Commit e7e326d5 authored by Andrew Grieve's avatar Andrew Grieve Committed by Commit Bot

Android: Include current dex in dependency_dex_files

This is just a minor build rule simplification. Should not affect
anything.

Change-Id: If778e8c2ece6e223b492ed4f172ce138f3c4e357
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1845932
Commit-Queue: Andrew Grieve <agrieve@chromium.org>
Reviewed-by: default avatarPeter Wen <wnwen@chromium.org>
Cr-Commit-Position: refs/heads/master@{#703482}
parent 3346b22a
...@@ -348,9 +348,9 @@ that will be merged into the final `.jar` file for distribution. ...@@ -348,9 +348,9 @@ that will be merged into the final `.jar` file for distribution.
Path to the final classes.dex file (or classes.zip in case of multi-dex) Path to the final classes.dex file (or classes.zip in case of multi-dex)
for this APK. for this APK.
* `deps_info['final_dex']['dependency_dex_files']`: * `deps_info['final_dex']['all_dex_files']`:
The list of paths to all `deps_info['dex_path']` entries for all library The list of paths to all `deps_info['dex_path']` entries for all libraries
dependencies for this APK. that comprise this APK. Valid only for debug builds.
* `native['libraries']` * `native['libraries']`
List of native libraries for the primary ABI to be embedded in this APK. List of native libraries for the primary ABI to be embedded in this APK.
...@@ -1191,6 +1191,9 @@ def main(argv): ...@@ -1191,6 +1191,9 @@ def main(argv):
raise Exception('Not all deps support the Android platform: ' raise Exception('Not all deps support the Android platform: '
+ str(deps_not_support_android)) + str(deps_not_support_android))
if is_apk_or_module_target:
all_dex_files = [c['dex_path'] for c in all_library_deps]
if is_java_target: if is_java_target:
# Classpath values filled in below (after applying tested_apk_config). # Classpath values filled in below (after applying tested_apk_config).
config['javac'] = {} config['javac'] = {}
...@@ -1200,6 +1203,8 @@ def main(argv): ...@@ -1200,6 +1203,8 @@ def main(argv):
deps_info['interface_jar_path'] = options.interface_jar_path deps_info['interface_jar_path'] = options.interface_jar_path
if options.dex_path: if options.dex_path:
deps_info['dex_path'] = options.dex_path deps_info['dex_path'] = options.dex_path
if is_apk_or_module_target:
all_dex_files.append(options.dex_path)
if options.type == 'android_apk': if options.type == 'android_apk':
deps_info['apk_path'] = options.apk_path deps_info['apk_path'] = options.apk_path
deps_info['incremental_apk_path'] = options.incremental_apk_path deps_info['incremental_apk_path'] = options.incremental_apk_path
...@@ -1318,9 +1323,6 @@ def main(argv): ...@@ -1318,9 +1323,6 @@ def main(argv):
if options.res_size_info: if options.res_size_info:
config['deps_info']['res_size_info'] = options.res_size_info config['deps_info']['res_size_info'] = options.res_size_info
if is_apk_or_module_target:
deps_dex_files = [c['dex_path'] for c in all_library_deps]
if options.type == 'group': if options.type == 'group':
if options.extra_classpath_jars: if options.extra_classpath_jars:
# These are .jars to add to javac classpath but not to runtime classpath. # These are .jars to add to javac classpath but not to runtime classpath.
...@@ -1590,8 +1592,9 @@ def main(argv): ...@@ -1590,8 +1592,9 @@ def main(argv):
# within proguard.py. Move the logic for the proguard case to here. # within proguard.py. Move the logic for the proguard case to here.
tested_apk_library_deps = tested_apk_deps.All('java_library') tested_apk_library_deps = tested_apk_deps.All('java_library')
tested_apk_deps_dex_files = [c['dex_path'] for c in tested_apk_library_deps] tested_apk_deps_dex_files = [c['dex_path'] for c in tested_apk_library_deps]
deps_dex_files = [ all_dex_files = [
p for p in deps_dex_files if not p in tested_apk_deps_dex_files] p for p in all_dex_files if not p in tested_apk_deps_dex_files
]
if options.type in ('android_apk', 'dist_aar', 'dist_jar', if options.type in ('android_apk', 'dist_aar', 'dist_jar',
'android_app_bundle_module', 'android_app_bundle'): 'android_app_bundle_module', 'android_app_bundle'):
...@@ -1605,7 +1608,7 @@ def main(argv): ...@@ -1605,7 +1608,7 @@ def main(argv):
dex_config = config['final_dex'] dex_config = config['final_dex']
dex_config['path'] = options.final_dex_path dex_config['path'] = options.final_dex_path
if is_apk_or_module_target: if is_apk_or_module_target:
dex_config['dependency_dex_files'] = deps_dex_files dex_config['all_dex_files'] = all_dex_files
if is_java_target: if is_java_target:
config['javac']['classpath'] = javac_classpath config['javac']['classpath'] = javac_classpath
...@@ -1723,7 +1726,7 @@ def main(argv): ...@@ -1723,7 +1726,7 @@ def main(argv):
RemoveObjDups(config, base, 'deps_info', 'javac_full_classpath') RemoveObjDups(config, base, 'deps_info', 'javac_full_classpath')
RemoveObjDups(config, base, 'deps_info', 'javac_full_interface_classpath') RemoveObjDups(config, base, 'deps_info', 'javac_full_interface_classpath')
RemoveObjDups(config, base, 'deps_info', 'jni', 'all_source') RemoveObjDups(config, base, 'deps_info', 'jni', 'all_source')
RemoveObjDups(config, base, 'final_dex', 'dependency_dex_files') RemoveObjDups(config, base, 'final_dex', 'all_dex_files')
RemoveObjDups(config, base, 'extra_android_manifests') RemoveObjDups(config, base, 'extra_android_manifests')
build_utils.WriteJson(config, options.build_config, only_if_changed=True) build_utils.WriteJson(config, options.build_config, only_if_changed=True)
......
...@@ -31,19 +31,12 @@ def _ParseArgs(args): ...@@ -31,19 +31,12 @@ def _ParseArgs(args):
default=[], default=[],
help='A glob matching the apk splits. ' help='A glob matching the apk splits. '
'Can be specified multiple times.') 'Can be specified multiple times.')
parser.add_argument('--native-libs-list', parser.add_argument(
action='append', '--native-libs',
default=[], help='GN-list of paths to native libraries relative to '
help='GN-list of paths to native libraries relative to ' 'output directory. Can be repeated.')
'output directory. Can be repeated.') parser.add_argument(
parser.add_argument('--dex-file', '--dex-files', help='GN-list of dex paths relative to output directory.')
action='append',
default=[],
dest='dex_files',
help='.dex file to include relative to output directory. '
'Can be repeated')
parser.add_argument('--dex-file-list',
help='GN-list of dex paths relative to output directory.')
parser.add_argument('--show-proguard-warning', parser.add_argument('--show-proguard-warning',
action='store_true', action='store_true',
default=False, default=False,
...@@ -52,11 +45,8 @@ def _ParseArgs(args): ...@@ -52,11 +45,8 @@ def _ParseArgs(args):
help='Prints the given message and exits.') help='Prints the given message and exits.')
options = parser.parse_args(args) options = parser.parse_args(args)
options.dex_files += build_utils.ParseGnList(options.dex_file_list) options.dex_files = build_utils.ParseGnList(options.dex_files)
all_libs = [] options.native_libs = build_utils.ParseGnList(options.native_libs)
for gn_list in options.native_libs_list:
all_libs.extend(build_utils.ParseGnList(gn_list))
options.native_libs_list = all_libs
return options return options
...@@ -65,7 +55,7 @@ def main(args): ...@@ -65,7 +55,7 @@ def main(args):
data = { data = {
'apk_path': options.apk_path, 'apk_path': options.apk_path,
'native_libs': options.native_libs_list, 'native_libs': options.native_libs,
'dex_files': options.dex_files, 'dex_files': options.dex_files,
'dont_even_try': options.dont_even_try, 'dont_even_try': options.dont_even_try,
'show_proguard_warning': options.show_proguard_warning, 'show_proguard_warning': options.show_proguard_warning,
......
...@@ -227,12 +227,15 @@ template("write_build_config") { ...@@ -227,12 +227,15 @@ template("write_build_config") {
args += [ "--annotation-processor-configs=$_rebased_processor_configs" ] args += [ "--annotation-processor-configs=$_rebased_processor_configs" ]
} }
# Dex path for library targets, or the the intermediate library for apks.
if (defined(invoker.dex_path)) { if (defined(invoker.dex_path)) {
args += [ args += [
"--dex-path", "--dex-path",
rebase_path(invoker.dex_path, root_build_dir), rebase_path(invoker.dex_path, root_build_dir),
] ]
} }
# Dex path for the final apk.
if (defined(invoker.final_dex_path)) { if (defined(invoker.final_dex_path)) {
args += [ args += [
"--final-dex-path", "--final-dex-path",
...@@ -1143,7 +1146,6 @@ if (enable_java_templates) { ...@@ -1143,7 +1146,6 @@ if (enable_java_templates) {
} }
assert(!_proguard_enabled || !(defined(invoker.input_dex_filearg) || assert(!_proguard_enabled || !(defined(invoker.input_dex_filearg) ||
defined(invoker.input_dex_jars) ||
defined(invoker.input_classes_filearg) || defined(invoker.input_classes_filearg) ||
defined(invoker.input_class_jars)), defined(invoker.input_class_jars)),
"Cannot explicitly set inputs when proguarding a dex.") "Cannot explicitly set inputs when proguarding a dex.")
...@@ -1375,12 +1377,6 @@ if (enable_java_templates) { ...@@ -1375,12 +1377,6 @@ if (enable_java_templates) {
inputs += [ invoker.build_config ] inputs += [ invoker.build_config ]
args += [ "--dex-inputs-filearg=${invoker.input_dex_filearg}" ] args += [ "--dex-inputs-filearg=${invoker.input_dex_filearg}" ]
} }
if (defined(invoker.input_dex_jars) && invoker.input_dex_jars != []) {
inputs += invoker.input_dex_jars
_rebased_input_dex_jars =
rebase_path(invoker.input_dex_jars, root_build_dir)
args += [ "--dex-inputs=${_rebased_input_dex_jars}" ]
}
if (defined(invoker.input_classes_filearg)) { if (defined(invoker.input_classes_filearg)) {
inputs += [ invoker.build_config ] inputs += [ invoker.build_config ]
args += [ "--class-inputs-filearg=${invoker.input_classes_filearg}" ] args += [ "--class-inputs-filearg=${invoker.input_classes_filearg}" ]
......
...@@ -2161,7 +2161,6 @@ if (enable_java_templates) { ...@@ -2161,7 +2161,6 @@ if (enable_java_templates) {
# JUnit tests use resource zip files. These must not be put in gen/ # JUnit tests use resource zip files. These must not be put in gen/
# directory or they will not be available to tester bots. # directory or they will not be available to tester bots.
_jar_path = "$_base_path.jar" _jar_path = "$_base_path.jar"
_lib_dex_path = "$_base_path.dex.jar"
_template_name = target_name _template_name = target_name
_is_bundle_module = _is_bundle_module =
...@@ -2813,7 +2812,6 @@ if (enable_java_templates) { ...@@ -2813,7 +2812,6 @@ if (enable_java_templates) {
deps = _deps deps = _deps
srcjar_deps = _srcjar_deps srcjar_deps = _srcjar_deps
final_jar_path = _jar_path final_jar_path = _jar_path
dex_path = _lib_dex_path
final_dex_path = _final_dex_path final_dex_path = _final_dex_path
if (_is_bundle_module) { if (_is_bundle_module) {
...@@ -2919,8 +2917,8 @@ if (enable_java_templates) { ...@@ -2919,8 +2917,8 @@ if (enable_java_templates) {
deps += _deps + [ ":$_compile_resources_target" ] deps += _deps + [ ":$_compile_resources_target" ]
proguard_mapping_path = _proguard_mapping_path proguard_mapping_path = _proguard_mapping_path
} else { } else {
input_dex_jars = [ _lib_dex_path ] input_dex_filearg =
input_dex_filearg = "@FileArg(${_rebased_build_config}:final_dex:dependency_dex_files)" "@FileArg(${_rebased_build_config}:final_dex:all_dex_files)"
if (_enable_main_dex_list) { if (_enable_main_dex_list) {
main_dex_list_input_classes_filearg = "@FileArg(${_rebased_build_config}:deps_info:java_runtime_classpath)" main_dex_list_input_classes_filearg = "@FileArg(${_rebased_build_config}:deps_info:java_runtime_classpath)"
} }
...@@ -3207,13 +3205,10 @@ if (enable_java_templates) { ...@@ -3207,13 +3205,10 @@ if (enable_java_templates) {
rebase_path(_final_apk_path_no_ext, root_build_dir) rebase_path(_final_apk_path_no_ext, root_build_dir)
_rebased_incremental_install_json_path = _rebased_incremental_install_json_path =
rebase_path(_incremental_install_json_path, root_build_dir) rebase_path(_incremental_install_json_path, root_build_dir)
_rebased_lib_dex_path = rebase_path(_lib_dex_path, root_build_dir)
_dex_arg_key = "${_rebased_build_config}:final_dex:dependency_dex_files"
args = [ args = [
"--apk-path=${_rebased_apk_path_no_ext}_incremental.apk", "--apk-path=${_rebased_apk_path_no_ext}_incremental.apk",
"--output-path=$_rebased_incremental_install_json_path", "--output-path=$_rebased_incremental_install_json_path",
"--dex-file=$_rebased_lib_dex_path", "--dex-file=@FileArg($_rebased_build_config:final_dex:all_dex_files)",
"--dex-file-list=@FileArg($_dex_arg_key)",
] ]
if (_proguard_enabled) { if (_proguard_enabled) {
args += [ "--show-proguard-warning" ] args += [ "--show-proguard-warning" ]
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment