Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(851)

Side by Side Diff: testing/test.gni

Issue 1854233002: Reland 2 of GN: Make breakpad_unittests & sandbox_linux_unittests use test() (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@test-minor-renames
Patch Set: Fix PIE errors, fix component mode. Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « sandbox/linux/sandbox_linux.gypi ('k') | tools/android/forwarder2/BUILD.gn » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 # Copyright 2015 The Chromium Authors. All rights reserved. 1 # Copyright 2015 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be 2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file. 3 # found in the LICENSE file.
4 4
5 # ============================================================================== 5 # ==============================================================================
6 # TEST SETUP 6 # TEST SETUP
7 # ============================================================================== 7 # ==============================================================================
8 8
9 # Define a test as an executable (or apk on Android) with the "testonly" flag 9 # Define a test as an executable (or apk on Android) with the "testonly" flag
10 # set. 10 # set.
11 # Variable:
12 # use_raw_android_executable: Use executable() rather than android_apk().
11 template("test") { 13 template("test") {
12 if (is_android) { 14 if (is_android) {
13 import("//build/config/android/config.gni") 15 import("//build/config/android/config.gni")
14 import("//build/config/android/rules.gni") 16 import("//build/config/android/rules.gni")
15 17
16 _library_target = "_${target_name}__library" 18 _use_raw_android_executable = defined(invoker.use_raw_android_executable) &&
17 _apk_target = "${target_name}_apk" 19 invoker.use_raw_android_executable
18
19 shared_library(_library_target) {
20 # Configs will always be defined since we set_defaults for a component
21 # in the main config. We want to use those rather than whatever came with
22 # the nested shared/static library inside the component.
23 configs = [] # Prevent list overwriting warning.
24 configs = invoker.configs
25
26 testonly = true
27
28 # Don't use "*" to forward all variables since some (like output_name
29 # and isolate_file) apply only to the APK below.
30 deps = []
31 forward_variables_from(invoker,
32 [
33 "all_dependent_configs",
34 "allow_circular_includes_from",
35 "cflags",
36 "cflags_c",
37 "cflags_cc",
38 "check_includes",
39 "data",
40 "data_deps",
41 "datadeps",
42 "defines",
43 "deps",
44 "include_dirs",
45 "ldflags",
46 "lib_dirs",
47 "libs",
48 "output_extension",
49 "output_name",
50 "public",
51 "public_configs",
52 "public_deps",
53 "sources",
54 "visibility",
55 ])
56
57 if (!defined(invoker.use_default_launcher) ||
58 invoker.use_default_launcher) {
59 deps += [ "//testing/android/native_test:native_test_native_code" ]
60 }
61 }
62
63 unittest_apk(_apk_target) {
64 forward_variables_from(invoker,
65 [
66 "android_manifest",
67 "deps",
68 "enable_multidex",
69 "use_default_launcher",
70 "write_asset_list",
71 ])
72 unittests_dep = ":$_library_target"
73 apk_name = invoker.target_name
74 if (defined(invoker.output_name)) {
75 apk_name = invoker.output_name
76 unittests_binary = "lib${apk_name}.so"
77 install_script_name = "install_${invoker.output_name}"
78 }
79 deps += [ ":$_library_target" ]
80 }
81 20
82 # output_name is used to allow targets with the same name but in different 21 # output_name is used to allow targets with the same name but in different
83 # packages to still produce unique runner scripts. 22 # packages to still produce unique runner scripts.
84 _output_name = invoker.target_name 23 _output_name = invoker.target_name
85 if (defined(invoker.output_name)) { 24 if (defined(invoker.output_name)) {
86 _output_name = invoker.output_name 25 _output_name = invoker.output_name
87 } 26 }
27
28 if (_use_raw_android_executable) {
29 _exec_target = "${target_name}__exec"
30 _dist_target = "${target_name}__dist"
31 _exec_output =
32 "$target_out_dir/${invoker.target_name}/${invoker.target_name}"
33
34 executable(_exec_target) {
35 # Configs will always be defined since we set_defaults in BUILDCONFIG.gn .
36 configs = []
37 data_deps = []
38 forward_variables_from(invoker, "*", [ "extra_dist_files" ])
39 testonly = true
40
41 # Thanks to the set_defaults() for test(), configs are initialized with
42 # the default shared_library configs rather than executable configs.
43 configs -= [
44 "//build/config:shared_library_config",
45 "//build/config/android:hide_native_jni_exports",
46 ]
47 configs += [ "//build/config:executable_config" ]
48
49 # Don't output to the root or else conflict with the group() below.
50 output_name = rebase_path(_exec_output, root_out_dir)
51 if (is_component_build || is_asan) {
52 data_deps += [ "//build/android:cpplib_stripped" ]
53 }
54 }
55
56 create_native_executable_dist(_dist_target) {
57 testonly = true
58 dist_dir = "$root_out_dir/$target_name"
59 binary = _exec_output
60 deps = [
61 ":$_exec_target",
62 ]
63 if (defined(invoker.extra_dist_files)) {
64 extra_files = invoker.extra_dist_files
65 }
66 }
67 } else {
68 _library_target = "_${target_name}__library"
69 _apk_target = "${target_name}_apk"
70 _apk_specific_vars = [
71 "android_manifest",
72 "enable_multidex",
73 "use_default_launcher",
74 "write_asset_list",
75 ]
76 shared_library(_library_target) {
77 # Configs will always be defined since we set_defaults in BUILDCONFIG.gn .
78 configs = [] # Prevent list overwriting warning.
79 configs = invoker.configs
80 testonly = true
81
82 deps = []
83 forward_variables_from(invoker,
84 "*",
85 _apk_specific_vars + [
86 "isolate_file",
87 "visibility",
88 ])
89
90 if (!defined(invoker.use_default_launcher) ||
91 invoker.use_default_launcher) {
92 deps += [ "//testing/android/native_test:native_test_native_code" ]
93 }
94 }
95 unittest_apk(_apk_target) {
96 forward_variables_from(invoker, _apk_specific_vars + [ "deps" ])
97 unittests_dep = ":$_library_target"
98 apk_name = invoker.target_name
99 if (defined(invoker.output_name)) {
100 apk_name = invoker.output_name
101 unittests_binary = "lib${apk_name}.so"
102 install_script_name = "install_${invoker.output_name}"
103 }
104 deps += [ ":$_library_target" ]
105 }
106
107 # Incremental test targets work only for .apks.
108 _incremental_test_runner_target =
109 "${_output_name}_incremental__test_runner_script"
110 test_runner_script(_incremental_test_runner_target) {
111 forward_variables_from(invoker, [ "isolate_file" ])
112 apk_target = ":$_apk_target"
113 test_name = "${_output_name}_incremental"
114 test_type = "gtest"
115 test_suite = _output_name
116 incremental_install = true
117 }
118 group("${target_name}_incremental") {
119 testonly = true
120 datadeps = [
121 ":$_incremental_test_runner_target",
122 ]
123 deps = [
124 ":${_apk_target}_incremental",
125 ]
126 }
127 }
128
88 _test_runner_target = "${_output_name}__test_runner_script" 129 _test_runner_target = "${_output_name}__test_runner_script"
89 test_runner_script(_test_runner_target) { 130 test_runner_script(_test_runner_target) {
90 apk_target = ":$_apk_target" 131 forward_variables_from(invoker, [ "isolate_file" ])
132 if (_use_raw_android_executable) {
133 executable_dist_dir = "$root_out_dir/$_dist_target"
134 } else {
135 apk_target = ":$_apk_target"
136 }
91 test_name = _output_name 137 test_name = _output_name
92 test_type = "gtest" 138 test_type = "gtest"
93 test_suite = _output_name 139 test_suite = _output_name
94 if (defined(invoker.isolate_file)) {
95 isolate_file = invoker.isolate_file
96 }
97 }
98 _incremental_test_runner_target =
99 "${_output_name}_incremental__test_runner_script"
100 test_runner_script(_incremental_test_runner_target) {
101 apk_target = ":$_apk_target"
102 test_name = "${_output_name}_incremental"
103 test_type = "gtest"
104 test_suite = _output_name
105 incremental_install = true
106 if (defined(invoker.isolate_file)) {
107 isolate_file = invoker.isolate_file
108 }
109 } 140 }
110 141
111 group(target_name) { 142 group(target_name) {
112 testonly = true 143 testonly = true
113 datadeps = [ 144 deps = [
114 ":$_test_runner_target", 145 ":$_test_runner_target",
115 ] 146 ]
116 deps = [ 147 if (_use_raw_android_executable) {
117 ":$_apk_target", 148 deps += [ ":$_dist_target" ]
118 ] 149 } else {
119 } 150 deps += [ ":$_apk_target" ]
120 group("${target_name}_incremental") { 151 }
121 testonly = true
122 datadeps = [
123 ":$_incremental_test_runner_target",
124 ]
125 deps = [
126 ":${_apk_target}_incremental",
127 ]
128 } 152 }
129 153
130 # TODO(GYP): Delete this after we've converted everything to GN. 154 # TODO(GYP): Delete this after we've converted everything to GN.
131 # The _run targets exist only for compatibility w/ GYP. 155 # The _run targets exist only for compatibility w/ GYP.
132 group("${target_name}_apk_run") { 156 group("${target_name}_apk_run") {
133 testonly = true 157 testonly = true
134 deps = [ 158 deps = [
135 ":${invoker.target_name}", 159 ":${invoker.target_name}",
136 ] 160 ]
137 } 161 }
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
199 # TODO(GYP): Delete this after we've converted everything to GN. 223 # TODO(GYP): Delete this after we've converted everything to GN.
200 # The _run targets exist only for compatibility with GYP. 224 # The _run targets exist only for compatibility with GYP.
201 group("${target_name}_run") { 225 group("${target_name}_run") {
202 testonly = true 226 testonly = true
203 deps = [ 227 deps = [
204 ":${invoker.target_name}", 228 ":${invoker.target_name}",
205 ] 229 ]
206 } 230 }
207 } 231 }
208 } 232 }
OLDNEW
« no previous file with comments | « sandbox/linux/sandbox_linux.gypi ('k') | tools/android/forwarder2/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698