Roll src/third_party/skia 43315bb:4b195e5
[chromium-blink-merge.git] / mojo / runner / BUILD.gn
blob5e14a089b2d5f95f613b399e3890cff1e2e8cd83
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("//mojo/generate_mojo_shell_assets_list.gni")
7 import("//third_party/mojo/src/mojo/public/mojo.gni")
8 import("//third_party/mojo/src/mojo/public/mojo_application.gni")
9 import("//third_party/mojo/src/mojo/public/tools/bindings/mojom.gni")
10 import("//testing/test.gni")
12 # We don't support building in the component build since mojo apps are
13 # inherently components.
14 assert(!is_component_build)
16 group("runner") {
17   testonly = true
19   deps = [
20     ":mojo_runner",
21   ]
23   if (is_android) {
24     deps += [ ":mojo_runner_apk" ]
25   }
28 if (is_android) {
29   import("//build/config/android/config.gni")
30   import("//build/config/android/rules.gni")
33 source_set("mojo_runner_lib") {
34   sources = []
36   deps = [
37     ":lib",
38     "//base",
39     "//build/config/sanitizers:deps",
40     "//mojo/common",
41     "//mojo/environment:chromium",
42   ]
44   if (!is_android) {
45     sources += [
46       "desktop/launcher_process.cc",
47       "desktop/launcher_process.h",
48       "desktop/main.cc",
49     ]
50   } else {
51     sources += [
52       "android/context_init.h",
53       "android/library_loader.cc",
54       "android/main.cc",
55       "android/main.h",
56     ]
58     deps += [
59       ":jni_headers",
60       "//components/view_manager",
61       "//mojo/shell",
62       "//ui/gl",
63     ]
64   }
67 executable("mojo_runner") {
68   deps = [
69     ":mojo_runner_lib",
70   ]
72   if (is_android) {
73     sources = [
74       "android/context_init.cc",
75     ]
77     # On android, the executable is also the native library used by the apk.
78     # It means dynamic symbols must be preserved and exported.
79     ldflags = [ "-Wl,--export-dynamic" ]
80   }
82   deps += [ "//build/config/sanitizers:deps" ]
85 source_set("in_process_native_runner") {
86   sources = [
87     "in_process_native_runner.cc",
88     "in_process_native_runner.h",
89   ]
91   public_deps = [
92     ":native_application_support",
93     "//mojo/shell",
94   ]
96   deps = [
97     "//base",
98   ]
101 source_set("lib") {
102   sources = [
103     "child_process.cc",
104     "child_process.h",
105     "child_process_host.cc",
106     "child_process_host.h",
107     "context.cc",
108     "context.h",
109     "init.cc",
110     "init.h",
111     "out_of_process_native_runner.cc",
112     "out_of_process_native_runner.h",
113     "task_runners.cc",
114     "task_runners.h",
115     "url_resolver.cc",
116     "url_resolver.h",
117   ]
119   deps = [
120     ":child_process_bindings",
121     ":in_process_native_runner",
122     ":native_application_support",
123     "//base",
124     "//base/third_party/dynamic_annotations",
125     "//base:base_static",
126     "//components/devtools_service/public/interfaces",
127     "//mojo/application/public/cpp",
128     "//mojo/common:tracing_impl",
129     "//mojo/util:filename_util",
130     "//third_party/mojo/src/mojo/edk/system",
131     "//mojo/services/network/public/interfaces",
132     "//mojo/shell",
133     "//mojo/services/tracing:bindings",
134     "//ui/gl",
135     "//url",
136   ]
138   public_deps = [
139     ":switches",
140   ]
142   data_deps = [
143     "//components/devtools_service",
144     "//mojo/services/tracing",
145   ]
147   if (is_android) {
148     sources += [
149       "android/android_handler.cc",
150       "android/android_handler.h",
151       "android/android_handler_loader.cc",
152       "android/android_handler_loader.h",
153       "android/background_application_loader.cc",
154       "android/background_application_loader.h",
155       "android/ui_application_loader_android.cc",
156       "android/ui_application_loader_android.h",
157     ]
159     deps += [
160       ":jni_headers",
161       ":run_android_application_function",
162       "//components/view_manager/gles2",
163       "//components/view_manager/native_viewport",
164       "//mojo/application/public/cpp:content_handler",
165     ]
166   }
168   # This target includes some files behind #ifdef OS... guards. Since gn is not
169   # smart enough to understand preprocess includes, it does complains about
170   # these includes when not using the build files for that OS. Suppress checking
171   # so we can enable checking for the rest of the targets in this file.
172   # TODO: Might be better to split the files with OS-specific includes out to a
173   # separate source_set so we can leave checking on for the rest of the target.
174   check_includes = false
177 source_set("native_application_support") {
178   sources = [
179     "native_application_support.cc",
180     "native_application_support.h",
181     "platform_handle_impl.cc",
182   ]
184   public_deps = [
185     "//third_party/mojo/src/mojo/public/cpp/bindings",
186   ]
188   deps = [
189     "//base",
190     "//mojo/gles2",
191     "//mojo/platform_handle:defs",
192     "//mojo/shell",
193   ]
195   # This target has to include the public thunk headers, which generally
196   # shouldn't be included without picking an implementation. We are providing
197   # the implementation but the thunk header target cannot declare that we are
198   # permitted to include it since it's in the public SDK and we are not.
199   # Suppress include checking so we can still check the rest of the targets in
200   # this file.
201   check_includes = false
204 source_set("switches") {
205   sources = [
206     "switches.cc",
207     "switches.h",
208   ]
210   deps = [
211     "//base",
212   ]
215 if (is_android) {
216   generate_jni("jni_headers") {
217     sources = [
218       "android/apk/src/org/chromium/mojo/shell/AndroidHandler.java",
219       "android/apk/src/org/chromium/mojo/shell/Bootstrap.java",
220       "android/apk/src/org/chromium/mojo/shell/ShellMain.java",
221       "android/tests/src/org/chromium/mojo/shell/ShellTestBase.java",
222     ]
223     jni_package = "mojo/shell"
224   }
226   android_library("bootstrap_java") {
227     java_files = [ "android/apk/src/org/chromium/mojo/shell/Bootstrap.java" ]
229     deps = [
230       "//base:base_java",
231     ]
233     dex_path = "$target_out_dir/bootstrap_java.dex.jar"
234   }
236   shared_library("bootstrap") {
237     sources = [
238       "android/bootstrap.cc",
239     ]
240     deps = [
241       ":jni_headers",
242       ":lib",
243       ":run_android_application_function",
244       "//base",
245     ]
246   }
248   # Shared header between the bootstrap and the main shell .so.
249   source_set("run_android_application_function") {
250     sources = [
251       "android/run_android_application_function.h",
252     ]
254     deps = [
255       "//base",
256     ]
257   }
259   android_library("java") {
260     java_files = [
261       "android/apk/src/org/chromium/mojo/shell/AndroidHandler.java",
262       "android/apk/src/org/chromium/mojo/shell/FileHelper.java",
263       "android/apk/src/org/chromium/mojo/shell/MojoShellActivity.java",
264       "android/apk/src/org/chromium/mojo/shell/MojoShellApplication.java",
265       "android/apk/src/org/chromium/mojo/shell/ShellMain.java",
266     ]
268     deps = [
269       ":resources",
270       "//base:base_java",
271     ]
272   }
274   android_resources("resources") {
275     resource_dirs = [ "android/apk/res" ]
276     custom_package = "org.chromium.mojo.shell"
277   }
279   mojo_runner_assets_dir = "$root_build_dir/mojo_runner_assets"
280   mojo_runner_test_assets_dir = "$root_build_dir/mojo_runner_test_assets"
282   copy_ex("copy_mojo_runner_assets") {
283     clear_dir = true
284     dest = mojo_runner_assets_dir
285     deps = [
286       ":copy_mojo_runner",
287     ]
288     sources = [
289       "$root_out_dir/lib.stripped/libbootstrap.so",
290       "$root_out_dir/network_service.mojo",
291       "$root_out_dir/obj/mojo/runner/bootstrap_java.dex.jar",
292     ]
293   }
295   generate_mojo_shell_assets_list("build_mojo_runner_assets") {
296     deps = [
297       ":copy_mojo_runner_assets",
298     ]
299     dir = mojo_runner_assets_dir
300   }
302   copy("copy_mojo_runner") {
303     sources = [
304       "$root_out_dir/exe.stripped/mojo_runner",
305     ]
306     outputs = [
307       "$root_out_dir/lib.stripped/libmojo_runner.so",
308     ]
309   }
311   copy_ex("copy_mojo_runner_test_assets") {
312     clear_dir = true
313     dest = mojo_runner_test_assets_dir
314     sources = [
315       "$root_out_dir/test_app.mojo",
316       "$root_out_dir/test_request_tracker_app.mojo",
317     ]
318   }
320   android_apk("mojo_runner_apk") {
321     apk_name = "MojoRunner"
323     android_manifest = "android/apk/AndroidManifest.xml"
325     native_libs = [ "libmojo_runner.so" ]
327     asset_location = mojo_runner_assets_dir
329     deps = [
330       ":build_mojo_runner_assets",
331       ":java",
332       ":resources",
333       "//base:base_java",
334       "//components/view_manager:view_manager_java",
335       "//third_party/android_tools:google_play_services_default_resources",
336     ]
337   }
339   generate_mojo_shell_assets_list("build_mojo_runner_test_assets") {
340     deps = [
341       ":copy_mojo_runner_test_assets",
342     ]
343     dir = mojo_runner_test_assets_dir
344   }
346   android_library("mojo_runner_tests_java") {
347     java_files =
348         [ "android/tests/src/org/chromium/mojo/shell/ShellTestBase.java" ]
350     deps = [
351       ":java",
352       "//base:base_java",
353     ]
354   }
357 mojom("child_process_bindings") {
358   sources = [
359     "child_process.mojom",
360   ]
362   deps = [
363     "//mojo/application/public/interfaces",
364   ]
366   import_dirs = [ "//mojo/services" ]
369 test("tests") {
370   output_name = "mojo_runner_unittests"
371   sources = [
372     "child_process_host_unittest.cc",
373     "data_pipe_peek_unittest.cc",
374     "in_process_native_runner_unittest.cc",
375     "native_runner_unittest.cc",
376     "shell_test_base.cc",
377     "shell_test_base.h",
378     "shell_test_base_android.cc",
379     "shell_test_base_unittest.cc",
380     "shell_test_main.cc",
381     "url_resolver_unittest.cc",
382   ]
384   deps = [
385     ":in_process_native_runner",
386     ":lib",
387     "//base",
388     "//base:i18n",
389     "//base/test:test_support",
390     "//mojo/common",
391     "//mojo/environment:chromium",
392     "//mojo/services/test_service:bindings",
393     "//mojo/shell",
394     "//mojo/util:filename_util",
395     "//testing/gtest",
396     "//third_party/mojo/src/mojo/edk/system",
397     "//third_party/mojo/src/mojo/public/cpp/bindings",
398     "//url",
399   ]
401   datadeps = [
402     "//mojo/services/test_service:test_app",
403     "//mojo/services/test_service:test_request_tracker_app",
404   ]
406   if (is_android) {
407     sources += [ "android/background_application_loader_unittest.cc" ]
409     deps += [ ":jni_headers" ]
411     apk_deps = [
412       ":build_mojo_runner_test_assets",
413       ":mojo_runner_tests_java",
414     ]
416     apk_asset_location = mojo_runner_test_assets_dir
417   }
420 mojo_native_application("apptests") {
421   output_name = "runner_apptests"
423   testonly = true
425   sources = [
426     # TODO(jam): needs http_server service.
427     #"shell_apptest.cc",
428   ]
430   deps = [
431     "//base",
432     "//mojo/application/public/cpp:test_support",
433     "//mojo/runner/test:bindings",
434     "//mojo/services/network/public/interfaces",
435     "//third_party/mojo/src/mojo/public/cpp/bindings:callback",
436   ]