diff options
author | jbudorick <jbudorick@chromium.org> | 2015-11-20 15:19:23 -0800 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2015-11-20 23:20:33 +0000 |
commit | e6361975d7f7f4c434dc3380a3824b9d5e323d20 (patch) | |
tree | 0a766eb528cd92153006c1d0dce7bc696beb35bb /build/config/android | |
parent | ce62351f189643118e9d09bf06e128b75345ef36 (diff) | |
download | chromium_src-e6361975d7f7f4c434dc3380a3824b9d5e323d20.zip chromium_src-e6361975d7f7f4c434dc3380a3824b9d5e323d20.tar.gz chromium_src-e6361975d7f7f4c434dc3380a3824b9d5e323d20.tar.bz2 |
[Android] Add gn support for multidex.
BUG=272790
Review URL: https://codereview.chromium.org/1451483002
Cr-Commit-Position: refs/heads/master@{#360943}
Diffstat (limited to 'build/config/android')
-rw-r--r-- | build/config/android/internal_rules.gni | 55 | ||||
-rw-r--r-- | build/config/android/rules.gni | 20 |
2 files changed, 72 insertions, 3 deletions
diff --git a/build/config/android/internal_rules.gni b/build/config/android/internal_rules.gni index f676010..3d91676 100644 --- a/build/config/android/internal_rules.gni +++ b/build/config/android/internal_rules.gni @@ -223,6 +223,51 @@ template("java_binary_script") { template("dex") { set_sources_assignment_filter([]) + _enable_multidex = defined(invoker.enable_multidex) && invoker.enable_multidex + + if (_enable_multidex) { + _main_dex_list_path = invoker.output + ".main_dex_list" + _main_dex_list_target_name = "${target_name}__main_dex_list" + action(_main_dex_list_target_name) { + forward_variables_from(invoker, + [ + "deps", + "inputs", + "sources", + "testonly", + ]) + + script = "//build/android/gyp/main_dex_list.py" + depfile = "$target_gen_dir/$target_name.d" + + main_dex_rules = "//build/android/main_dex_classes.flags" + + outputs = [ + depfile, + _main_dex_list_path, + ] + + args = [ + "--depfile", + rebase_path(depfile, root_build_dir), + "--android-sdk-tools", + rebased_android_sdk_build_tools, + "--main-dex-list-path", + rebase_path(_main_dex_list_path, root_build_dir), + "--main-dex-rules-path", + rebase_path(main_dex_rules, root_build_dir), + ] + + if (defined(invoker.args)) { + args += invoker.args + } + + if (defined(invoker.sources)) { + args += rebase_path(invoker.sources, root_build_dir) + } + } + } + assert(defined(invoker.output)) action(target_name) { forward_variables_from(invoker, @@ -258,6 +303,16 @@ template("dex") { args += [ "--no-locals=1" ] } + if (_enable_multidex) { + args += [ + "--multi-dex", + "--main-dex-list-path", + rebase_path(_main_dex_list_path, root_build_dir), + ] + deps += [ ":${_main_dex_list_target_name}" ] + inputs += [ _main_dex_list_path ] + } + if (defined(invoker.args)) { args += invoker.args } diff --git a/build/config/android/rules.gni b/build/config/android/rules.gni index 95e1303..e656070 100644 --- a/build/config/android/rules.gni +++ b/build/config/android/rules.gni @@ -1240,7 +1240,12 @@ template("android_apk") { _rebased_lib_dex_path = rebase_path(_lib_dex_path, root_build_dir) _template_name = target_name - final_dex_path = "$gen_dir/classes.dex" + enable_multidex = defined(invoker.enable_multidex) && invoker.enable_multidex + if (enable_multidex) { + final_dex_path = "$gen_dir/classes.dex.zip" + } else { + final_dex_path = "$gen_dir/classes.dex" + } final_dex_target_name = "${_template_name}__final_dex" _final_apk_path = "" @@ -1552,18 +1557,27 @@ template("android_apk") { _dex_sources = [ _proguard_jar_path ] _dex_deps = [ ":$_proguard_target" ] } else { - _dex_sources = [ _lib_dex_path ] + if (enable_multidex) { + _dex_sources = [ _jar_path ] + } else { + _dex_sources = [ _lib_dex_path ] + } _dex_deps = [ ":$java_target" ] } dex("$final_dex_target_name") { + forward_variables_from(invoker, [ "enable_multidex" ]) deps = _dex_deps + [ ":$build_config_target" ] inputs = [ _build_config, ] sources = _dex_sources output = final_dex_path - _dex_arg_key = "${_rebased_build_config}:final_dex:dependency_dex_files" + if (enable_multidex) { + _dex_arg_key = "${_rebased_build_config}:dist_jar:dependency_jars" + } else { + _dex_arg_key = "${_rebased_build_config}:final_dex:dependency_dex_files" + } args = [ "--inputs=@FileArg($_dex_arg_key)" ] if (emma_coverage && !_emma_never_instrument) { |