Use output_name for Mojo and Mandoline test targets.
[chromium-blink-merge.git] / mojo / runner / BUILD.gn
blobdffaeaf8a0c8852ac8daa2143f38fc6554e56a65
1 # Copyright 2014 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 import("//build/config/ui.gni")
6 import("//third_party/mojo/src/mojo/public/mojo.gni")
7 import("//third_party/mojo/src/mojo/public/mojo_application.gni")
8 import("//third_party/mojo/src/mojo/public/tools/bindings/mojom.gni")
9 import("//testing/test.gni")
11 # We don't support building in the component build since mojo apps are
12 # inherently components.
13 assert(!is_component_build)
15 group("runner") {
16   testonly = true
18   deps = [
19     ":mojo_runner",
20   ]
22   if (is_android) {
23     deps += [ ":mojo_runner_apk" ]
24   }
27 if (is_android) {
28   import("//build/config/android/config.gni")
29   import("//build/config/android/rules.gni")
32 executable("mojo_runner") {
33   sources = []
35   deps = [
36     ":lib",
37     "//base",
38     "//build/config/sanitizers:deps",
39     "//mojo/common",
40     "//mojo/environment:chromium",
41   ]
43   if (!is_android) {
44     sources += [
45       "desktop/launcher_process.cc",
46       "desktop/launcher_process.h",
47       "desktop/main.cc",
48     ]
49   } else {
50     sources += [
51       "android/library_loader.cc",
52       "android/main.cc",
53       "android/main.h",
54     ]
56     # On android, the executable is also the native library used by the apk.
57     # It means dynamic symbols must be preserved and exported.
58     ldflags = [ "-Wl,--export-dynamic" ]
60     deps += [
61       ":jni_headers",
62       "//components/native_viewport:lib",
63       "//mojo/shell",
64       "//ui/gl",
65     ]
66   }
69 source_set("in_process_native_runner") {
70   sources = [
71     "in_process_native_runner.cc",
72     "in_process_native_runner.h",
73   ]
75   public_deps = [
76     ":native_application_support",
77     "//mojo/shell",
78   ]
80   deps = [
81     "//base",
82   ]
85 source_set("lib") {
86   sources = [
87     "child_process.cc",
88     "child_process.h",
89     "child_process_host.cc",
90     "child_process_host.h",
91     "context.cc",
92     "context.h",
93     "init.cc",
94     "init.h",
95     "out_of_process_native_runner.cc",
96     "out_of_process_native_runner.h",
97     "task_runners.cc",
98     "task_runners.h",
99     "url_resolver.cc",
100     "url_resolver.h",
101   ]
103   deps = [
104     ":child_process_bindings",
105     ":in_process_native_runner",
106     ":native_application_support",
107     "//base",
108     "//base/third_party/dynamic_annotations",
109     "//base:base_static",
110     "//mojo/application",
111     "//mojo/common",
112     "//mojo/common:tracing_impl",
113     "//mojo/util:filename_util",
114     "//third_party/mojo/src/mojo/edk/system",
115     "//third_party/mojo/src/mojo/public/cpp/bindings",
116     "//third_party/mojo/src/mojo/public/interfaces/application",
117     "//mojo/services/network/public/interfaces",
118     "//mojo/shell",
119     "//mojo/services/tracing:bindings",
120     "//ui/gl",
121     "//url",
122   ]
124   public_deps = [
125     ":switches",
126   ]
128   data_deps = [
129     "//components/core_services",
130     "//mojo/services/tracing",
131   ]
133   if (is_android) {
134     sources += [
135       "android/android_handler.cc",
136       "android/android_handler.h",
137       "android/android_handler_loader.cc",
138       "android/android_handler_loader.h",
139       "android/background_application_loader.cc",
140       "android/background_application_loader.h",
141       "android/native_viewport_application_loader.cc",
142       "android/native_viewport_application_loader.h",
143       "android/ui_application_loader_android.cc",
144       "android/ui_application_loader_android.h",
145     ]
147     deps += [
148       ":jni_headers",
149       ":run_android_application_function",
150       "//components/gles2",
151       "//components/native_viewport:lib",
152       "//mojo/application:content_handler",
153     ]
154   }
156   # This target includes some files behind #ifdef OS... guards. Since gn is not
157   # smart enough to understand preprocess includes, it does complains about
158   # these includes when not using the build files for that OS. Suppress checking
159   # so we can enable checking for the rest of the targets in this file.
160   # TODO: Might be better to split the files with OS-specific includes out to a
161   # separate source_set so we can leave checking on for the rest of the target.
162   check_includes = false
165 source_set("native_application_support") {
166   sources = [
167     "native_application_support.cc",
168     "native_application_support.h",
169     "platform_handle_impl.cc",
170   ]
172   public_deps = [
173     "//third_party/mojo/src/mojo/public/cpp/bindings",
174   ]
176   deps = [
177     "//base",
178     "//mojo/gles2",
179     "//mojo/platform_handle:defs",
180   ]
182   # This target has to include the public thunk headers, which generally
183   # shouldn't be included without picking an implementation. We are providing
184   # the implementation but the thunk header target cannot declare that we are
185   # permitted to include it since it's in the public SDK and we are not.
186   # Suppress include checking so we can still check the rest of the targets in
187   # this file.
188   check_includes = false
191 source_set("switches") {
192   sources = [
193     "switches.cc",
194     "switches.h",
195   ]
197   deps = [
198     "//base",
199   ]
202 if (is_android) {
203   generate_jni("jni_headers") {
204     sources = [
205       "android/apk/src/org/chromium/mojo/shell/AndroidHandler.java",
206       "android/apk/src/org/chromium/mojo/shell/Bootstrap.java",
207       "android/apk/src/org/chromium/mojo/shell/ShellMain.java",
208       "android/tests/src/org/chromium/mojo/shell/ShellTestBase.java",
209     ]
210     jni_package = "mojo/shell"
211   }
213   android_library("bootstrap_java") {
214     java_files = [ "android/apk/src/org/chromium/mojo/shell/Bootstrap.java" ]
216     deps = [
217       "//base:base_java",
218     ]
220     dex_path = "$target_out_dir/bootstrap_java.dex.jar"
221   }
223   shared_library("bootstrap") {
224     sources = [
225       "android/bootstrap.cc",
226     ]
227     deps = [
228       ":jni_headers",
229       ":lib",
230       ":run_android_application_function",
231       "//base",
232     ]
233   }
235   # Shared header between the bootstrap and the main shell .so.
236   source_set("run_android_application_function") {
237     sources = [
238       "android/run_android_application_function.h",
239     ]
241     deps = [
242       "//base",
243     ]
244   }
246   android_library("java") {
247     java_files = [
248       "android/apk/src/org/chromium/mojo/shell/AndroidHandler.java",
249       "android/apk/src/org/chromium/mojo/shell/FileHelper.java",
250       "android/apk/src/org/chromium/mojo/shell/MojoShellActivity.java",
251       "android/apk/src/org/chromium/mojo/shell/MojoShellApplication.java",
252       "android/apk/src/org/chromium/mojo/shell/ShellMain.java",
253     ]
255     deps = [
256       "//base:base_java",
257     ]
258   }
260   android_resources("resources") {
261     resource_dirs = [ "android/apk/res" ]
262     custom_package = "org.chromium.mojo.shell"
263   }
265   mojo_runner_assets_dir = "$root_build_dir/mojo_runner_assets"
266   mojo_runner_test_assets_dir = "$root_build_dir/mojo_runner_test_assets"
268   copy_ex("copy_mojo_runner_assets") {
269     clear_dir = true
270     dest = mojo_runner_assets_dir
271     sources = [
272       "$root_out_dir/lib.stripped/libbootstrap.so",
273       "$root_out_dir/network_service.mojo",
274       "$root_out_dir/obj/mojo/runner/bootstrap_java.dex.jar",
275     ]
276   }
278   copy("copy_mojo_runner") {
279     sources = [
280       "$root_out_dir/exe.stripped/mojo_runner",
281     ]
282     outputs = [
283       "$root_out_dir/lib.stripped/libmojo_runner.so",
284     ]
285   }
287   copy_ex("copy_mojo_runner_test_assets") {
288     clear_dir = true
289     dest = mojo_runner_test_assets_dir
290     sources = [
291       "$root_out_dir/test_app.mojo",
292       "$root_out_dir/test_request_tracker_app.mojo",
293     ]
294   }
296   android_apk("mojo_runner_apk") {
297     apk_name = "MojoRunner"
299     android_manifest = "android/apk/AndroidManifest.xml"
301     native_libs = [ "libmojo_runner.so" ]
303     asset_location = mojo_runner_assets_dir
305     deps = [
306       ":copy_mojo_runner",
307       ":copy_mojo_runner_assets",
308       ":java",
309       ":resources",
310       "//base:base_java",
311       "//components/native_viewport:native_viewport_java",
312       "//third_party/android_tools:google_play_services_default_resources",
313     ]
314   }
316   android_library("mojo_runner_tests_java") {
317     java_files =
318         [ "android/tests/src/org/chromium/mojo/shell/ShellTestBase.java" ]
320     deps = [
321       ":java",
322       "//base:base_java",
323     ]
324   }
327 mojom("child_process_bindings") {
328   sources = [
329     "child_process.mojom",
330   ]
332   deps = [
333     "//third_party/mojo/src/mojo/public/interfaces/application",
334   ]
337 test("tests") {
338   output_name = "mojo_runner_unittests"
339   sources = [
340     "child_process_host_unittest.cc",
341     "data_pipe_peek_unittest.cc",
342     "in_process_native_runner_unittest.cc",
343     "native_runner_unittest.cc",
344     "shell_test_base.cc",
345     "shell_test_base.h",
346     "shell_test_base_android.cc",
347     "shell_test_base_unittest.cc",
348     "shell_test_main.cc",
349     "url_resolver_unittest.cc",
350   ]
352   deps = [
353     ":in_process_native_runner",
354     ":lib",
355     "//base",
356     "//base:i18n",
357     "//base/test:test_support",
358     "//mojo/common",
359     "//mojo/environment:chromium",
360     "//mojo/services/test_service:bindings",
361     "//mojo/shell",
362     "//mojo/util:filename_util",
363     "//testing/gtest",
364     "//third_party/mojo/src/mojo/edk/system",
365     "//third_party/mojo/src/mojo/public/cpp/bindings",
366     "//url",
367   ]
369   datadeps = [
370     "//mojo/services/test_service:test_app",
371     "//mojo/services/test_service:test_request_tracker_app",
372   ]
374   if (is_android) {
375     sources += [ "android/background_application_loader_unittest.cc" ]
377     deps += [ ":jni_headers" ]
379     apk_deps = [
380       ":copy_mojo_runner_test_assets",
381       ":mojo_runner_tests_java",
382     ]
384     apk_asset_location = mojo_runner_test_assets_dir
385   }
388 mojo_native_application("apptests") {
389   output_name = "runner_apptests"
391   testonly = true
393   sources = [
394     # TODO(jam): needs http_server service.
395     #"shell_apptest.cc",
396   ]
398   deps = [
399     "//base",
400     "//mojo/application",
401     "//mojo/application:test_support",
402     "//mojo/common:common",
403     "//mojo/runner/test:bindings",
405     #"//mojo/services/http_server/public/cpp",
406     #"//mojo/services/http_server/public/interfaces",
407     "//mojo/services/network/public/interfaces",
409     "//third_party/mojo/src/mojo/public/cpp/bindings:callback",
410     "//third_party/mojo/src/mojo/public/cpp/environment",
411     "//third_party/mojo/src/mojo/public/cpp/system:system",
412   ]
414   #data_deps = [ "//services/http_server:http_server($default_toolchain)" ]