shutil.rmtree(dir_to_clean)
-def PrepareFromChromium(target_dir):
- gyp_dir = os.path.join(target_dir, 'scripts', 'gyp')
- if not os.path.exists(gyp_dir):
- os.makedirs(gyp_dir)
- shutil.copytree('../build/android/gyp/util', os.path.join(gyp_dir, 'util'))
-
-
def PrepareFromXwalk(src_dir, target_dir):
'''Prepare different files for app packaging tools. All resources are used by
make_apk.py.
# Get the dir of source code from src_dir: ../../.
source_code_dir = os.path.dirname(os.path.dirname(src_dir))
- # The directories for source and target .jar files.
+ # The directory to copy libraries and code from.
jar_src_dir = os.path.join(src_dir, 'lib.java')
- jar_target_dir = os.path.join(target_dir, 'libs')
+ xwalk_core_library_dir = os.path.join(src_dir, 'xwalk_core_library')
- # The directories for generated resources.
- gen_res_src_dir = os.path.join(src_dir, 'gen')
- gen_res_target_dir = os.path.join(target_dir, 'gen')
- xwalk_core_library_res_dir = os.path.join(
- src_dir, 'xwalk_core_library', 'res')
+ # The directory to copy libraries, code and resources to.
+ app_target_dir = os.path.join(target_dir, 'template')
+ jar_target_dir = os.path.join(app_target_dir, 'libs')
# The directory for source packaging tools.
tools_src_dir = os.path.join(source_code_dir, 'xwalk/app/tools/android')
- # The directories for source and target gyp.
- gyp_src_dir = os.path.join(tools_src_dir, 'gyp')
- gyp_target_dir = os.path.join(target_dir, 'scripts/gyp')
-
# The source file/directory list to be copied and the target directory list.
source_target_list = [
(os.path.join(source_code_dir, 'xwalk/VERSION'), target_dir),
# This jar is needed for minifying and obfuscating the javascript and css.
(os.path.join(tools_src_dir,
- 'libs/yuicompressor-' + yui_compressor_version + '.jar'),
- jar_target_dir),
-
- # This jar is needed for 'javac' compile.
- (os.path.join(jar_src_dir, 'xwalk_app_runtime_java.jar'), jar_target_dir),
- (os.path.join(jar_src_dir, 'xwalk_runtime_embedded.dex.jar'),
- jar_target_dir),
-
- # Native library, like libxwalkcore.so.
- (os.path.join(src_dir, 'xwalk_runtime_lib_apk/libs/x86'),
- os.path.join(target_dir, 'native_libs/x86/libs/x86')),
- (os.path.join(src_dir, 'xwalk_runtime_lib_apk/libs/armeabi-v7a'),
- os.path.join(target_dir, 'native_libs/armeabi-v7a/libs/armeabi-v7a')),
-
- # Native source package(xwalk.pak) and related js files for extension.
- (os.path.join(src_dir, 'xwalk_runtime_lib/assets'),
- os.path.join(target_dir, 'native_libs_res')),
-
- # Various Java resources.
- # FIXME(wang16): Copy from the xwalk_core_library first. We need to
- # consider refine the whole process of make_apk.
- (os.path.join(gen_res_src_dir, 'ui_java/java_R'),
- os.path.join(gen_res_target_dir, 'ui_java/java_R')),
- (os.path.join(gen_res_src_dir, 'content_java/java_R'),
- os.path.join(gen_res_target_dir, 'content_java/java_R')),
- (os.path.join(gen_res_src_dir, 'xwalk_core_internal_java/java_R'),
- os.path.join(gen_res_target_dir, 'xwalk_core_internal_java/java_R')),
- (xwalk_core_library_res_dir,
- os.path.join(target_dir, 'libs_res/xwalk_core_library')),
+ 'libs/yuicompressor-%s.jar' % yui_compressor_version),
+ target_dir),
# The app wrapper code. It's the template Java code.
(os.path.join(source_code_dir, 'xwalk/app/android/app_template'),
- os.path.join(target_dir, 'app_src')),
-
- # Copy below 7 files to overwrite the existing ones from Chromium.
- (os.path.join(gyp_src_dir, 'util/build_utils.py'),
- os.path.join(gyp_target_dir, 'util')),
- (os.path.join(gyp_src_dir, 'util/md5_check.py'),
- os.path.join(gyp_target_dir, 'util')),
- (os.path.join(gyp_src_dir, 'ant.py'), gyp_target_dir),
- (os.path.join(gyp_src_dir, 'dex.py'), gyp_target_dir),
- (os.path.join(gyp_src_dir, 'finalize_apk.py'), gyp_target_dir),
- (os.path.join(gyp_src_dir, 'jar.py'), gyp_target_dir),
- (os.path.join(gyp_src_dir, 'javac.py'), gyp_target_dir),
+ app_target_dir),
+
+ # Shared mode uses xwalk_app_runtime_java.jar only.
+ # Embedded mode needs both.
+ (os.path.join(jar_src_dir, 'xwalk_app_runtime_java.jar'), jar_target_dir),
+ (os.path.join(jar_src_dir, 'xwalk_runtime_java.jar'), jar_target_dir),
+
+ # XWalk Core Library
+ (xwalk_core_library_dir, os.path.join(target_dir, 'xwalk_core_library')),
# Build and python tools.
- (os.path.join(tools_src_dir, 'ant'),
- os.path.join(target_dir, 'scripts/ant')),
+ (os.path.join(tools_src_dir, 'ant', 'xwalk-debug.keystore'), target_dir),
(os.path.join(tools_src_dir, 'app_info.py'), target_dir),
(os.path.join(tools_src_dir, 'compress_js_and_css.py'), target_dir),
(os.path.join(tools_src_dir, 'customize.py'), target_dir),
# Process target.
if source_is_file and not os.path.exists(target_path):
os.makedirs(target_path)
+ if not source_is_file and os.path.isdir(target_path):
+ shutil.rmtree(target_path)
# Do copy.
if source_is_file:
target_dir = args[0]
src_dir = os.path.dirname(target_dir)
Clean(target_dir)
- PrepareFromChromium(target_dir)
PrepareFromXwalk(src_dir, target_dir)