def main(argv): option_parser = optparse.OptionParser() AddGeneratorOptions(option_parser) options, _ = option_parser.parse_args(argv) if not os.path.exists(options.source): print 'Source project does not exist, please provide correct directory.' sys.exit(1) out_dir = options.target if options.src_package: if options.shared: out_project_dir = os.path.join(out_dir, 'xwalk_shared_library_src') else: out_project_dir = os.path.join(out_dir, 'xwalk_core_library_src') else: if options.shared: out_project_dir = os.path.join(out_dir, 'xwalk_shared_library') else: out_project_dir = os.path.join(out_dir, 'xwalk_core_library') # Clean directory for project first. CleanLibraryProject(out_project_dir) if not os.path.exists(out_project_dir): os.mkdir(out_project_dir) # Copy Eclipse project files of library project. CopyProjectFiles(options.source, out_project_dir, options.shared) # Copy binaries and resuorces. CopyResources(options.source, out_dir, out_project_dir, options.shared) CopyBinaries(out_dir, out_project_dir, options.src_package, options.shared, options.use_lzma) # Copy JS API binding files. if not options.shared: CopyJSBindingFiles(options.source, out_project_dir) # Remove unused files. mode = os.path.basename(os.path.normpath(out_dir)) RemoveUnusedFilesInReleaseMode(mode, os.path.join(out_project_dir, 'libs')) # Create empty src directory src_dir = os.path.join(out_project_dir, 'src') if not os.path.isdir(src_dir): os.mkdir(src_dir) readme = os.path.join(src_dir, 'README.md') open(readme, 'w').write("# Source folder for xwalk library\n" "## Why it's empty\n" "xwalk library doesn't contain java sources.\n" "## Why put me here\n" "To make archives keep the folder, " "the src directory is needed to build an apk by ant.") print 'Your Android library project has been created at %s' % ( out_project_dir)
def main(argv): print 'Generating XWalkCore Library Project...' option_parser = optparse.OptionParser() AddGeneratorOptions(option_parser) options, _ = option_parser.parse_args(argv) if not os.path.exists(options.source): print 'Source project does not exist, please provide correct directory.' sys.exit(1) out_dir = options.target # Clean directory for project first. CleanLibraryProject(out_dir) out_project_dir = os.path.join(out_dir, LIBRARY_PROJECT_NAME) if not os.path.exists(out_project_dir): os.mkdir(out_project_dir) # Copy Eclipse project files of library project. CopyProjectFiles(options.source, out_dir) # Copy binaries and resuorces. CopyResources(options.source, out_dir) CopyBinaries(out_dir) # Copy JS API binding files. CopyJSBindingFiles(options.source, out_dir) # Post copy library project. PostCopyLibraryProject(out_dir) # Remove unused files. mode = os.path.basename(os.path.normpath(out_dir)) RemoveUnusedFilesInReleaseMode(mode, os.path.join(out_dir, LIBRARY_PROJECT_NAME, 'libs')) # Create empty src directory src_dir = os.path.join(out_project_dir, 'src') if not os.path.isdir(src_dir): os.mkdir(src_dir) print 'Your Android library project has been created at %s' % ( out_project_dir)
def PrepareFromXwalk(src_dir, target_dir): '''Prepare different files for app packaging tools. All resources are used by make_apk.py. ''' # The version of yui compressor. yui_compressor_version = '2.4.8' # Get the dir of source code from src_dir: ../../. source_code_dir = os.path.dirname(os.path.dirname(src_dir)) # The directory to copy libraries and code from. jar_src_dir = os.path.join(src_dir, 'lib.java') xwalk_core_library_dir = os.path.join(src_dir, 'xwalk_core_library') # 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 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-%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'), app_target_dir), (os.path.join(jar_src_dir, 'xwalk_app_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', '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), (os.path.join(tools_src_dir, 'customize_launch_screen.py'), target_dir), (os.path.join(tools_src_dir, 'extension_manager.py'), target_dir), (os.path.join(tools_src_dir, 'handle_permissions.py'), target_dir), (os.path.join(tools_src_dir, 'handle_xml.py'), target_dir), (os.path.join(tools_src_dir, 'make_apk.py'), target_dir), (os.path.join(tools_src_dir, 'manifest_json_parser.py'), target_dir), (os.path.join(tools_src_dir, 'parse_xpk.py'), target_dir), (os.path.join(tools_src_dir, 'util.py'), target_dir) ] for index in range(len(source_target_list)): source_path, target_path = source_target_list[index] # Process source. if not os.path.exists(source_path): print('The source path "%s" does not exist.' % source_path) continue source_is_file = os.path.isfile(source_path) # 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: shutil.copy(source_path, target_path) else: shutil.copytree(source_path, target_path) # Remove unused files. mode = os.path.basename(os.path.dirname(target_dir)) RemoveUnusedFilesInReleaseMode(mode, os.path.join(target_dir, 'native_libs'))
def PrepareFromXwalk(src_dir, target_dir): '''Prepare different files for app packaging tools. All resources are used by make_apk.py. ''' # The version of yui compressor. yui_compressor_version = '2.4.8' # 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. jar_src_dir = os.path.join(src_dir, 'lib.java') jar_target_dir = os.path.join(target_dir, 'libs') # 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') # 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. (os.path.join(source_code_dir, 'content/public/android/java/res'), os.path.join(target_dir, 'libs_res/content')), (os.path.join(source_code_dir, 'ui/android/java/res'), os.path.join(target_dir, 'libs_res/ui')), (os.path.join(source_code_dir, 'xwalk/runtime/android/core/res'), os.path.join(target_dir, 'libs_res/runtime')), (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, 'ui_java/res_crunched'), os.path.join(gen_res_target_dir, 'ui_java/res_crunched')), (os.path.join(gen_res_src_dir, 'ui_java/res_grit'), os.path.join(gen_res_target_dir, 'ui_java/res_grit')), (os.path.join(gen_res_src_dir, 'ui_java/res_v14_compatibility'), os.path.join(gen_res_target_dir, 'ui_java/res_v14_compatibility')), (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, 'content_java/res_crunched'), os.path.join(gen_res_target_dir, 'content_java/res_crunched')), (os.path.join(gen_res_src_dir, 'content_java/res_grit'), os.path.join(gen_res_target_dir, 'content_java/res_grit')), (os.path.join(gen_res_src_dir, 'content_java/res_v14_compatibility'), os.path.join(gen_res_target_dir, 'content_java/res_v14_compatibility')), (os.path.join(gen_res_src_dir, 'xwalk_core_java/java_R'), os.path.join(gen_res_target_dir, 'xwalk_core_java/java_R')), (os.path.join(gen_res_src_dir, 'xwalk_core_java/res_crunched'), os.path.join(gen_res_target_dir, 'xwalk_core_java/res_crunched')), (os.path.join(gen_res_src_dir, 'xwalk_core_java/res_grit'), os.path.join(gen_res_target_dir, 'xwalk_core_java/res_grit')), (os.path.join(gen_res_src_dir, 'xwalk_core_java/res_v14_compatibility'), os.path.join(gen_res_target_dir, 'xwalk_core_java/res_v14_compatibility')), # 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), # Build and python tools. (os.path.join(tools_src_dir, 'ant'), os.path.join(target_dir, 'scripts/ant')), (os.path.join(tools_src_dir, 'compress_js_and_css.py'), target_dir), (os.path.join(tools_src_dir, 'customize.py'), target_dir), (os.path.join(tools_src_dir, 'customize_launch_screen.py'), target_dir), (os.path.join(tools_src_dir, 'handle_permissions.py'), target_dir), (os.path.join(tools_src_dir, 'handle_xml.py'), target_dir), (os.path.join(tools_src_dir, 'make_apk.py'), target_dir), (os.path.join(tools_src_dir, 'manifest_json_parser.py'), target_dir), (os.path.join(tools_src_dir, 'parse_xpk.py'), target_dir) ] for index in range(len(source_target_list)): source_path, target_path = source_target_list[index] # Process source. if not os.path.exists(source_path): print('The source path "%s" does not exist.' % source_path) continue source_is_file = os.path.isfile(source_path) # Process target. if source_is_file and not os.path.exists(target_path): os.makedirs(target_path) # Do copy. if source_is_file: shutil.copy(source_path, target_path) else: shutil.copytree(source_path, target_path) # Remove unused files. mode = os.path.basename(os.path.dirname(target_dir)) RemoveUnusedFilesInReleaseMode(mode, os.path.join(target_dir, 'native_libs'))
def PrepareFromXwalk(src_dir, target_dir): """ Prepares xwalk_app_template/, which contains files used for packaging Crosswalk apps. Its primary consumer is app-tools. """ # Get the dir of source code from src_dir: ../../. source_code_dir = os.path.dirname(os.path.dirname(src_dir)) # The directory to copy libraries and code from. jar_src_dir = os.path.join(src_dir, 'lib.java') xwalk_core_library_dir = os.path.join(src_dir, 'xwalk_core_library') xwalk_shared_library_dir = os.path.join(src_dir, 'xwalk_shared_library') # 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 source file/directory list to be copied and the target directory list. source_target_list = [ (os.path.join(source_code_dir, 'xwalk/API_VERSION'), target_dir), (os.path.join(source_code_dir, 'xwalk/VERSION'), target_dir), # The app wrapper code. It's the template Java code. (os.path.join(source_code_dir, 'xwalk/app/android/app_template'), app_target_dir), (os.path.join(jar_src_dir, 'xwalk_app_runtime_java.jar'), jar_target_dir), # XWalk Core Library (xwalk_core_library_dir, os.path.join(target_dir, 'xwalk_core_library')), # XWalk Shared Library (xwalk_shared_library_dir, os.path.join(target_dir, 'xwalk_shared_library')), ] for index in range(len(source_target_list)): source_path, target_path = source_target_list[index] # Process source. if not os.path.exists(source_path): print('The source path "%s" does not exist.' % source_path) continue source_is_file = os.path.isfile(source_path) # 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: shutil.copy(source_path, target_path) else: shutil.copytree(source_path, target_path) # Remove unused files. mode = os.path.basename(os.path.dirname(target_dir)) RemoveUnusedFilesInReleaseMode(mode, os.path.join(target_dir, 'native_libs'))
os.path.join(output_dir, 'libs', 'xwalk_app_runtime_java.jar')), ) for src, dest in dirs: shutil.copytree(src, dest) for src, dest in files: try: os.makedirs(os.path.dirname(dest)) except OSError, e: if e.errno == errno.EEXIST: pass shutil.copy2(src, dest) # Remove gdbserver from Release builds. See http://crrev.com/14200040 and # Android's platform/sdk's ApkBuilder.java which do the same. RemoveUnusedFilesInReleaseMode(build_mode, os.path.join(output_dir, 'native_libs')) def main(): parser = argparse.ArgumentParser() parser.add_argument('--build-dir', required=True, help='Build directory location.') parser.add_argument('--build-mode', required=True, help='Build mode (Release, Debug etc).') parser.add_argument('--output-dir', required=True, help='Directory where the app template files will be ' 'stored.') parser.add_argument('--source-dir', required=True, help='Top-level source directory location.') args = parser.parse_args()