def main(argv): argv = build_utils.expand_file_args(argv) args = parse_args(argv) # print(args) proguard = proguard_util.ProguardCmdBuilder(args.proguard_path) proguard.injars(build_utils.parse_gyp_list(args.input_paths)) proguard.configs(build_utils.parse_gyp_list(args.proguard_configs)) proguard.outjar(args.output_path) if args.mapping: proguard.mapping(args.mapping) if args.tested_apk_info: proguard.tested_apk_info(args.tested_apk_info) classpath = list(set(args.classpath)) proguard.libraryjars(classpath) proguard.verbose(args.verbose) input_paths = proguard.get_inputs() proguard.check_output() if args.depfile: all_dep_paths = list(input_paths) all_dep_paths.extend(build_utils.get_python_dependencies()) build_utils.write_dep_file(args.depfile, all_dep_paths) pass pass
def parse_args(argv): argv = list(sys.argv[1:]) argv = build_utils.expand_file_args(argv) parser = create_parser() args = parser.parse_args(argv) requires_options = [ "android_sdk_jar", "aapt_path", "android_manifest", "dependency_res_zips", "resource_dirs", "resource_zip_out" ] build_utils.check_options(args, parser, required=requires_options) args.resource_dirs = build_utils.parse_gyp_list(args.resource_dirs) args.dependency_res_zips = build_utils.parse_gyp_list( args.dependency_res_zips) if args.extra_r_text_files: args.extra_r_text_files = build_utils.parse_gyp_list( args.extra_r_text_files) else: args.extra_r_text_files = [] if args.extra_res_packages: args.extra_res_packages = build_utils.parse_gyp_list( args.extra_res_packages) else: args.extra_res_packages = [] return args
def parse_args(argv): argv = build_utils.expand_file_args(argv) parser = create_parser() args = parser.parse_args(argv) args.assets = build_utils.parse_gyp_list(args.assets) args.uncompressed_assets = build_utils.parse_gyp_list( args.uncompressed_assets) args.native_lib_placeholders = build_utils.parse_gyp_list( args.native_lib_placeholders) all_libs = [] for item in args.native_libs: all_libs.extend(build_utils.parse_gyp_list(item)) args.native_libs = all_libs secondary_libs = [] for item in args.secondary_native_libs: secondary_libs.extend(build_utils.parse_gyp_list(item)) args.secondary_native_libs = secondary_libs if not args.android_abi and (args.native_libs or args.native_lib_placeholders): raise Exception("Must specify --android-abi with --native-libs") if not args.secondary_android_abi and args.secondary_native_libs: raise Exception("Must specify --secondary-android-abi with" " --secondary-native-libs") return args
def parse_args(): parser = create_parser() args = parser.parse_args() required_options = ("android_sdk_jar", "aapt_path", "configuration_name", "android_manifest", "version_code", "version_name", "apk_path") build_utils.check_options(args, parser, required=required_options) args.resource_zips = build_utils.parse_gyp_list(args.resource_zips) args.language_splits = build_utils.parse_gyp_list(args.language_splits) return args
def parse_args(argv): parser = create_parser() args = parser.parse_args(argv) args.imports = build_utils.parse_gyp_list(args.imports) includes = [] if args.includes: includes.extend(build_utils.parse_gyp_list(args.includes)) args.includes = includes return args
def main(argv): argv = build_utils.expand_file_args(argv) parser = argparse.ArgumentParser(prog="create_java_binary_script.py") build_utils.add_depfile_option(parser) parser.add_argument('--output', help='Output path for executable script.') parser.add_argument('--jar-path', help='Path to the main jar.') parser.add_argument( '--main-class', help='Name of the java class with the "main" entry point.') parser.add_argument('--classpath', action='append', default=[], help='Classpath for running the jar.') parser.add_argument( '--bootclasspath', action='append', default=[], help='zip/jar files to add to bootclasspath for java cmd.') parser.add_argument("extra_program_args", nargs="*") args = parser.parse_args(argv) if args.extra_program_args is None: args.extra_program_args = [] classpath = [args.jar_path] for cp_arg in args.classpath: classpath += build_utils.parse_gyp_list(cp_arg) bootclasspath = [] for bootcp_arg in args.bootclasspath: bootclasspath += build_utils.parse_gyp_list(bootcp_arg) bootclasspath = [os.path.abspath(p) for p in bootclasspath] classpath = [os.path.abspath(p) for p in classpath] with open(args.output, 'w') as script: script.write( script_template.format(classpath=repr(classpath), bootclasspath=repr(bootclasspath), main_class=args.main_class, extra_program_args=repr( args.extra_program_args))) os.chmod(args.output, 0o750) if args.depfile: build_utils.write_dep_file(args.depfile, build_utils.get_python_dependencies())
def parse_args(argv): parser = create_parser() args = parser.parse_args(argv) classpath = [] for arg in args.classpath: classpath.extend(build_utils.parse_gyp_list(arg)) args.classpath = classpath return args
def parse_args(argv): argv = build_utils.expand_file_args(argv) parser = create_parser() args = parser.parse_args(argv) input_list = [] for item in args.inputs: input_list.extend(build_utils.parse_gyp_list(item)) args.inputs = input_list return args
def main(argv): parser = create_parser() args = parser.parse_args(argv) inputs = build_utils.parse_gyp_list(args.inputs) output = args.output build_utils.do_zip(inputs, output, args.base_dir) if args.depfile: build_utils.write_dep_file(args.depfile, build_utils.get_python_dependencies()) pass
def parse_options(argv): parser = create_parser() args = parser.parse_args(argv) build_utils.check_options(args, parser, required=("jar_path", "base_dir")) bootclasspath = [] for arg in args.bootclasspath: bootclasspath += build_utils.parse_gyp_list(arg) args.bootclasspath = bootclasspath classpath = [] for arg in args.classpath: classpath += build_utils.parse_gyp_list(arg) args.classpath = classpath java_srcjars = [] for arg in args.java_srcjars: java_srcjars += build_utils.parse_gyp_list(arg) args.java_srcjars = java_srcjars if args.src_gendirs: args.src_gendirs = build_utils.parse_gyp_list(args.src_gendirs) args.javac_includes = build_utils.parse_gyp_list(args.javac_includes) args.jar_excluded_classes = build_utils.parse_gyp_list( args.jar_excluded_classes) return args
def main(): parser = create_parser() args = parser.parse_args() build_utils.check_options(args, parser, required=['inputs']) inputs = build_utils.parse_gyp_list(args.inputs) if (args.output is None) == (args.outputs_zip is None): args.error('Exactly one of --output and --output-zip must be given') if args.output and len(inputs) != 1: args.error('--output cannot be used with multiple inputs') if args.outputs_zip and not args.inputs_base_dir: args.error('--inputs-base-dir must be given when --output-zip is used') variables = {} for v in build_utils.parse_gyp_list(args.variables): if '=' not in v: args.error('--variables argument must contain "=": ' + v) name, _, value = v.partition('=') variables[name] = value loader = RecordingFileSystemLoader(args.loader_base_dir) env = jinja2.Environment(loader=loader, undefined=jinja2.StrictUndefined, line_comment_prefix='##') if args.output: # 只处理单个文件 process_file(env, inputs[0], args.loader_base_dir, args.output, variables) else: # 处理多个文件 process_files(env, inputs, args.loader_base_dir, args.inputs_base_dir, args.outputs_zip, variables) if args.depfile: deps = loader.get_loaded_templates( ) + build_utils.get_python_dependencies() build_utils.write_dep_file(args.depfile, deps) pass
def parse_args(parser, argv): argv = build_utils.expand_file_args(argv) args = parser.parse_args(argv) required_options = ("android_sdk_tools", ) build_utils.check_options(args, parser, required=required_options) if args.multidex_configuration_path: with open(args.multidex_configuration_path) as multidex_config_file: multidex_config = json.load(multidex_config_file) args.multi_dex = multidex_config.get("enabled", False) pass # if args.multi_dex and not args.main_dex_list_path: # print("multidex cannot be enabled without --main-dex-list-path") # args.multi_dex = False elif args.main_dex_list_path and not args.multi_dex: print("--main-dex-list-path is unused if --multi-dex is not enabled") if args.inputs: args.inputs = build_utils.parse_gyp_list(args.inputs) if args.excluded_paths: args.excluded_paths = build_utils.parse_gyp_list(args.excluded_paths) return args
def main(argv): argv = build_utils.expand_file_args(argv) parser = create_parser() args = parser.parse_args(argv) defines = [] for arg in args.defines: defines.extend(build_utils.parse_gyp_list(arg)) args.defines = defines do_gcc(args) if args.depfile: build_utils.write_dep_file(args.depfile, build_utils.get_python_dependencies()) if args.stamp: build_utils.touch(args.stamp) pass
def main(argv): argv = build_utils.expand_file_args(argv) parser = create_parser() args = parser.parse_args(argv) # print(args) if args.multidex_configuration_path: multidex_config = build_utils.read_json( args.multidex_configuration_path) if not multidex_config.get("enabled", False): return 0 if args.inputs: args.paths.extend(build_utils.parse_gyp_list(args.inputs)) shrinked_android_jar = os.path.abspath( os.path.join(args.android_sdk_tools, 'lib', 'shrinkedAndroid.jar')) dx_jar = os.path.abspath( os.path.join(args.android_sdk_tools, 'lib', 'dx.jar')) rules_file = os.path.abspath( os.path.join(args.android_sdk_tools, 'mainDexClasses.rules')) proguard_cmd = [ "java", "-jar", args.proguard_jar_path, '-forceprocessing', '-dontwarn', '-dontoptimize', '-dontobfuscate', '-dontpreverify', '-libraryjars', shrinked_android_jar, '-include', rules_file, ] for m in args.main_dex_rules_paths: proguard_cmd.extend(["-include", m]) pass main_dex_list_cmd = [ "java", "-cp", dx_jar, "com.android.multidex.MainDexListBuilder", ] input_paths = list(args.paths) input_paths += [ shrinked_android_jar, dx_jar, rules_file, ] input_paths += args.main_dex_rules_paths input_strings = [ proguard_cmd, main_dex_list_cmd, ] output_paths = [ args.main_dex_list_path, ] _on_stale_md5(args, proguard_cmd, main_dex_list_cmd, args.paths, args.main_dex_list_path) if args.depfile: all_dep_paths = list(input_paths) all_dep_paths.extend(build_utils.get_python_dependencies()) build_utils.write_dep_file(args.depfile, all_dep_paths) pass
def main(): parser = create_parser() args = parser.parse_args() requires_options_map = { "java_library": ["build_config", "jar_path", "srczip_path"], "java_binary": ["build_config", "jar_path"], "android_resources": ["build_config", "resources_zip"], "android_assets": ["build_config"], "android_native_libraries": ["build_config", "native_libs"], "android_apk": ["build_config", "apk_path", "dex_path"], "deps_dex": ["build_config", "dex_path"], "group": ["build_config"] } # 检查必须的选项 requires_options = requires_options_map.get(args.type) if requires_options is None: raise Exception("Unknown type: %s" % args.type) build_utils.check_options(args, parser, required=requires_options) if type == "java_library": if args.supports_android and not args.dex_path: raise Exception( "--dex-path must be set if --supports-android is enabled") if args.requires_android and not args.supports_android: raise Exception( "--supports-android must be set is --requires-android is enabled") pass if args.possible_deps_configs is None: args.possible_deps_configs = [] possible_deps_config_paths = args.possible_deps_configs allow_unknown_deps = (args.type in ( "android_apk", "android_resources", "android_assets", "android_native_libraries")) unknown_deps = [ c for c in possible_deps_config_paths if not os.path.exists(c)] if not allow_unknown_deps and unknown_deps: raise Exception("Unknown deps: %s" % str(unknown_deps)) # 直接依赖 direct_deps_config_paths = [c for c in possible_deps_config_paths if c not in unknown_deps] direct_deps_config_paths = _filter_unwanted_deps_configs(args.type, direct_deps_config_paths) deps = Deps(direct_deps_config_paths) all_inputs = deps.all_config_paths() + build_utils.get_python_dependencies() if args.has_alternative_locale_resource: # 移除其他的资源 alternative = [c["path"] for c in deps.direct("android_resources") if c["is_locale_resource"]] if len(alternative) != 1: raise Exception() unwanted = [c["path"] for c in deps.all("android_resources") if c["is_locale_resource"]] for path in unwanted: if path != alternative[0]: deps.remove_non_direct_dep(unwanted) pass config = { "deps_info": { "name": os.path.basename(args.build_config), "path": args.build_config, "type": args.type, "deps_configs": direct_deps_config_paths } } deps_info = config["deps_info"] direct_library_deps = deps.direct("java_library") all_library_deps = deps.all("java_library") direct_resources_deps = deps.direct("android_resources") all_resources_deps = deps.all("android_resources") all_resources_deps.reverse() all_native_libraries_deps = deps.all("android_native_libraries") if args.type == "android_apk" and args.tested_apk_config: tested_apk_deps = Deps([args.tested_apk_config]) tested_apk_resource_deps = tested_apk_deps.all("android_resources") direct_resources_deps = [d for d in direct_resources_deps if d not in tested_apk_resource_deps] all_resources_deps = [d for d in all_resources_deps if d not in tested_apk_resource_deps] pass if args.type in ("java_library", "java_binary") and not args.bypass_platform_checks: deps_info["requires_android"] = args.requires_android deps_info["supports_android"] = args.supports_android deps_requires_android = [d["name"] for d in all_library_deps if d["requires_android"]] deps_not_supports_android = [d["name"] for d in all_library_deps if not d["supports_android"]] if not args.requires_android and deps_requires_android: raise Exception("Some deps requires building for the android platform: %s" % " ".join(deps_requires_android)) if args.supports_android and deps_not_supports_android: raise Exception("Some deps not supports running on the android platform: %s" % " ".join(deps_not_supports_android)) pass if args.type in ("java_library", "java_binary", "android_apk"): javac_classpath = [c["jar_path"] for c in direct_library_deps] java_full_classpath = [c["jar_path"] for c in all_library_deps] config["resources_deps"] = [c["path"] for c in all_resources_deps] deps_info["jar_path"] = args.jar_path deps_info["srczip_path"] = args.srczip_path if args.type == "android_apk" or args.supports_android: deps_info["dex_path"] = args.dex_path if args.type == "android_apk": deps_info["apk_path"] = args.apk_path deps_info["incremental_apk_path"] = args.incremental_apk_path deps_info["incremental_install_script_path"] = args.incremental_install_script_path config["javac"] = {} pass if args.type in ("java_binary", "java_library"): config["javac"]["srcjars"] = [c["srcjar"] for c in direct_resources_deps] if args.type == "android_apk": config["javac"]["srcjars"] = [] if args.type == "android_assets": all_assets_sources = [] if args.asset_renaming_sources: all_assets_sources.extend(args.asset_renaming_sources) if args.asset_sources: all_assets_sources.extend(args.asset_sources) deps_info["assets"] = { "sources": all_assets_sources, } all_assets_outputs = [] if args.asset_renaming_destinations: all_assets_outputs.extend(args.asset_renaming_destinations) deps_info["assets"]["outputs"] = all_assets_outputs deps_info["assets"]["disable_compression"] = args.disable_asset_compression pass if args.type == "android_resources": deps_info["resources_zip"] = args.resources_zip deps_info["r_text"] = args.r_text deps_info["is_locale_resource"] = args.is_locale_resource if args.srcjar: deps_info["srcjar"] = args.srcjar if args.android_manifest: manifest = AndroidManifest(args.android_manifest) deps_info["package_name"] = manifest.get_package_name() if args.package_name: deps_info["package_name"] = args.package_name pass if args.type == "android_native_libraries": deps_info["native_libs"] = build_utils.parse_gyp_list(args.native_libs) pass if args.type in ("android_resources", "android_apk", "resources_rewriter"): config["resources"] = {} config["resources"]["dependency_zips"] = [d["resources_zip"] for d in all_resources_deps] config["resources"]["extra_package_names"] = [] config["resources"]["extra_r_text_files"] = [] pass if args.type in ("android_apk", "android_resources", "resources_rewriter"): config["resources"]["extra_package_names"] = [c["package_name"] for c in all_resources_deps if "package_name" in c] config["resources"]["extra_r_text_files"] = [c["r_text"] for c in all_resources_deps if "r_text" in c] if args.type in ("android_apk", "deps_dex"): deps_dex_paths = [c["dex_path"] for c in all_library_deps] proguard_enabled = args.proguard_enabled if args.type == "android_apk": deps_info["proguard_enabled"] = proguard_enabled if proguard_enabled: deps_info["proguard_info"] = args.proguard_info config["proguard"] = {} proguard_config = config["proguard"] proguard_config["input_paths"] = [args.jar_path] + java_full_classpath if args.type in ("android_apk", "deps_dex"): config["final_dex"] = {} dex_config = config["final_dex"] dex_config["dependency_dex_files"] = deps_dex_paths pass if args.type in ("android_apk", "java_library", "java_binary"): config["javac"]["classpath"] = javac_classpath config["javac"]["interface_classpath"] = [as_interface_jar(path) for path in javac_classpath] config["java"] = { "full_classpath": java_full_classpath } if args.type == "android_apk": dependency_jars = [c["jar_path"] for c in all_library_deps] all_interface_jars = [as_interface_jar(p) for p in dependency_jars + [args.jar_path]] all_srczips = [c["srczip_path"] for c in all_library_deps] all_srczips.append(args.srczip_path) config["dist_jar"] = { "dependency_jars": dependency_jars, "all_interface_jars": all_interface_jars, "all_srczips": all_srczips, } manifest = AndroidManifest(args.android_manifest) deps_info["package_name"] = manifest.get_package_name() if not args.tested_apk_config and manifest.get_instrumentation(): manifest.check_instrumentation(manifest.get_package_name()) library_paths = [] java_libraries_list_holder = [None] libraries = build_utils.parse_gyp_list(args.native_libs or '[]') for d in all_native_libraries_deps: libraries.extend(d["native_libs"]) if libraries: all_deps = [path for path in libraries] library_paths = [path for path in all_deps] java_libraries_list_holder[0] = ("{%s}" % ",".join( ['"%s"' % s[3:-3] for s in library_paths])) pass all_inputs.extend(library_paths) config["native"] = { "libraries": library_paths, "java_libraries_list": java_libraries_list_holder[0] } config["assets"], config["uncompressed_assets"] = _merge_assets( deps.all("android_assets")) pass build_utils.write_json(config, args.build_config) if args.depfile: build_utils.write_dep_file(args.depfile, all_inputs) pass