[Android] Rework multidex and enable multidex for unit_tests_apk. (RELAND)
This is a reland of https://codereview.chromium.org/1581563003 BUG=272790 TBR=thakis@chromium.org,yfriedman@chromium.org,phajdan.jr@chromium.org Review URL: https://codereview.chromium.org/1590243003 Cr-Original-Commit-Position: refs/heads/master@{#369815} Cr-Mirrored-From: https://chromium.googlesource.com/chromium/src Cr-Mirrored-Commit: ab450c5ede0635194331286088d0f488f4086ba5
This commit is contained in:
Родитель
34d810a867
Коммит
8cfa662c60
|
@ -6,23 +6,33 @@
|
|||
|
||||
import argparse
|
||||
import json
|
||||
import os
|
||||
import sys
|
||||
|
||||
from util import build_utils
|
||||
|
||||
|
||||
_GCC_PREPROCESS_PATH = os.path.join(
|
||||
os.path.dirname(__file__), 'gcc_preprocess.py')
|
||||
|
||||
|
||||
def ParseArgs():
|
||||
parser = argparse.ArgumentParser()
|
||||
parser.add_argument('--configuration-name', required=True,
|
||||
help='The build CONFIGURATION_NAME.')
|
||||
parser.add_argument('--enable-multidex', action='store_true', default=False,
|
||||
help='If passed, multidex may be enabled.')
|
||||
parser.add_argument('--enabled-configurations', default=[],
|
||||
help='The configuration(s) for which multidex should be '
|
||||
'enabled. If not specified and --enable-multidex is '
|
||||
'passed, multidex will be enabled for all '
|
||||
'configurations.')
|
||||
'configurations.')
|
||||
parser.add_argument('--multidex-configuration-path', required=True,
|
||||
help='The path to which the multidex configuration JSON '
|
||||
'should be saved.')
|
||||
parser.add_argument('--multidex-config-java-file', required=True)
|
||||
parser.add_argument('--multidex-config-java-stamp', required=True)
|
||||
parser.add_argument('--multidex-config-java-template', required=True)
|
||||
|
||||
args = parser.parse_args()
|
||||
|
||||
|
@ -33,20 +43,42 @@ def ParseArgs():
|
|||
return args
|
||||
|
||||
|
||||
def main():
|
||||
args = ParseArgs()
|
||||
|
||||
multidex_enabled = (
|
||||
(not args.enabled_configurations
|
||||
or args.configuration_name in args.enabled_configurations))
|
||||
|
||||
def _WriteConfigJson(multidex_enabled, multidex_configuration_path):
|
||||
config = {
|
||||
'enabled': multidex_enabled,
|
||||
}
|
||||
|
||||
with open(args.multidex_configuration_path, 'w') as f:
|
||||
with open(multidex_configuration_path, 'w') as f:
|
||||
f.write(json.dumps(config))
|
||||
|
||||
|
||||
def _GenerateMultidexConfigJava(multidex_enabled, args):
|
||||
gcc_preprocess_cmd = [
|
||||
sys.executable, _GCC_PREPROCESS_PATH,
|
||||
'--include-path=',
|
||||
'--template', args.multidex_config_java_template,
|
||||
'--stamp', args.multidex_config_java_stamp,
|
||||
'--output', args.multidex_config_java_file,
|
||||
]
|
||||
if multidex_enabled:
|
||||
gcc_preprocess_cmd += [
|
||||
'--defines', 'ENABLE_MULTIDEX',
|
||||
]
|
||||
|
||||
build_utils.CheckOutput(gcc_preprocess_cmd)
|
||||
|
||||
|
||||
def main():
|
||||
args = ParseArgs()
|
||||
|
||||
multidex_enabled = (
|
||||
args.enable_multidex
|
||||
and (not args.enabled_configurations
|
||||
or args.configuration_name in args.enabled_configurations))
|
||||
|
||||
_WriteConfigJson(multidex_enabled, args.multidex_configuration_path)
|
||||
_GenerateMultidexConfigJava(multidex_enabled, args)
|
||||
|
||||
return 0
|
||||
|
||||
|
||||
|
|
|
@ -34,7 +34,6 @@
|
|||
{
|
||||
# Location where all generated Java sources will be placed.
|
||||
'variables': {
|
||||
'additional_gcc_preprocess_options': [],
|
||||
'include_path%': '<(DEPTH)',
|
||||
'output_dir': '<(SHARED_INTERMEDIATE_DIR)/templates/<(_target_name)/<(package_name)',
|
||||
},
|
||||
|
@ -75,7 +74,6 @@
|
|||
'--include-path=<(include_path)',
|
||||
'--output=<(output_path)',
|
||||
'--template=<(RULE_INPUT_PATH)',
|
||||
'<@(additional_gcc_preprocess_options)',
|
||||
],
|
||||
'message': 'Generating Java from cpp template <(RULE_INPUT_PATH)',
|
||||
}
|
||||
|
|
|
@ -7,13 +7,18 @@
|
|||
# APK, so we build a dummy APK to upload as the app.
|
||||
|
||||
{
|
||||
'variables': {
|
||||
'remote_device_dummy_apk_name': 'remote_device_dummy',
|
||||
'remote_device_dummy_apk_path': '<(PRODUCT_DIR)/apks/<(remote_device_dummy_apk_name).apk',
|
||||
},
|
||||
'targets': [
|
||||
{
|
||||
# GN: //build/android/pylib/remote/device/dummy:remote_device_dummy_apk
|
||||
'target_name': 'remote_device_dummy_apk',
|
||||
'type': 'none',
|
||||
'variables': {
|
||||
'apk_name': 'remote_device_dummy',
|
||||
'apk_name': '<(remote_device_dummy_apk_name)',
|
||||
'final_apk_path': '<(remote_device_dummy_apk_path)',
|
||||
'java_in_dir': '.',
|
||||
'android_manifest_path': '../../../../../../build/android/AndroidManifest.xml',
|
||||
},
|
||||
|
@ -21,5 +26,22 @@
|
|||
'../../../../../../build/java_apk.gypi',
|
||||
]
|
||||
},
|
||||
{
|
||||
'target_name': 'require_remote_device_dummy_apk',
|
||||
'message': 'Making sure <(remote_device_dummy_apk_path) has been built.',
|
||||
'type': 'none',
|
||||
'variables': {
|
||||
'required_file': '<(PRODUCT_DIR)/remote_device_dummy_apk/<(remote_device_dummy_apk_name).apk.required',
|
||||
},
|
||||
'inputs': [
|
||||
'<(remote_device_dummy_apk_path)',
|
||||
],
|
||||
'outputs': [
|
||||
'<(required_file)',
|
||||
],
|
||||
'action': [
|
||||
'python', '../../build/android/gyp/touch.py', '<(required_file)',
|
||||
],
|
||||
}
|
||||
]
|
||||
}
|
||||
|
|
|
@ -21,7 +21,7 @@
|
|||
'dependencies': [
|
||||
'<(DEPTH)/base/base.gyp:base_java',
|
||||
'<(DEPTH)/build/android/pylib/device/commands/commands.gyp:chromium_commands',
|
||||
'<(DEPTH)/build/android/pylib/remote/device/dummy/dummy.gyp:remote_device_dummy_apk',
|
||||
'<(DEPTH)/build/android/pylib/remote/device/dummy/dummy.gyp:require_remote_device_dummy_apk',
|
||||
'<(DEPTH)/testing/android/appurify_support.gyp:appurify_support_java',
|
||||
'<(DEPTH)/testing/android/native_test.gyp:native_test_java',
|
||||
'<(DEPTH)/tools/android/android_tools.gyp:android_tools',
|
||||
|
|
|
@ -21,7 +21,7 @@
|
|||
'dependencies': [
|
||||
'<(DEPTH)/base/base.gyp:base_java',
|
||||
'<(DEPTH)/build/android/pylib/device/commands/commands.gyp:chromium_commands',
|
||||
'<(DEPTH)/build/android/pylib/remote/device/dummy/dummy.gyp:remote_device_dummy_apk',
|
||||
'<(DEPTH)/build/android/pylib/remote/device/dummy/dummy.gyp:require_remote_device_dummy_apk',
|
||||
'<(DEPTH)/testing/android/appurify_support.gyp:appurify_support_java',
|
||||
'<(DEPTH)/testing/android/on_device_instrumentation.gyp:reporter_java',
|
||||
'<(DEPTH)/tools/android/android_tools.gyp:android_tools',
|
||||
|
|
|
@ -1484,6 +1484,21 @@ template("android_apk") {
|
|||
_srcjar_deps += [ ":${_template_name}__native_libraries_java" ]
|
||||
}
|
||||
|
||||
if (!defined(invoker.apk_under_test)) {
|
||||
java_cpp_template("${_template_name}__multidex_config_java") {
|
||||
package_name = "org/chromium/base/multidex"
|
||||
sources = [
|
||||
"//base/android/java/templates/ChromiumMultiDex.template",
|
||||
]
|
||||
|
||||
defines = []
|
||||
if (enable_multidex) {
|
||||
defines += [ "ENABLE_MULTIDEX" ]
|
||||
}
|
||||
}
|
||||
_srcjar_deps += [ ":${_template_name}__multidex_config_java" ]
|
||||
}
|
||||
|
||||
java_target = "${_template_name}__java"
|
||||
java_library_impl(java_target) {
|
||||
forward_variables_from(invoker, [ "run_findbugs" ])
|
||||
|
@ -2018,11 +2033,13 @@ template("unittest_apk") {
|
|||
native_libs = [ unittests_binary ]
|
||||
deps += [
|
||||
"//base:base_java",
|
||||
"//build/android/pylib/remote/device/dummy:remote_device_dummy_apk",
|
||||
"//testing/android/appurify_support:appurify_support_java",
|
||||
"//testing/android/reporter:reporter_java",
|
||||
]
|
||||
data_deps += [ "//tools/android/md5sum" ]
|
||||
data_deps += [
|
||||
"//build/android/pylib/remote/device/dummy:remote_device_dummy_apk",
|
||||
"//tools/android/md5sum",
|
||||
]
|
||||
if (host_os == "linux") {
|
||||
data_deps += [ "//tools/android/forwarder2" ]
|
||||
}
|
||||
|
|
|
@ -77,6 +77,7 @@
|
|||
'tested_apk_obfuscated_jar_path%': '/',
|
||||
'tested_apk_dex_path%': '/',
|
||||
'tested_apk_is_multidex%': 0,
|
||||
'tested_apk_generated_multidex_config%': 0,
|
||||
'additional_input_paths': [],
|
||||
'additional_locale_input_paths': [],
|
||||
'create_density_splits%': 0,
|
||||
|
@ -121,6 +122,11 @@
|
|||
'native_libraries_template_data_dir': '<(intermediate_dir)/native_libraries/',
|
||||
'native_libraries_template_data_file': '<(native_libraries_template_data_dir)/native_libraries_array.h',
|
||||
'native_libraries_template_version_file': '<(native_libraries_template_data_dir)/native_libraries_version.h',
|
||||
'generate_multidex_config%': 0,
|
||||
'multidex_config_template': '<(DEPTH)/base/android/java/templates/ChromiumMultiDex.template',
|
||||
'multidex_config_java_dir': '<(intermediate_dir)/multidex_config/',
|
||||
'multidex_config_java_file': '<(multidex_config_java_dir)/ChromiumMultiDex.java',
|
||||
'multidex_config_java_stamp': '<(intermediate_dir)/multidex_config_java.stamp',
|
||||
'compile_stamp': '<(intermediate_dir)/compile.stamp',
|
||||
'lint_stamp': '<(intermediate_dir)/lint.stamp',
|
||||
'lint_result': '<(intermediate_dir)/lint_result.xml',
|
||||
|
@ -266,6 +272,7 @@
|
|||
'tested_apk_obfuscated_jar_path': '<(obfuscated_jar_path)',
|
||||
'tested_apk_dex_path': '<(dex_path)',
|
||||
'tested_apk_is_multidex': '<(enable_multidex)',
|
||||
'tested_apk_generated_multidex_config': '>(generate_multidex_config)',
|
||||
}
|
||||
}]
|
||||
],
|
||||
|
@ -794,37 +801,58 @@
|
|||
},
|
||||
],
|
||||
}],
|
||||
['enable_multidex == 1', {
|
||||
],
|
||||
'target_conditions': [
|
||||
['generate_multidex_config == 1 and tested_apk_generated_multidex_config == 0', {
|
||||
'variables': {
|
||||
'generated_src_dirs': ['<(multidex_config_java_dir)'],
|
||||
},
|
||||
'actions': [
|
||||
{
|
||||
'action_name': 'main_dex_list_for_<(_target_name)',
|
||||
'variables': {
|
||||
'jar_paths': ['>@(input_jars_paths)', '<(javac_jar_path)'],
|
||||
'output_path': '<(main_dex_list_path)',
|
||||
},
|
||||
'includes': [ 'android/main_dex_action.gypi' ],
|
||||
},
|
||||
{
|
||||
'action_name': 'configure_multidex_for_<(_target_name)',
|
||||
'inputs': [
|
||||
'<(DEPTH)/build/android/gyp/configure_multidex.py',
|
||||
'<(multidex_config_template)',
|
||||
],
|
||||
'outputs': [
|
||||
'<(multidex_configuration_path)',
|
||||
'<(multidex_config_java_stamp)',
|
||||
],
|
||||
'variables': {
|
||||
'additional_multidex_config_options': [],
|
||||
'enabled_configurations': ['>@(enable_multidex_configurations)'],
|
||||
'enabled_configurations': '>(enable_multidex_configurations)',
|
||||
'conditions': [
|
||||
['enable_multidex == 1', {
|
||||
'additional_multidex_config_options': ['--enable-multidex'],
|
||||
}],
|
||||
],
|
||||
},
|
||||
'action': [
|
||||
'python', '<(DEPTH)/build/android/gyp/configure_multidex.py',
|
||||
'--configuration-name', '<(CONFIGURATION_NAME)',
|
||||
'--enabled-configurations', '<(enabled_configurations)',
|
||||
'--multidex-configuration-path', '<(multidex_configuration_path)',
|
||||
'--multidex-config-java-template', '<(multidex_config_template)',
|
||||
'--multidex-config-java-file', '<(multidex_config_java_file)',
|
||||
'--multidex-config-java-stamp', '<(multidex_config_java_stamp)',
|
||||
'>@(additional_multidex_config_options)',
|
||||
],
|
||||
},
|
||||
],
|
||||
'conditions': [
|
||||
['enable_multidex == 1', {
|
||||
'actions': [
|
||||
{
|
||||
'action_name': 'main_dex_list_for_<(_target_name)',
|
||||
'variables': {
|
||||
'jar_paths': ['>@(input_jars_paths)', '<(javac_jar_path)'],
|
||||
'output_path': '<(main_dex_list_path)',
|
||||
},
|
||||
'includes': [ 'android/main_dex_action.gypi' ],
|
||||
},
|
||||
]
|
||||
}]
|
||||
],
|
||||
}],
|
||||
],
|
||||
'dependencies': [
|
||||
|
@ -955,6 +983,9 @@
|
|||
['native_lib_target != ""', {
|
||||
'inputs': [ '<(native_libraries_java_stamp)' ],
|
||||
}],
|
||||
['generate_multidex_config == 1', {
|
||||
'inputs': [ '<(multidex_config_java_stamp)' ],
|
||||
}],
|
||||
],
|
||||
'outputs': [
|
||||
'<(compile_stamp)',
|
||||
|
|
Загрузка…
Ссылка в новой задаче