 Chromium Code Reviews
 Chromium Code Reviews Issue 1805643002:
  🚀 Geneate base_unittest's Android .isolate file at build-time  (Closed) 
  Base URL: https://chromium.googlesource.com/chromium/src.git@master
    
  
    Issue 1805643002:
  🚀 Geneate base_unittest's Android .isolate file at build-time  (Closed) 
  Base URL: https://chromium.googlesource.com/chromium/src.git@master| Index: testing/test.gni | 
| diff --git a/testing/test.gni b/testing/test.gni | 
| index 4503860eedcb07b4c186e92ae239045e33ab41bb..d13c561c7d12d4bbd20d25b281f678bae5cd134c 100644 | 
| --- a/testing/test.gni | 
| +++ b/testing/test.gni | 
| @@ -6,9 +6,34 @@ | 
| # TEST SETUP | 
| # ============================================================================== | 
| +if (is_android) { | 
| + template("_gen_apk_isolate") { | 
| + action(target_name) { | 
| + script = "//build/android/gyp/gen-android-test-isolate.py" | 
| + outputs = [ | 
| + invoker.output, | 
| + ] | 
| + args = [ | 
| + "--out-file", | 
| + rebase_path(invoker.output, root_build_dir), | 
| + ".", | 
| + invoker.lib_target, | 
| + ] | 
| + } | 
| + } | 
| +} | 
| + | 
| # Define a test as an executable (or apk on Android) with the "testonly" flag | 
| # set. | 
| +# | 
| +# Variables: | 
| +# requires_apk_isolate: Whether the test has files (via data / data_deps) that | 
| +# need to be side-loaded to the device. | 
| template("test") { | 
| + _requires_apk_isolate = | 
| 
jbudorick
2016/03/15 20:23:14
Why define this outside of is_android?
 
agrieve
2016/03/15 20:34:07
I thought it'd be nice to have it live right besid
 | 
| + defined(invoker.requires_apk_isolate) && invoker.requires_apk_isolate | 
| + assert(_requires_apk_isolate || true) # Mark as used. | 
| + | 
| if (is_android) { | 
| import("//build/config/android/config.gni") | 
| import("//build/config/android/rules.gni") | 
| @@ -17,6 +42,14 @@ template("test") { | 
| library_name = "_${target_name}__library" | 
| apk_name = "${target_name}_apk" | 
| + if (_requires_apk_isolate) { | 
| + _apk_isolate_target_name = "_${target_name}__apk_isolate" | 
| + _apk_isolate_path = "$target_gen_dir/$target_name.apk.isolate" | 
| + _gen_apk_isolate(_apk_isolate_target_name) { | 
| + lib_target = get_label_info(":$library_name", "label_no_toolchain") | 
| + output = _apk_isolate_path | 
| + } | 
| + } | 
| shared_library(library_name) { | 
| # Configs will always be defined since we set_defaults for a component | 
| # in the main config. We want to use those rather than whatever came with | 
| @@ -89,7 +122,10 @@ template("test") { | 
| test_name = _test_name | 
| test_type = "gtest" | 
| test_suite = _test_name | 
| - if (defined(invoker.isolate_file)) { | 
| + if (_requires_apk_isolate) { | 
| + isolate_file = _apk_isolate_path | 
| + # TODO(agrieve): Delete next conditional once it's not used. | 
| + } else if (defined(invoker.isolate_file)) { | 
| isolate_file = invoker.isolate_file | 
| } | 
| } | 
| @@ -101,25 +137,34 @@ template("test") { | 
| test_type = "gtest" | 
| test_suite = _test_name | 
| incremental_install = true | 
| - if (defined(invoker.isolate_file)) { | 
| + if (_requires_apk_isolate) { | 
| + isolate_file = _apk_isolate_path | 
| + # TODO(agrieve): Delete next conditional once it's not used. | 
| + } else if (defined(invoker.isolate_file)) { | 
| isolate_file = invoker.isolate_file | 
| } | 
| } | 
| group(target_name) { | 
| testonly = true | 
| - datadeps = [ | 
| + data_deps = [ | 
| ":$test_runner_script_name", | 
| ] | 
| + if (_requires_apk_isolate) { | 
| + data_deps += [ ":$_apk_isolate_target_name" ] | 
| + } | 
| deps = [ | 
| ":$apk_name", | 
| ] | 
| } | 
| group("${target_name}_incremental") { | 
| testonly = true | 
| - datadeps = [ | 
| + data_deps = [ | 
| ":$incremental_test_runner_script_name", | 
| ] | 
| + if (_requires_apk_isolate) { | 
| + data_deps += [ ":$_apk_isolate_target_name" ] | 
| + } | 
| deps = [ | 
| ":${apk_name}_incremental", | 
| ] |