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.
Path to the final classes.dex file (or classes.zip in case of multi-dex)
for this APK.
* `deps_info['final_dex']['dependency_dex_files']`:
The list of paths to all `deps_info['dex_path']` entries for all library
dependencies for this APK.
* `deps_info['final_dex']['all_dex_files']`:
The list of paths to all `deps_info['dex_path']` entries for all libraries
that comprise this APK. Valid only for debug builds.
* `native['libraries']`
List of native libraries for the primary ABI to be embedded in this APK.
......@@ -1191,6 +1191,9 @@ def main(argv):
raise Exception('Not all deps support the Android platform: '
+ 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:
# Classpath values filled in below (after applying tested_apk_config).
config['javac'] = {}
......@@ -1200,6 +1203,8 @@ def main(argv):
deps_info['interface_jar_path'] = options.interface_jar_path
if 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':
deps_info['apk_path'] = options.apk_path
deps_info['incremental_apk_path'] = options.incremental_apk_path
......@@ -1318,9 +1323,6 @@ def main(argv):
if 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.extra_classpath_jars:
# These are .jars to add to javac classpath but not to runtime classpath.
......@@ -1590,8 +1592,9 @@ def main(argv):
# within proguard.py. Move the logic for the proguard case to here.
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]
deps_dex_files = [
p for p in deps_dex_files if not p in tested_apk_deps_dex_files]
all_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',
'android_app_bundle_module', 'android_app_bundle'):
......@@ -1605,7 +1608,7 @@ def main(argv):
dex_config = config['final_dex']
dex_config['path'] = options.final_dex_path
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:
config['javac']['classpath'] = javac_classpath
......@@ -1723,7 +1726,7 @@ def main(argv):
RemoveObjDups(config, base, 'deps_info', 'javac_full_classpath')
RemoveObjDups(config, base, 'deps_info', 'javac_full_interface_classpath')
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')
build_utils.WriteJson(config, options.build_config, only_if_changed=True)
......
......@@ -31,19 +31,12 @@ def _ParseArgs(args):
default=[],
help='A glob matching the apk splits. '
'Can be specified multiple times.')
parser.add_argument('--native-libs-list',
action='append',
default=[],
parser.add_argument(
'--native-libs',
help='GN-list of paths to native libraries relative to '
'output directory. Can be repeated.')
parser.add_argument('--dex-file',
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(
'--dex-files', help='GN-list of dex paths relative to output directory.')
parser.add_argument('--show-proguard-warning',
action='store_true',
default=False,
......@@ -52,11 +45,8 @@ def _ParseArgs(args):
help='Prints the given message and exits.')
options = parser.parse_args(args)
options.dex_files += build_utils.ParseGnList(options.dex_file_list)
all_libs = []
for gn_list in options.native_libs_list:
all_libs.extend(build_utils.ParseGnList(gn_list))
options.native_libs_list = all_libs
options.dex_files = build_utils.ParseGnList(options.dex_files)
options.native_libs = build_utils.ParseGnList(options.native_libs)
return options
......@@ -65,7 +55,7 @@ def main(args):
data = {
'apk_path': options.apk_path,
'native_libs': options.native_libs_list,
'native_libs': options.native_libs,
'dex_files': options.dex_files,
'dont_even_try': options.dont_even_try,
'show_proguard_warning': options.show_proguard_warning,
......
......@@ -227,12 +227,15 @@ template("write_build_config") {
args += [ "--annotation-processor-configs=$_rebased_processor_configs" ]
}
# Dex path for library targets, or the the intermediate library for apks.
if (defined(invoker.dex_path)) {
args += [
"--dex-path",
rebase_path(invoker.dex_path, root_build_dir),
]
}
# Dex path for the final apk.
if (defined(invoker.final_dex_path)) {
args += [
"--final-dex-path",
......@@ -1143,7 +1146,6 @@ if (enable_java_templates) {
}
assert(!_proguard_enabled || !(defined(invoker.input_dex_filearg) ||
defined(invoker.input_dex_jars) ||
defined(invoker.input_classes_filearg) ||
defined(invoker.input_class_jars)),
"Cannot explicitly set inputs when proguarding a dex.")
......@@ -1375,12 +1377,6 @@ if (enable_java_templates) {
inputs += [ invoker.build_config ]
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)) {
inputs += [ invoker.build_config ]
args += [ "--class-inputs-filearg=${invoker.input_classes_filearg}" ]
......
......@@ -2161,7 +2161,6 @@ if (enable_java_templates) {
# JUnit tests use resource zip files. These must not be put in gen/
# directory or they will not be available to tester bots.
_jar_path = "$_base_path.jar"
_lib_dex_path = "$_base_path.dex.jar"
_template_name = target_name
_is_bundle_module =
......@@ -2813,7 +2812,6 @@ if (enable_java_templates) {
deps = _deps
srcjar_deps = _srcjar_deps
final_jar_path = _jar_path
dex_path = _lib_dex_path
final_dex_path = _final_dex_path
if (_is_bundle_module) {
......@@ -2919,8 +2917,8 @@ if (enable_java_templates) {
deps += _deps + [ ":$_compile_resources_target" ]
proguard_mapping_path = _proguard_mapping_path
} else {
input_dex_jars = [ _lib_dex_path ]
input_dex_filearg = "@FileArg(${_rebased_build_config}:final_dex:dependency_dex_files)"
input_dex_filearg =
"@FileArg(${_rebased_build_config}:final_dex:all_dex_files)"
if (_enable_main_dex_list) {
main_dex_list_input_classes_filearg = "@FileArg(${_rebased_build_config}:deps_info:java_runtime_classpath)"
}
......@@ -3207,13 +3205,10 @@ if (enable_java_templates) {
rebase_path(_final_apk_path_no_ext, root_build_dir)
_rebased_incremental_install_json_path =
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 = [
"--apk-path=${_rebased_apk_path_no_ext}_incremental.apk",
"--output-path=$_rebased_incremental_install_json_path",
"--dex-file=$_rebased_lib_dex_path",
"--dex-file-list=@FileArg($_dex_arg_key)",
"--dex-file=@FileArg($_rebased_build_config:final_dex:all_dex_files)",
]
if (_proguard_enabled) {
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