# Copyright 2014 The Chromium Authors. All rights reserved. # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file. import("//build/config/android/config.gni") assert(is_android) rebased_android_sdk = rebase_path(android_sdk, root_build_dir) rebased_android_sdk_root = rebase_path(android_sdk_root, root_build_dir) rebased_android_sdk_build_tools = rebase_path(android_sdk_build_tools, root_build_dir) android_sdk_jar = "$android_sdk/android.jar" rebased_android_sdk_jar = rebase_path(android_sdk_jar, root_build_dir) template("android_lint") { set_sources_assignment_filter([]) if (defined(invoker.testonly)) { testonly = invoker.testonly } jar_path = invoker.jar_path android_manifest = invoker.android_manifest java_files = invoker.java_files base_path = "$target_gen_dir/$target_name" action(target_name) { script = "//build/android/gyp/lint.py" result_path = base_path + "/result.xml" config_path = base_path + "/config.xml" suppressions_file = "//build/android/lint/suppressions.xml" inputs = [ suppressions_file, android_manifest, jar_path, ] + java_files outputs = [ config_path, result_path, ] rebased_java_files = rebase_path(java_files, root_build_dir) args = [ "--lint-path=$rebased_android_sdk_root/tools/lint", "--config-path", rebase_path(suppressions_file, root_build_dir), "--manifest-path", rebase_path(android_manifest, root_build_dir), "--product-dir=.", "--jar-path", rebase_path(jar_path, root_build_dir), "--processed-config-path", rebase_path(config_path, root_build_dir), "--result-path", rebase_path(result_path, root_build_dir), "--java-files=$rebased_java_files", "--enable", ] } } template("findbugs") { jar_path = invoker.jar_path build_config = invoker.build_config action(target_name) { script = "//build/android/findbugs_diff.py" depfile = "$target_gen_dir/$target_name.d" result_path = "$target_gen_dir/$target_name/result.xml" exclusions_file = "//build/android/findbugs_filter/findbugs_exclude.xml" rebased_build_config = rebase_path(build_config, root_build_dir) inputs = [ "//build/android/pylib/utils/findbugs.py", exclusions_file, jar_path, ] outputs = [ depfile, result_path, ] args = [ "--depfile", rebase_path(depfile, root_build_dir), "--exclude", rebase_path(exclusions_file, root_build_dir), "--auxclasspath-gyp", "@FileArg($rebased_build_config:javac:classpath)", "--output-file", rebase_path(result_path, root_build_dir), rebase_path(jar_path, root_build_dir), ] } } template("dex") { set_sources_assignment_filter([]) if (defined(invoker.testonly)) { testonly = invoker.testonly } assert(defined(invoker.output)) action(target_name) { script = "//build/android/gyp/dex.py" depfile = "$target_gen_dir/$target_name.d" if (defined(invoker.sources)) { sources = invoker.sources } outputs = [ depfile, invoker.output, ] if (defined(invoker.inputs)) { inputs = invoker.inputs } if (defined(invoker.deps)) { deps = invoker.deps } rebased_output = rebase_path(invoker.output, root_build_dir) args = [ "--depfile", rebase_path(depfile, root_build_dir), "--android-sdk-tools", rebased_android_sdk_build_tools, "--dex-path", rebased_output, ] if (defined(invoker.no_locals) && invoker.no_locals) { args += [ "--no-locals=1" ] } if (defined(invoker.args)) { args += invoker.args } if (defined(invoker.sources)) { args += rebase_path(invoker.sources, root_build_dir) } } } # Creates a zip archive of the inputs. # If base_dir is provided, the archive paths will be relative to it. template("zip") { set_sources_assignment_filter([]) if (defined(invoker.testonly)) { testonly = invoker.testonly } assert(defined(invoker.inputs)) assert(defined(invoker.output)) rebase_inputs = rebase_path(invoker.inputs, root_build_dir) rebase_output = rebase_path(invoker.output, root_build_dir) action(target_name) { script = "//build/android/gn/zip.py" depfile = "$target_gen_dir/$target_name.d" inputs = invoker.inputs outputs = [ depfile, invoker.output, ] args = [ "--depfile", rebase_path(depfile, root_build_dir), "--inputs=$rebase_inputs", "--output=$rebase_output", ] if (defined(invoker.base_dir)) { args += [ "--base-dir", rebase_path(invoker.base_dir, root_build_dir), ] } } } # Write the target's .build_config file. This is a json file that contains a # dictionary of information about how to build this target (things that # require knowledge about this target's dependencies and cannot be calculated # at gn-time). There is a special syntax to add a value in that dictionary to # an action/action_foreachs args: # --python-arg=@FileArg($rebased_build_config_path:key0:key1) # At runtime, such an arg will be replaced by the value in the build_config. # See build/android/gyp/write_build_config.py and # build/android/gyp/util/build_utils.py:ExpandFileArgs template("write_build_config") { set_sources_assignment_filter([]) if (defined(invoker.testonly)) { testonly = invoker.testonly } assert(defined(invoker.type)) assert(defined(invoker.build_config)) type = invoker.type build_config = invoker.build_config assert(type == "android_apk" || type == "java_library" || type == "android_resources" || type == "deps_dex") action(target_name) { script = "//build/android/gyp/write_build_config.py" depfile = "$target_gen_dir/$target_name.d" inputs = [] deps = [] if (defined(invoker.deps)) { deps += invoker.deps } possible_deps_configs = [] foreach(d, deps) { dep_gen_dir = get_label_info(d, "target_gen_dir") dep_name = get_label_info(d, "name") possible_deps_configs += [ "$dep_gen_dir/$dep_name.build_config" ] } rebase_possible_deps_configs = rebase_path(possible_deps_configs, root_build_dir) outputs = [ depfile, build_config, ] args = [ "--type", type, "--depfile", rebase_path(depfile, root_build_dir), "--possible-deps-configs=$rebase_possible_deps_configs", "--build-config", rebase_path(build_config, root_build_dir), ] is_java_library = type == "java_library" is_apk = type == "android_apk" is_android_resources = type == "android_resources" is_deps_dex = type == "deps_dex" supports_android = is_apk || is_android_resources || is_deps_dex || (is_java_library && defined(invoker.supports_android) && invoker.supports_android) requires_android = is_apk || is_android_resources || is_deps_dex || (is_java_library && defined(invoker.requires_android) && invoker.requires_android) assert(!requires_android || supports_android, "requires_android requires" + " supports_android") # Mark these variables as used. assert(is_java_library || true) assert(is_apk || true) assert(is_android_resources || true) assert(is_deps_dex || true) if (is_java_library || is_apk) { args += [ "--jar-path", rebase_path(invoker.jar_path, root_build_dir), ] } if (is_apk || is_deps_dex || (is_java_library && supports_android)) { args += [ "--dex-path", rebase_path(invoker.dex_path, root_build_dir), ] } if (supports_android) { args += [ "--supports-android" ] } if (requires_android) { args += [ "--requires-android" ] } if (defined(invoker.bypass_platform_checks) && invoker.bypass_platform_checks) { args += [ "--bypass-platform-checks" ] } if (defined(invoker.apk_under_test)) { deps += [ invoker.apk_under_test ] apk_under_test_gen_dir = get_label_info(invoker.apk_under_test, "target_gen_dir") apk_under_test_name = get_label_info(invoker.apk_under_test, "name") apk_under_test_config = "$apk_under_test_gen_dir/$apk_under_test_name.build_config" args += [ "--tested-apk-config", rebase_path(apk_under_test_config, root_build_dir), ] } if (is_android_resources || is_apk) { assert(defined(invoker.resources_zip)) args += [ "--resources-zip", rebase_path(invoker.resources_zip, root_build_dir), ] if (defined(invoker.android_manifest)) { inputs += [ invoker.android_manifest ] args += [ "--android-manifest", rebase_path(invoker.android_manifest, root_build_dir), ] } else { assert(!is_apk, "apk build configs require an android_manifest") } if (defined(invoker.custom_package)) { args += [ "--package-name", invoker.custom_package, ] } if (defined(invoker.r_text)) { args += [ "--r-text", rebase_path(invoker.r_text, root_build_dir), ] } } if (is_apk) { if (defined(invoker.native_libs)) { inputs += invoker.native_libs rebased_native_libs = rebase_path(invoker.native_libs, root_build_dir) rebased_android_readelf = rebase_path(android_readelf, root_build_dir) args += [ "--native-libs=$rebased_native_libs", "--readelf-path=$rebased_android_readelf", ] } } if (defined(invoker.srcjar)) { args += [ "--srcjar", rebase_path(invoker.srcjar, root_build_dir), ] } } } template("process_java_prebuilt") { set_sources_assignment_filter([]) if (defined(invoker.testonly)) { testonly = invoker.testonly } _input_jar_path = invoker.input_jar_path _output_jar_path = invoker.output_jar_path _jar_toc_path = _output_jar_path + ".TOC" assert(invoker.build_config != "") if (defined(invoker.proguard_preprocess) && invoker.proguard_preprocess) { _proguard_jar_path = "$android_sdk_root/tools/proguard/lib/proguard.jar" _proguard_config_path = invoker.proguard_config _build_config = invoker.build_config _rebased_build_config = rebase_path(_build_config, root_build_dir) action("${target_name}__proguard_process") { script = "//build/android/gyp/proguard.py" inputs = [ android_sdk_jar, _proguard_jar_path, _build_config, _input_jar_path, _proguard_config_path, ] depfile = "${target_gen_dir}/${target_name}.d" outputs = [ depfile, _output_jar_path, ] args = [ "--depfile", rebase_path(depfile, root_build_dir), "--proguard-path", rebase_path(_proguard_jar_path, root_build_dir), "--input-path", rebase_path(_input_jar_path, root_build_dir), "--output-path", rebase_path(_output_jar_path, root_build_dir), "--proguard-config", rebase_path(_proguard_config_path, root_build_dir), "--classpath", rebased_android_sdk_jar, "--classpath=@FileArg($_rebased_build_config:javac:classpath)", ] } } else { copy("${target_name}__copy_jar") { sources = [ _input_jar_path, ] outputs = [ _output_jar_path, ] } } action("${target_name}__jar_toc") { script = "//build/android/gyp/jar_toc.py" depfile = "$target_gen_dir/$target_name.d" outputs = [ depfile, _jar_toc_path, _jar_toc_path + ".md5.stamp", ] inputs = [ _output_jar_path, ] args = [ "--depfile", rebase_path(depfile, root_build_dir), "--jar-path", rebase_path(_output_jar_path, root_build_dir), "--toc-path", rebase_path(_jar_toc_path, root_build_dir), ] } group(target_name) { deps = [ ":${target_name}__jar_toc", ] } } # Packages resources, assets, dex, and native libraries into an apk. Signs and # zipaligns the apk. template("create_apk") { set_sources_assignment_filter([]) if (defined(invoker.testonly)) { testonly = invoker.testonly } _android_manifest = invoker.android_manifest _base_path = invoker.base_path _final_apk_path = invoker.apk_path if (defined(invoker.resources_zip)) { _resources_zip = invoker.resources_zip } if (defined(invoker.dex_path)) { _dex_path = invoker.dex_path } _keystore_path = invoker.keystore_path _keystore_name = invoker.keystore_name _keystore_password = invoker.keystore_password _load_library_from_apk = invoker.load_library_from_apk _deps = [] if (defined(invoker.deps)) { _deps = invoker.deps } _native_libs_dir = "//build/android/empty/res" if (defined(invoker.native_libs_dir)) { _native_libs_dir = invoker.native_libs_dir } if (defined(invoker.asset_location)) { _asset_location = invoker.asset_location } _version_code = invoker.version_code _version_name = invoker.version_name _base_apk_path = _base_path + ".apk_intermediates" _resource_packaged_apk_path = _base_apk_path + ".ap_" _packaged_apk_path = _base_apk_path + ".unfinished.apk" _shared_resources = defined(invoker.shared_resources) && invoker.shared_resources _configuration_name = "Release" if (is_debug) { _configuration_name = "Debug" } action("${target_name}__package_resources") { deps = _deps script = "//build/android/gyp/package_resources.py" depfile = "${target_gen_dir}/${target_name}.d" inputs = [ _android_manifest, ] if (defined(_resources_zip)) { inputs += [ _resources_zip ] } outputs = [ depfile, _resource_packaged_apk_path, ] args = [ "--depfile", rebase_path(depfile, root_build_dir), "--android-sdk", rebased_android_sdk, "--android-sdk-tools", rebased_android_sdk_build_tools, "--configuration-name=$_configuration_name", "--android-manifest", rebase_path(_android_manifest, root_build_dir), "--version-code", _version_code, "--version-name", _version_name, "--apk-path", rebase_path(_resource_packaged_apk_path, root_build_dir), ] if (defined(_asset_location)) { args += [ "--asset-dir", rebase_path(_asset_location, root_build_dir), ] } if (defined(_resources_zip)) { args += [ "--resource-zips", rebase_path(_resources_zip, root_build_dir), ] } if (_shared_resources) { args += [ "--shared-resources" ] } } action("${target_name}__package") { script = "//build/android/gyp/ant.py" _ant_script = "//build/android/ant/apk-package.xml" depfile = "$target_gen_dir/$target_name.d" inputs = [ _resource_packaged_apk_path, _ant_script, ] if (defined(_dex_path)) { inputs += [ _dex_path ] } outputs = [ depfile, _packaged_apk_path, ] _rebased_emma_jar = "" _rebased_resource_packaged_apk_path = rebase_path(_resource_packaged_apk_path, root_build_dir) _rebased_packaged_apk_path = rebase_path(_packaged_apk_path, root_build_dir) _rebased_native_libs_dir = rebase_path(_native_libs_dir, root_build_dir) args = [ "--depfile", rebase_path(depfile, root_build_dir), "--", "-quiet", "-DANDROID_SDK_ROOT=$rebased_android_sdk_root", "-DANDROID_SDK_TOOLS=$rebased_android_sdk_build_tools", "-DRESOURCE_PACKAGED_APK_NAME=$_rebased_resource_packaged_apk_path", "-DCONFIGURATION_NAME=$_configuration_name", "-DNATIVE_LIBS_DIR=$_rebased_native_libs_dir", "-DOUT_DIR=", "-DUNSIGNED_APK_PATH=$_rebased_packaged_apk_path", "-DEMMA_INSTRUMENT=0", "-DEMMA_DEVICE_JAR=$_rebased_emma_jar", "-Dbasedir=.", "-buildfile", rebase_path(_ant_script, root_build_dir), ] if (defined(_dex_path)) { _rebased_dex_path = rebase_path(_dex_path, root_build_dir) args += [ "-DDEX_FILE_PATH=$_rebased_dex_path", "-DHAS_CODE=true", ] } else { args += [ "-DHAS_CODE=false" ] } } action("${target_name}__finalize") { script = "//build/android/gyp/finalize_apk.py" depfile = "$target_gen_dir/$target_name.d" sources = [ _packaged_apk_path, ] inputs = [ _keystore_path, ] outputs = [ depfile, _final_apk_path, ] args = [ "--depfile", rebase_path(depfile, root_build_dir), "--zipalign-path", rebase_path(zipalign_path, root_build_dir), "--unsigned-apk-path", rebase_path(_packaged_apk_path, root_build_dir), "--final-apk-path", rebase_path(_final_apk_path, root_build_dir), "--key-path", rebase_path(_keystore_path, root_build_dir), "--key-name", _keystore_name, "--key-passwd", _keystore_password, ] if (_load_library_from_apk) { _rezip_jar_path = "$root_build_dir/lib.java/rezip_apk.jar" inputs += [ _rezip_jar_path ] args += [ "--load-library-from-zip-file=1", "--rezip-apk-jar-path", rebase_path(_rezip_jar_path, root_build_dir), ] } } group(target_name) { deps = [ ":${target_name}__finalize", ":${target_name}__package_resources", ] } } template("java_prebuilt_impl") { set_sources_assignment_filter([]) if (defined(invoker.testonly)) { testonly = invoker.testonly } _supports_android = defined(invoker.supports_android) && invoker.supports_android assert(defined(invoker.jar_path)) _base_path = "${target_gen_dir}/$target_name" _jar_path = _base_path + ".jar" _build_config = _base_path + ".build_config" if (_supports_android) { _dex_path = _base_path + ".dex.jar" } _final_deps = [] _template_name = target_name _final_deps += [ ":${_template_name}__build_config" ] write_build_config("${_template_name}__build_config") { type = "java_library" supports_android = _supports_android requires_android = defined(invoker.requires_android) && invoker.requires_android deps = [] if (defined(invoker.deps)) { deps += invoker.deps } build_config = _build_config jar_path = _jar_path if (_supports_android) { dex_path = _dex_path } } _final_deps += [ ":${_template_name}__process_jar" ] process_java_prebuilt("${_template_name}__process_jar") { if (defined(invoker.proguard_preprocess) && invoker.proguard_preprocess) { proguard_preprocess = true proguard_config = invoker.proguard_config } build_config = _build_config input_jar_path = invoker.jar_path output_jar_path = _jar_path } if (_supports_android) { _final_deps += [ ":${_template_name}__dex" ] dex("${_template_name}__dex") { sources = [ _jar_path, ] output = _dex_path } } group(target_name) { deps = _final_deps } } # Compiles and jars a set of java files. # # Outputs: # $jar_path.jar # $jar_path.jar.TOC # # Variables # java_files: List of .java files to compile. # java_deps: List of java dependencies. These should all have a .jar output # at "${target_gen_dir}/${target_name}.jar. # chromium_code: If true, enable extra warnings. # srcjar_deps: List of srcjar dependencies. The .java files contained in the # dependencies srcjar outputs will be compiled and added to the output jar. # jar_path: Use this to explicitly set the output jar path. Defaults to # "${target_gen_dir}/${target_name}.jar. template("compile_java") { set_sources_assignment_filter([]) if (defined(invoker.testonly)) { testonly = invoker.testonly } assert(defined(invoker.java_files)) assert(defined(invoker.build_config)) assert(defined(invoker.jar_path)) _java_files = invoker.java_files _final_jar_path = invoker.jar_path _intermediate_jar_path = "$target_gen_dir/$target_name.initial.jar" _build_config = invoker.build_config _jar_excluded_patterns = [] if (defined(invoker.jar_excluded_patterns)) { _jar_excluded_patterns += invoker.jar_excluded_patterns } _chromium_code = false if (defined(invoker.chromium_code)) { _chromium_code = invoker.chromium_code } _manifest_entries = [] if (defined(invoker.manifest_entries)) { _manifest_entries = invoker.manifest_entries } _srcjar_deps = [] if (defined(invoker.srcjar_deps)) { _srcjar_deps += invoker.srcjar_deps } _java_srcjars = [] if (defined(invoker.srcjars)) { _java_srcjars = invoker.srcjars } foreach(dep, _srcjar_deps) { _dep_gen_dir = get_label_info(dep, "target_gen_dir") _dep_name = get_label_info(dep, "name") _java_srcjars += [ "$_dep_gen_dir/$_dep_name.srcjar" ] } # Mark srcjar_deps as used. assert(_srcjar_deps == [] || true) _system_jars = [] if (defined(invoker.android) && invoker.android) { _system_jars += [ android_sdk_jar ] } _rebased_build_config = rebase_path(_build_config, root_build_dir) _rebased_jar_path = rebase_path(_intermediate_jar_path, root_build_dir) _template_name = target_name _final_deps = [ ":${_template_name}__javac" ] action("${_template_name}__javac") { script = "//build/android/gyp/javac.py" depfile = "$target_gen_dir/$target_name.d" deps = [] outputs = [ depfile, _intermediate_jar_path, _intermediate_jar_path + ".md5.stamp", ] sources = _java_files + _java_srcjars inputs = _system_jars + [ _build_config ] _rebased_system_jars = rebase_path(_system_jars, root_build_dir) _rebased_java_srcjars = rebase_path(_java_srcjars, root_build_dir) _rebased_depfile = rebase_path(depfile, root_build_dir) args = [ "--depfile=$_rebased_depfile", "--classpath=$_rebased_system_jars", "--classpath=@FileArg($_rebased_build_config:javac:classpath)", "--jar-path=$_rebased_jar_path", "--java-srcjars=$_rebased_java_srcjars", "--java-srcjars=@FileArg($_rebased_build_config:javac:srcjars)", "--jar-excluded-classes=$_jar_excluded_patterns", ] foreach(e, _manifest_entries) { args += [ "--manifest-entry=" + e ] } if (_chromium_code) { args += [ "--chromium-code=1" ] } args += rebase_path(_java_files, root_build_dir) } _final_deps += [ ":${_template_name}__finish" ] process_java_prebuilt("${_template_name}__finish") { build_config = _build_config input_jar_path = _intermediate_jar_path output_jar_path = _final_jar_path if (defined(invoker.proguard_preprocess) && invoker.proguard_preprocess) { proguard_preprocess = invoker.proguard_preprocess proguard_config = invoker.proguard_config } } group(target_name) { deps = _final_deps } } template("java_library_impl") { set_sources_assignment_filter([]) if (defined(invoker.testonly)) { testonly = invoker.testonly } assert( defined(invoker.java_files) || defined(invoker.DEPRECATED_java_in_dir) || defined(invoker.srcjars) || defined(invoker.srcjar_deps)) _base_path = "$target_gen_dir/$target_name" _jar_path = _base_path + ".jar" if (defined(invoker.jar_path)) { _jar_path = invoker.jar_path } _template_name = target_name _final_deps = [] _final_datadeps = [] if (defined(invoker.datadeps)) { _final_datadeps = invoker.datadeps } _supports_android = defined(invoker.supports_android) && invoker.supports_android _requires_android = defined(invoker.requires_android) && invoker.requires_android if (_supports_android) { _dex_path = _base_path + ".dex.jar" if (defined(invoker.dex_path)) { _dex_path = invoker.dex_path } } if (defined(invoker.override_build_config)) { _build_config = invoker.override_build_config } else { _build_config = _base_path + ".build_config" _final_deps += [ ":${_template_name}__build_config" ] write_build_config("${_template_name}__build_config") { type = "java_library" supports_android = _supports_android requires_android = _requires_android bypass_platform_checks = defined(invoker.bypass_platform_checks) && invoker.bypass_platform_checks deps = [] if (defined(invoker.deps)) { deps += invoker.deps } build_config = _build_config jar_path = _jar_path if (_supports_android) { dex_path = _dex_path } } } _chromium_code = true if (defined(invoker.chromium_code)) { _chromium_code = invoker.chromium_code } _srcjar_deps = [] if (defined(invoker.srcjar_deps)) { _srcjar_deps = invoker.srcjar_deps } _srcjars = [] if (defined(invoker.srcjars)) { _srcjars = invoker.srcjars } _java_files = [] if (defined(invoker.java_files)) { _java_files = invoker.java_files } else if (defined(invoker.DEPRECATED_java_in_dir)) { _src_dir = invoker.DEPRECATED_java_in_dir + "/src" _src_dir_exists = exec_script("//build/dir_exists.py", [ rebase_path(_src_dir, root_build_dir) ], "string") assert(_src_dir_exists == "False", "In GN, java_in_dir should be the fully specified java directory " + "(i.e. including the trailing \"/src\")") _java_files_build_rel = exec_script( "//build/android/gyp/find.py", [ "--pattern", "*.java", rebase_path(invoker.DEPRECATED_java_in_dir, root_build_dir), ], "list lines") _java_files = rebase_path(_java_files_build_rel, ".", root_build_dir) } assert(_java_files != [] || _srcjar_deps != [] || _srcjars != []) _final_deps += [ ":${_template_name}__compile_java" ] compile_java("${_template_name}__compile_java") { jar_path = _jar_path build_config = _build_config java_files = _java_files srcjar_deps = _srcjar_deps srcjars = _srcjars chromium_code = _chromium_code android = _requires_android if (defined(invoker.jar_excluded_patterns)) { jar_excluded_patterns = invoker.jar_excluded_patterns } if (defined(invoker.proguard_preprocess)) { proguard_preprocess = invoker.proguard_preprocess } if (defined(invoker.proguard_config)) { proguard_config = invoker.proguard_config } if (defined(invoker.dist_jar_path)) { dist_jar_path = invoker.dist_jar_path } if (defined(invoker.manifest_entries)) { manifest_entries = invoker.manifest_entries } } if (defined(invoker.main_class)) { _final_deps += [ ":${_template_name}__binary_script" ] action("${_template_name}__binary_script") { script = "//build/android/gyp/create_java_binary_script.py" depfile = "$target_gen_dir/$target_name.d" java_script = "$root_build_dir/bin/$_template_name" inputs = [ _build_config, ] outputs = [ depfile, java_script, ] _rebased_build_config = rebase_path(_build_config, root_build_dir) args = [ "--depfile", rebase_path(depfile, root_build_dir), "--output", rebase_path(java_script, root_build_dir), "--classpath=@FileArg($_rebased_build_config:java:full_classpath)", "--jar-path", rebase_path(_jar_path, root_build_dir), "--main-class", invoker.main_class, ] } } if (_supports_android) { if (defined(invoker.chromium_code) && invoker.chromium_code) { _android_manifest = "//build/android/AndroidManifest.xml" if (defined(invoker.android_manifest)) { _android_manifest = invoker.android_manifest } _final_datadeps += [ ":${_template_name}__lint" ] android_lint("${_template_name}__lint") { android_manifest = _android_manifest jar_path = _jar_path java_files = _java_files } if (run_findbugs) { _final_datadeps += [ ":${_template_name}__findbugs" ] findbugs("${_template_name}__findbugs") { build_config = _build_config jar_path = _jar_path } } } _final_deps += [ ":${_template_name}__dex" ] dex("${_template_name}__dex") { sources = [ _jar_path, ] output = _dex_path } } group(target_name) { if (defined(invoker.visibility)) { visibility = invoker.visibility } deps = _final_deps datadeps = _final_datadeps } } # Runs process_resources.py template("process_resources") { set_sources_assignment_filter([]) if (defined(invoker.testonly)) { testonly = invoker.testonly } zip_path = invoker.zip_path srcjar_path = invoker.srcjar_path r_text_path = invoker.r_text_path build_config = invoker.build_config resource_dirs = invoker.resource_dirs android_manifest = invoker.android_manifest non_constant_id = true if (defined(invoker.generate_constant_ids) && invoker.generate_constant_ids) { non_constant_id = false } action(target_name) { script = "//build/android/gyp/process_resources.py" depfile = "$target_gen_dir/$target_name.d" outputs = [ depfile, zip_path, srcjar_path, r_text_path, ] sources_build_rel = exec_script("//build/android/gyp/find.py", rebase_path(resource_dirs, root_build_dir), "list lines") sources = rebase_path(sources_build_rel, ".", root_build_dir) inputs = [ build_config, android_manifest, ] rebase_resource_dirs = rebase_path(resource_dirs, root_build_dir) rebase_build_config = rebase_path(build_config, root_build_dir) args = [ "--depfile", rebase_path(depfile, root_build_dir), "--android-sdk", rebase_path(android_sdk, root_build_dir), "--android-sdk-tools", rebase_path(android_sdk_build_tools, root_build_dir), "--android-manifest", rebase_path(android_manifest, root_build_dir), "--resource-dirs=$rebase_resource_dirs", "--srcjar-out", rebase_path(srcjar_path, root_build_dir), "--resource-zip-out", rebase_path(zip_path, root_build_dir), "--r-text-out", rebase_path(r_text_path, root_build_dir), "--dependencies-res-zips=@FileArg($rebase_build_config:resources:dependency_zips)", "--extra-res-packages=@FileArg($rebase_build_config:resources:extra_package_names)", "--extra-r-text-files=@FileArg($rebase_build_config:resources:extra_r_text_files)", ] if (non_constant_id) { args += [ "--non-constant-id" ] } if (defined(invoker.custom_package)) { args += [ "--custom-package", invoker.custom_package, ] } if (defined(invoker.v14_verify_only) && invoker.v14_verify_only) { args += [ "--v14-verify-only" ] } if (defined(invoker.v14_skip) && invoker.v14_skip) { args += [ "--v14-skip" ] } if (defined(invoker.shared_resources) && invoker.shared_resources) { args += [ "--shared-resources" ] } if (defined(invoker.include_all_resources) && invoker.include_all_resources) { args += [ "--include-all-resources" ] } if (defined(invoker.all_resources_zip_path)) { all_resources_zip = invoker.all_resources_zip_path outputs += [ all_resources_zip ] args += [ "--all-resources-zip-out", rebase_path(all_resources_zip, root_build_dir), ] } if (defined(invoker.args)) { args += invoker.args } } } template("copy_ex") { set_sources_assignment_filter([]) if (defined(invoker.testonly)) { testonly = invoker.testonly } action(target_name) { script = "//build/android/gyp/copy_ex.py" if (defined(invoker.deps)) { deps = invoker.deps } sources = [] if (defined(invoker.sources)) { sources += invoker.sources } inputs = [] if (defined(invoker.inputs)) { inputs += invoker.inputs } depfile = "$target_gen_dir/$target_name.d" outputs = [ depfile, ] args = [ "--depfile", rebase_path(depfile, root_build_dir), "--dest", rebase_path(invoker.dest, root_build_dir), ] rebased_sources = rebase_path(sources, root_build_dir) args += [ "--files=$rebased_sources" ] if (defined(invoker.clear_dir) && invoker.clear_dir) { args += [ "--clear" ] } if (defined(invoker.args)) { args += invoker.args } } } # Produces a single .dex.jar out of a set of Java dependencies. template("deps_dex") { set_sources_assignment_filter([]) build_config = "$target_gen_dir/${target_name}.build_config" write_build_config("${target_name}__build_config") { type = "deps_dex" deps = invoker.deps build_config = build_config dex_path = invoker.dex_path } rebased_build_config = rebase_path(build_config, root_build_dir) dex(target_name) { inputs = [ build_config, ] output = invoker.dex_path dex_arg_key = "${rebased_build_config}:final_dex:dependency_dex_files" args = [ "--inputs=@FileArg($dex_arg_key)" ] if (defined(invoker.excluded_jars)) { excluded_jars = rebase_path(invoker.excluded_jars, root_build_dir) args += [ "--excluded-paths=${excluded_jars}" ] } } } # Creates an AndroidManifest.xml for an APK split. template("generate_split_manifest") { assert(defined(invoker.main_manifest)) assert(defined(invoker.out_manifest)) assert(defined(invoker.split_name)) action(target_name) { depfile = "$target_gen_dir/$target_name.d" args = [ "--main-manifest", rebase_path(invoker.main_manifest, root_build_dir), "--out-manifest", rebase_path(invoker.out_manifest, root_build_dir), "--split", invoker.split_name, ] if (defined(invoker.version_code)) { args += [ "--version-code", invoker.version_code, ] } if (defined(invoker.version_name)) { args += [ "--version-name", invoker.version_name, ] } if (defined(invoker.has_code)) { args += [ "--has-code", invoker.has_code, ] } args += [ "--depfile", rebase_path(depfile, root_build_dir), ] script = "//build/android/gyp/generate_split_manifest.py" outputs = [ depfile, invoker.out_manifest, ] inputs = [ invoker.main_manifest, ] } }