summaryrefslogtreecommitdiffstats
path: root/build
diff options
context:
space:
mode:
authorjbudorick <jbudorick@chromium.org>2016-01-15 11:43:47 -0800
committerCommit bot <commit-bot@chromium.org>2016-01-15 19:44:53 +0000
commitab450c5ede0635194331286088d0f488f4086ba5 (patch)
tree7435c3011a8270552696deb6125422a6fa0d1066 /build
parent8d3d8dd4bbf5d0876f3c787b447e97dba971795a (diff)
downloadchromium_src-ab450c5ede0635194331286088d0f488f4086ba5.zip
chromium_src-ab450c5ede0635194331286088d0f488f4086ba5.tar.gz
chromium_src-ab450c5ede0635194331286088d0f488f4086ba5.tar.bz2
[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-Commit-Position: refs/heads/master@{#369815}
Diffstat (limited to 'build')
-rwxr-xr-xbuild/android/gyp/configure_multidex.py50
-rw-r--r--build/android/java_cpp_template.gypi2
-rw-r--r--build/android/pylib/remote/device/dummy/dummy.gyp24
-rw-r--r--build/apk_browsertest.gypi2
-rw-r--r--build/apk_test.gypi2
-rw-r--r--build/config/android/rules.gni21
-rw-r--r--build/java_apk.gypi51
7 files changed, 126 insertions, 26 deletions
diff --git a/build/android/gyp/configure_multidex.py b/build/android/gyp/configure_multidex.py
index aa85d2f..9f3b736 100755
--- a/build/android/gyp/configure_multidex.py
+++ b/build/android/gyp/configure_multidex.py
@@ -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
diff --git a/build/android/java_cpp_template.gypi b/build/android/java_cpp_template.gypi
index f4ea0a9..3296659 100644
--- a/build/android/java_cpp_template.gypi
+++ b/build/android/java_cpp_template.gypi
@@ -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)',
}
diff --git a/build/android/pylib/remote/device/dummy/dummy.gyp b/build/android/pylib/remote/device/dummy/dummy.gyp
index b003edc..46e2d48 100644
--- a/build/android/pylib/remote/device/dummy/dummy.gyp
+++ b/build/android/pylib/remote/device/dummy/dummy.gyp
@@ -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)',
+ ],
+ }
]
}
diff --git a/build/apk_browsertest.gypi b/build/apk_browsertest.gypi
index 8cbc413..52cb9e0 100644
--- a/build/apk_browsertest.gypi
+++ b/build/apk_browsertest.gypi
@@ -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',
diff --git a/build/apk_test.gypi b/build/apk_test.gypi
index e0d323f..6512b6d 100644
--- a/build/apk_test.gypi
+++ b/build/apk_test.gypi
@@ -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',
diff --git a/build/config/android/rules.gni b/build/config/android/rules.gni
index da9a853..1c65d21 100644
--- a/build/config/android/rules.gni
+++ b/build/config/android/rules.gni
@@ -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" ]
}
diff --git a/build/java_apk.gypi b/build/java_apk.gypi
index ab49dc6..57d8558 100644
--- a/build/java_apk.gypi
+++ b/build/java_apk.gypi
@@ -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)',