Chromium Code Reviews| Index: build/config/android/internal_rules.gni |
| diff --git a/build/config/android/internal_rules.gni b/build/config/android/internal_rules.gni |
| index de29cce90a3bdb1bfd1e732c21da9aa356f7bbe9..d34644b13102ef04e16141cf90a0788040fd5fc8 100644 |
| --- a/build/config/android/internal_rules.gni |
| +++ b/build/config/android/internal_rules.gni |
| @@ -55,6 +55,47 @@ template("android_lint") { |
| } |
| +template("dex") { |
| + if (defined(invoker.testonly)) { testonly = invoker.testonly } |
| + |
| + assert(defined(invoker.sources)) |
| + assert(defined(invoker.output)) |
| + action(target_name) { |
| + script = "//build/android/gyp/dex.py" |
| + depfile = "$target_gen_dir/$target_name.d" |
| + 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 |
| + } |
| + |
| + args += rebase_path(invoker.sources, 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 |
| @@ -73,7 +114,7 @@ template("write_build_config") { |
| type = invoker.type |
| build_config = invoker.build_config |
| - assert(type == "android_apk" || type == "android_library" || type == "android_resources") |
| + assert(type == "android_apk" || type == "java_library" || type == "android_resources") |
| action(target_name) { |
| script = "//build/android/gyp/write_build_config.py" |
| @@ -105,14 +146,42 @@ template("write_build_config") { |
| "--build-config", rebase_path(build_config, root_build_dir), |
| ] |
| - if (type == "android_library" || type == "android_apk") { |
| + is_java_library = type == "java_library" |
| + is_apk = type == "android_apk" |
| + is_android_resources = type == "android_resources" |
| + |
| + supports_android = (is_apk || is_android_resources || |
| + (is_java_library && defined(invoker.supports_android) && |
| + invoker.supports_android)) |
| + requires_android = (is_apk || is_android_resources || |
| + (is_java_library && defined(invoker.requires_android) && |
| + invoker.requires_android)) |
| + |
| + assert(!requires_android || supports_android, "requires_android requires" + |
| + " supports_android") |
| + assert(is_java_library || true) |
|
newt (away)
2014/11/03 22:12:44
why this assert?
cjhopman
2014/11/15 03:37:59
Added comment about why.
|
| + assert(is_apk || true) |
| + assert(is_android_resources || true) |
| + |
| + if (is_java_library || is_apk) { |
| args += [ |
| "--jar-path", rebase_path(invoker.jar_path, root_build_dir), |
| + ] |
| + } |
| + |
| + if (is_apk || (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 (type == "android_resources" || type == "android_apk") { |
| + if (is_android_resources || is_apk) { |
| assert(defined(invoker.resources_zip)) |
| args += [ |
| "--resources-zip", rebase_path(invoker.resources_zip, root_build_dir), |
| @@ -132,7 +201,7 @@ template("write_build_config") { |
| } |
| } |
| - if (type == "android_apk") { |
| + if (is_apk) { |
| if (defined(invoker.native_libs)) { |
| rebased_native_libs = rebase_path(invoker.native_libs, root_build_dir) |
| rebased_android_readelf = rebase_path(android_readelf, root_build_dir) |
| @@ -152,229 +221,7 @@ template("write_build_config") { |
| } |
| -# Creates a zip archive of the inputs. |
| -# If base_dir is provided, the archive paths will be relative to it. |
| -template("zip") { |
| - 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) |
| - ] |
| - } |
| - } |
| -} |
| - |
| -template("dex") { |
| - if (defined(invoker.testonly)) { testonly = invoker.testonly } |
| - |
| - assert(defined(invoker.sources)) |
| - assert(defined(invoker.output)) |
| - action(target_name) { |
| - script = "//build/android/gyp/dex.py" |
| - depfile = "$target_gen_dir/$target_name.d" |
| - 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 |
| - } |
| - |
| - args += rebase_path(invoker.sources, root_build_dir) |
| - } |
| -} |
| - |
| -# Packages resources, assets, dex, and native libraries into an apk. Signs and |
| -# zipaligns the apk. |
| -template("create_apk") { |
| - if (defined(invoker.testonly)) { testonly = invoker.testonly } |
| - |
| - _android_manifest = invoker.android_manifest |
| - _base_path = invoker.base_path |
| - _final_apk_path = invoker.apk_path |
| - _resources_zip = invoker.resources_zip |
| - _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 |
| - } |
| - |
| - _asset_location = "//build/android/empty/res" |
| - 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" |
| - |
| - |
| - _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, |
| - _resources_zip, |
| - ] |
| - outputs = [depfile, _resource_packaged_apk_path] |
| - |
| - _rebased_resources_zips = [rebase_path(_resources_zip, root_build_dir)] |
| - 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, |
| - |
| - "--asset-dir", rebase_path(_asset_location, root_build_dir), |
| - "--resource-zips=$_rebased_resources_zips", |
| - |
| - "--apk-path", rebase_path(_resource_packaged_apk_path, root_build_dir), |
| - ] |
| - } |
| - |
| - 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 = [ |
| - _dex_path, |
| - _resource_packaged_apk_path, |
| - _ant_script |
| - ] |
| - |
| - 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) |
| - _rebased_dex_path = rebase_path(_dex_path, 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", |
| - "-DDEX_FILE_PATH=$_rebased_dex_path", |
| - |
| - "-Dbasedir=.", |
| - "-buildfile", rebase_path(_ant_script, root_build_dir) |
| - ] |
| - } |
| - |
| - 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"] |
| - } |
| -} |
| - |
| -template("java_prebuilt") { |
| +template("process_java_prebuilt") { |
| if (defined(invoker.testonly)) { testonly = invoker.testonly } |
| _input_jar_path = invoker.input_jar_path |
| @@ -436,12 +283,75 @@ template("java_prebuilt") { |
| } |
| group(target_name) { |
| - deps = [ |
| - ":${target_name}__jar_toc" |
| - ] |
| + deps = [ |
| + ":${target_name}__jar_toc" |
| + ] |
| + } |
| +} |
| + |
| + |
| +template("java_prebuilt_impl") { |
| + 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: |
| @@ -497,10 +407,20 @@ template("compile_java") { |
| # Mark srcjar_deps as used. |
| assert(_srcjar_deps == [] || true) |
| - _system_jars = [ android_sdk_jar ] |
| - action("${target_name}__javac") { |
| + _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, |
| @@ -511,9 +431,7 @@ template("compile_java") { |
| _rebased_system_jars = rebase_path(_system_jars, root_build_dir) |
| _rebased_java_srcjars = rebase_path(_java_srcjars, root_build_dir) |
| - _rebased_build_config = rebase_path(_build_config, root_build_dir) |
| _rebased_depfile = rebase_path(depfile, root_build_dir) |
| - _rebased_jar_path = rebase_path(_intermediate_jar_path, root_build_dir) |
| args = [ |
| "--depfile=$_rebased_depfile", |
| "--classpath=$_rebased_system_jars", |
| @@ -524,13 +442,20 @@ template("compile_java") { |
| "--jar-excluded-classes=$_jar_excluded_patterns", |
| ] |
| if (_chromium_code) { |
| - args += [ "--chromium-code" ] |
| + args += [ "--chromium-code=1" ] |
| + } |
| + |
| + if (defined(invoker.main_class)) { |
| + args += [ |
| + "--main-class", invoker.main_class |
| + ] |
| } |
| args += rebase_path(_java_files, root_build_dir) |
| } |
| - java_prebuilt("${target_name}__finish") { |
| + _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 |
| @@ -541,26 +466,68 @@ template("compile_java") { |
| } |
| group(target_name) { |
| - deps = [ |
| - ":${target_name}__javac", |
| - ":${target_name}__finish", |
| - ] |
| + deps = _final_deps |
| } |
| } |
| -# This adds Android-specific parts to the java_library template. |
| -# |
| -# Runs Android lint against the compiled java files. |
| -# Dexes the output jar for inclusion in an APK. |
| -template("android_java_library") { |
| +template("java_library_impl") { |
| 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)) |
| - assert(defined(invoker.build_config)) |
| - assert(defined(invoker.jar_path)) |
| - assert(defined(invoker.dex_path)) |
| + _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 |
| + |
| + 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)) { |
| @@ -597,57 +564,252 @@ template("android_java_library") { |
| } |
| assert(_java_files != [] || _srcjar_deps != [] || _srcjars != []) |
| - _jar_path = invoker.jar_path |
| - _dex_path = invoker.dex_path |
| - |
| - _android_manifest = "//build/android/AndroidManifest.xml" |
| - if (defined(invoker.android_manifest)) { |
| - _android_manifest = invoker.android_manifest |
| - } |
| - assert(_android_manifest != "") |
| - |
| - _final_deps = [] |
| - _final_datadeps = [] |
| - |
| - compile_java("${target_name}__compile_java") { |
| + _final_deps += [ ":${_template_name}__compile_java" ] |
| + compile_java("${_template_name}__compile_java") { |
| jar_path = _jar_path |
| - if (defined(invoker.jar_excluded_patterns)) { |
| - jar_excluded_patterns = invoker.jar_excluded_patterns |
| - } |
| - build_config = invoker.build_config |
| + 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.main_class)) { main_class = invoker.main_class } |
| + 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.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 (defined(invoker.proguard_preprocess) && invoker.proguard_preprocess) { |
| - proguard_preprocess = invoker.proguard_preprocess |
| - proguard_config = invoker.proguard_config |
| + if (_requires_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 (defined(invoker.dist_jar_path)) { |
| - dist_jar_path = invoker.dist_jar_path |
| + _final_deps += [ ":${_template_name}__dex" ] |
| + dex("${_template_name}__dex") { |
|
newt (away)
2014/11/03 22:12:45
shouldn't we also run dex when supports_android is
cjhopman
2014/11/15 03:37:59
Done.
|
| + sources = [_jar_path] |
| + output = _dex_path |
| } |
| } |
| - if (defined(invoker.chromium_code) && invoker.chromium_code) { |
| - _final_datadeps += [ ":${target_name}__lint" ] |
| - android_lint("${target_name}__lint") { |
| - android_manifest = _android_manifest |
| - jar_path = _jar_path |
| - java_files = _java_files |
| + group(target_name) { |
| + deps = _final_deps |
| + datadeps = _final_datadeps |
| + } |
| +} |
| + |
| +# Creates a zip archive of the inputs. |
| +# If base_dir is provided, the archive paths will be relative to it. |
| +template("zip") { |
| + 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) |
| + ] |
| } |
| } |
| +} |
| + |
| +# Packages resources, assets, dex, and native libraries into an apk. Signs and |
| +# zipaligns the apk. |
| +template("create_apk") { |
| + if (defined(invoker.testonly)) { testonly = invoker.testonly } |
| + |
| + _android_manifest = invoker.android_manifest |
| + _base_path = invoker.base_path |
| + _final_apk_path = invoker.apk_path |
| + _resources_zip = invoker.resources_zip |
| + _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 |
| + } |
| + |
| + _asset_location = "//build/android/empty/res" |
| + 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" |
| + |
| + |
| + _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, |
| + _resources_zip, |
| + ] |
| + outputs = [depfile, _resource_packaged_apk_path] |
| + |
| + _rebased_resources_zips = [rebase_path(_resources_zip, root_build_dir)] |
| + 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, |
| + |
| + "--asset-dir", rebase_path(_asset_location, root_build_dir), |
| + "--resource-zips=$_rebased_resources_zips", |
| + |
| + "--apk-path", rebase_path(_resource_packaged_apk_path, root_build_dir), |
| + ] |
| + } |
| + |
| + 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 = [ |
| + _dex_path, |
| + _resource_packaged_apk_path, |
| + _ant_script |
| + ] |
| + |
| + 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) |
| + _rebased_dex_path = rebase_path(_dex_path, 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", |
| + "-DDEX_FILE_PATH=$_rebased_dex_path", |
| + |
| + "-Dbasedir=.", |
| + "-buildfile", rebase_path(_ant_script, root_build_dir) |
| + ] |
| + } |
| + |
| + 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] |
| - dex("${target_name}__dex") { |
| - sources = [_jar_path] |
| - output = _dex_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}__compile_java", |
| - ":${target_name}__dex", |
| - ] + _final_deps + _final_datadeps |
| + deps = [":${target_name}__finalize"] |
| } |
| } |