3 # Copyright (c) 2013 Intel Corporation. All rights reserved.
4 # Use of this source code is governed by a BSD-style license that can be
5 # found in the LICENSE file.
6 # pylint: disable=F0401
11 from common_function import RemoveUnusedFilesInReleaseMode
13 def Clean(dir_to_clean):
14 if os.path.isdir(dir_to_clean):
15 shutil.rmtree(dir_to_clean)
18 def PrepareFromXwalk(src_dir, target_dir):
19 '''Prepare different files for app packaging tools. All resources are used by
22 # The version of yui compressor.
23 yui_compressor_version = '2.4.8'
25 # Get the dir of source code from src_dir: ../../.
26 source_code_dir = os.path.dirname(os.path.dirname(src_dir))
28 # The directory to copy libraries and code from.
29 jar_src_dir = os.path.join(src_dir, 'lib.java')
30 xwalk_core_library_dir = os.path.join(src_dir, 'xwalk_core_library')
32 # The directory to copy libraries, code and resources to.
33 app_target_dir = os.path.join(target_dir, 'template')
34 jar_target_dir = os.path.join(app_target_dir, 'libs')
36 # The directory for source packaging tools.
37 tools_src_dir = os.path.join(source_code_dir, 'xwalk/app/tools/android')
39 # The source file/directory list to be copied and the target directory list.
40 source_target_list = [
41 (os.path.join(source_code_dir, 'xwalk/VERSION'), target_dir),
43 # This jar is needed for minifying and obfuscating the javascript and css.
44 (os.path.join(tools_src_dir,
45 'libs/yuicompressor-%s.jar' % yui_compressor_version),
48 # The app wrapper code. It's the template Java code.
49 (os.path.join(source_code_dir, 'xwalk/app/android/app_template'),
52 (os.path.join(jar_src_dir, 'xwalk_app_runtime_java.jar'), jar_target_dir),
55 (xwalk_core_library_dir, os.path.join(target_dir, 'xwalk_core_library')),
57 # Build and python tools.
58 (os.path.join(tools_src_dir, 'ant', 'xwalk-debug.keystore'), target_dir),
59 (os.path.join(tools_src_dir, 'app_info.py'), target_dir),
60 (os.path.join(tools_src_dir, 'compress_js_and_css.py'), target_dir),
61 (os.path.join(tools_src_dir, 'customize.py'), target_dir),
62 (os.path.join(tools_src_dir, 'customize_launch_screen.py'), target_dir),
63 (os.path.join(tools_src_dir, 'extension_manager.py'), target_dir),
64 (os.path.join(tools_src_dir, 'handle_permissions.py'), target_dir),
65 (os.path.join(tools_src_dir, 'handle_xml.py'), target_dir),
66 (os.path.join(tools_src_dir, 'make_apk.py'), target_dir),
67 (os.path.join(tools_src_dir, 'manifest_json_parser.py'), target_dir),
68 (os.path.join(tools_src_dir, 'parse_xpk.py'), target_dir),
69 (os.path.join(tools_src_dir, 'util.py'), target_dir)
72 for index in range(len(source_target_list)):
73 source_path, target_path = source_target_list[index]
76 if not os.path.exists(source_path):
77 print ('The source path "%s" does not exist.' % source_path)
80 source_is_file = os.path.isfile(source_path)
83 if source_is_file and not os.path.exists(target_path):
84 os.makedirs(target_path)
85 if not source_is_file and os.path.isdir(target_path):
86 shutil.rmtree(target_path)
90 shutil.copy(source_path, target_path)
92 shutil.copytree(source_path, target_path)
94 # Remove unused files.
95 mode = os.path.basename(os.path.dirname(target_dir))
96 RemoveUnusedFilesInReleaseMode(mode, os.path.join(target_dir, 'native_libs'))
101 print 'You must provide only one argument: folder to update'
104 src_dir = os.path.dirname(target_dir)
106 PrepareFromXwalk(src_dir, target_dir)
109 if __name__ == '__main__':
110 sys.exit(main(sys.argv[1:]))