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
3 # found in the LICENSE file.
5 # ==============================================================================
7 # ==============================================================================
9 # Define a test as an executable (or apk on Android) with the "testonly" flag
13 import("//build/config/android/config.gni")
14 import("//build/config/android/rules.gni")
16 main_target_name = target_name
17 library_name = "_${target_name}__library"
18 apk_name = "${target_name}_apk"
20 shared_library(library_name) {
21 # Configs will always be defined since we set_defaults for a component
22 # in the main config. We want to use those rather than whatever came with
23 # the nested shared/static library inside the component.
24 configs = [] # Prevent list overwriting warning.
25 configs = invoker.configs
28 set_sources_assignment_filter([])
32 if (defined(invoker.all_dependent_configs)) {
33 all_dependent_configs = invoker.all_dependent_configs
35 if (defined(invoker.allow_circular_includes_from)) {
36 allow_circular_includes_from = invoker.allow_circular_includes_from
38 if (defined(invoker.cflags)) {
39 cflags = invoker.cflags
41 if (defined(invoker.cflags_c)) {
42 cflags_c = invoker.cflags_c
44 if (defined(invoker.cflags_cc)) {
45 cflags_cc = invoker.cflags_cc
47 if (defined(invoker.cflags_objc)) {
48 cflags_objc = invoker.cflags_objc
50 if (defined(invoker.cflags_objcc)) {
51 cflags_objcc = invoker.cflags_objcc
53 if (defined(invoker.check_includes)) {
54 check_includes = invoker.check_includes
56 if (defined(invoker.data)) {
59 if (defined(invoker.data_deps)) {
60 data_deps = invoker.data_deps
62 if (defined(invoker.datadeps)) {
63 datadeps = invoker.datadeps
65 if (defined(invoker.defines)) {
66 defines = invoker.defines
69 if (!defined(invoker.use_launcher) || invoker.use_launcher) {
70 deps += [ "//testing/android/native_test:native_test_native_code" ]
72 if (defined(invoker.deps)) {
75 if (defined(invoker.direct_dependent_configs)) {
76 direct_dependent_configs = invoker.direct_dependent_configs
78 if (defined(invoker.forward_dependent_configs_from)) {
79 forward_dependent_configs_from = invoker.forward_dependent_configs_from
81 if (defined(invoker.include_dirs)) {
82 include_dirs = invoker.include_dirs
84 if (defined(invoker.ldflags)) {
85 ldflags = invoker.ldflags
87 if (defined(invoker.lib_dirs)) {
88 lib_dirs = invoker.lib_dirs
90 if (defined(invoker.libs)) {
93 if (defined(invoker.output_extension)) {
94 output_extension = invoker.output_extension
96 if (defined(invoker.output_name)) {
97 output_name = invoker.output_name
99 if (defined(invoker.public)) {
100 public = invoker.public
102 if (defined(invoker.public_configs)) {
103 public_configs = invoker.public_configs
105 if (defined(invoker.public_deps)) {
106 public_deps = invoker.public_deps
108 if (defined(invoker.sources)) {
109 sources = invoker.sources
111 if (defined(invoker.visibility)) {
112 visibility = invoker.visibility
116 unittest_apk(apk_name) {
117 unittests_dep = ":$library_name"
118 apk_name = main_target_name
119 if (defined(invoker.output_name)) {
120 test_output_name = invoker.output_name
121 unittests_binary = "lib${test_output_name}.so"
126 if (defined(invoker.apk_deps)) {
127 deps += invoker.apk_deps
129 if (defined(invoker.apk_asset_location)) {
130 asset_location = invoker.apk_asset_location
143 executable(target_name) {
145 configs = [] # Prevent list overwriting warning.
146 configs = invoker.configs
149 set_sources_assignment_filter([])
153 if (defined(invoker.all_dependent_configs)) {
154 all_dependent_configs = invoker.all_dependent_configs
156 if (defined(invoker.allow_circular_includes_from)) {
157 allow_circular_includes_from = invoker.allow_circular_includes_from
159 if (defined(invoker.cflags)) {
160 cflags = invoker.cflags
162 if (defined(invoker.cflags_c)) {
163 cflags_c = invoker.cflags_c
165 if (defined(invoker.cflags_cc)) {
166 cflags_cc = invoker.cflags_cc
168 if (defined(invoker.cflags_objc)) {
169 cflags_objc = invoker.cflags_objc
171 if (defined(invoker.cflags_objcc)) {
172 cflags_objcc = invoker.cflags_objcc
174 if (defined(invoker.check_includes)) {
175 check_includes = invoker.check_includes
177 if (defined(invoker.data)) {
180 if (defined(invoker.data_deps)) {
181 data_deps = invoker.data_deps
183 if (defined(invoker.datadeps)) {
184 datadeps = invoker.datadeps
186 if (defined(invoker.defines)) {
187 defines = invoker.defines
190 # All shared libraries must have the sanitizer deps to properly link in
191 # asan mode (this target will be empty in other cases).
192 if (defined(invoker.deps)) {
193 deps = invoker.deps + [ "//build/config/sanitizers:deps" ]
196 "//build/config/sanitizers:deps",
199 if (defined(invoker.direct_dependent_configs)) {
200 direct_dependent_configs = invoker.direct_dependent_configs
202 if (defined(invoker.forward_dependent_configs_from)) {
203 forward_dependent_configs_from = invoker.forward_dependent_configs_from
205 if (defined(invoker.include_dirs)) {
206 include_dirs = invoker.include_dirs
208 if (defined(invoker.ldflags)) {
209 ldflags = invoker.ldflags
211 if (defined(invoker.lib_dirs)) {
212 lib_dirs = invoker.lib_dirs
214 if (defined(invoker.libs)) {
217 if (defined(invoker.output_extension)) {
218 output_extension = invoker.output_extension
220 if (defined(invoker.output_name)) {
221 output_name = invoker.output_name
223 if (defined(invoker.public)) {
224 public = invoker.public
226 if (defined(invoker.public_configs)) {
227 public_configs = invoker.public_configs
229 if (defined(invoker.public_deps)) {
230 public_deps = invoker.public_deps
232 if (defined(invoker.sources)) {
233 sources = invoker.sources
235 if (defined(invoker.visibility)) {
236 visibility = invoker.visibility