[sql] Remove _HAS_EXCEPTIONS=0 from build info.
[chromium-blink-merge.git] / mojo / runner / BUILD.gn
blob1744441344426cd82f0774ef0838db7b8e2af614
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("//mojo/generate_mojo_shell_assets_list.gni")
6 import("//mojo/public/mojo_application.gni")
7 import("//testing/test.gni")
8 import("//third_party/mojo/src/mojo/public/tools/bindings/mojom.gni")
10 # We don't support building in the component build since mojo apps are
11 # inherently components.
12 assert(!is_component_build)
14 group("runner") {
15   testonly = true
17   deps = [
18     ":mojo_runner",
19   ]
22 if (is_android) {
23   import("//build/config/android/config.gni")
24   import("//build/config/android/rules.gni")
27 source_set("mojo_runner_lib") {
28   sources = []
30   deps = [
31     ":lib",
32     "//base",
33     "//build/config/sanitizers:deps",
34     "//mojo/common",
35     "//mojo/environment:chromium",
36   ]
38   if (!is_android) {
39     sources += [
40       "desktop/launcher_process.cc",
41       "desktop/launcher_process.h",
42       "desktop/main.cc",
43     ]
44     deps += [ "//components/tracing:startup_tracing" ]
45   } else {
46     sources += [
47       "android/context_init.h",
48       "android/library_loader.cc",
49       "android/main.cc",
50       "android/main.h",
51     ]
53     deps += [
54       ":jni_headers",
55       "//components/view_manager",
56       "//mojo/shell",
57       "//ui/gl",
58       "//ui/platform_window/android",
59     ]
60   }
63 executable("mojo_runner") {
64   deps = [
65     ":mojo_runner_lib",
66   ]
68   if (is_android) {
69     sources = [
70       "android/context_init.cc",
71     ]
73     # On android, the executable is also the native library used by the apk.
74     # It means dynamic symbols must be preserved and exported.
75     ldflags = [ "-Wl,--export-dynamic" ]
76   }
78   deps += [ "//build/config/sanitizers:deps" ]
81 source_set("in_process_native_runner") {
82   sources = [
83     "in_process_native_runner.cc",
84     "in_process_native_runner.h",
85   ]
87   public_deps = [
88     ":native_application_support",
89     "//mojo/shell",
90   ]
92   deps = [
93     "//base",
94   ]
97 source_set("lib") {
98   sources = [
99     "about_fetcher.cc",
100     "about_fetcher.h",
101     "child_process.cc",
102     "child_process.h",
103     "child_process_host.cc",
104     "child_process_host.h",
105     "context.cc",
106     "context.h",
107     "init.cc",
108     "init.h",
109     "out_of_process_native_runner.cc",
110     "out_of_process_native_runner.h",
111     "scoped_user_data_dir.cc",
112     "scoped_user_data_dir.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/cpp",
127     "//components/devtools_service/public/interfaces",
128     "//mojo/application/public/cpp",
129     "//mojo/common:tracing_impl",
130     "//mojo/util:filename_util",
131     "//third_party/mojo/src/mojo/edk/system",
132     "//mojo/services/network/public/interfaces",
133     "//mojo/shell",
134     "//mojo/services/tracing:bindings",
135     "//ui/gl",
136     "//url",
137   ]
139   if (is_linux && !is_android) {
140     sources += [
141       "linux_sandbox.cc",
142       "linux_sandbox.h",
143     ]
145     deps += [
146       "//sandbox/linux:sandbox",
147       "//sandbox/linux:sandbox_services",
148     ]
149   }
151   public_deps = [
152     ":switches",
153   ]
155   data_deps = [
156     "//components/devtools_service",
157     "//mojo/services/tracing",
158   ]
160   if (is_android) {
161     sources += [
162       "android/android_handler.cc",
163       "android/android_handler.h",
164       "android/android_handler_loader.cc",
165       "android/android_handler_loader.h",
166       "android/background_application_loader.cc",
167       "android/background_application_loader.h",
168       "android/ui_application_loader_android.cc",
169       "android/ui_application_loader_android.h",
170     ]
172     deps += [
173       ":jni_headers",
174       ":run_android_application_function",
175       "//components/view_manager/gles2",
176       "//components/view_manager/native_viewport",
177       "//mojo/application/public/cpp:content_handler",
178     ]
179   }
181   # This target includes some files behind #ifdef OS... guards. Since gn is not
182   # smart enough to understand preprocess includes, it does complains about
183   # these includes when not using the build files for that OS. Suppress checking
184   # so we can enable checking for the rest of the targets in this file.
185   # TODO: Might be better to split the files with OS-specific includes out to a
186   # separate source_set so we can leave checking on for the rest of the target.
187   check_includes = false
190 source_set("native_application_support") {
191   sources = [
192     "native_application_support.cc",
193     "native_application_support.h",
194     "platform_handle_impl.cc",
195   ]
197   public_deps = [
198     "//third_party/mojo/src/mojo/public/cpp/bindings",
199   ]
201   deps = [
202     "//base",
203     "//mojo/gles2",
204     "//mojo/platform_handle:defs",
205     "//mojo/shell",
206   ]
208   # This target has to include the public thunk headers, which generally
209   # shouldn't be included without picking an implementation. We are providing
210   # the implementation but the thunk header target cannot declare that we are
211   # permitted to include it since it's in the public SDK and we are not.
212   # Suppress include checking so we can still check the rest of the targets in
213   # this file.
214   check_includes = false
217 source_set("switches") {
218   sources = [
219     "switches.cc",
220     "switches.h",
221   ]
223   deps = [
224     "//base",
225   ]
228 if (is_android) {
229   generate_jni("jni_headers") {
230     sources = [
231       "android/apk/src/org/chromium/mojo/shell/AndroidHandler.java",
232       "android/apk/src/org/chromium/mojo/shell/Bootstrap.java",
233       "android/apk/src/org/chromium/mojo/shell/ShellMain.java",
234       "android/tests/src/org/chromium/mojo/shell/ShellTestBase.java",
235     ]
236     jni_package = "mojo/shell"
237   }
239   android_library("bootstrap_java") {
240     java_files = [ "android/apk/src/org/chromium/mojo/shell/Bootstrap.java" ]
242     deps = [
243       "//base:base_java",
244     ]
246     dex_path = "$target_out_dir/bootstrap_java.dex.jar"
247   }
249   shared_library("bootstrap") {
250     sources = [
251       "android/bootstrap.cc",
252     ]
253     deps = [
254       ":jni_headers",
255       ":lib",
256       ":run_android_application_function",
257       "//base",
258     ]
259   }
261   # Shared header between the bootstrap and the main shell .so.
262   source_set("run_android_application_function") {
263     sources = [
264       "android/run_android_application_function.h",
265     ]
267     deps = [
268       "//base",
269     ]
270   }
272   android_library("java") {
273     java_files = [
274       "android/apk/src/org/chromium/mojo/shell/AndroidHandler.java",
275       "android/apk/src/org/chromium/mojo/shell/FileHelper.java",
276       "android/apk/src/org/chromium/mojo/shell/MojoShellActivity.java",
277       "android/apk/src/org/chromium/mojo/shell/MojoShellApplication.java",
278       "android/apk/src/org/chromium/mojo/shell/ShellMain.java",
279     ]
281     deps = [
282       ":resources",
283       "//base:base_java",
284     ]
285   }
287   android_resources("resources") {
288     resource_dirs = [ "android/apk/res" ]
289     custom_package = "org.chromium.mojo.shell"
290   }
292   mojo_runner_test_assets_dir = "$root_build_dir/mojo_runner_test_assets"
293   mojo_runner_apptests_assets_dir =
294       "$root_build_dir/mojo_runner_apptests_assets"
296   copy_ex("copy_mojo_runner_apptests_assets") {
297     testonly = true
298     clear_dir = true
299     dest = mojo_runner_apptests_assets_dir
301     deps = [
302       ":bootstrap",
303       ":bootstrap_java",
304       "//components/clipboard:apptests",
305       "//components/resource_provider:apptests",
306       "//components/view_manager:apptests",
307       "//mojo/services/network:apptests",
308     ]
310     sources = [
311       "$root_out_dir/lib.stripped/libbootstrap$android_product_extension",
312       "$root_out_dir/obj/mojo/runner/bootstrap_java.dex.jar",
313     ]
315     apptest_outputs = [
316       "clipboard",
317       "clipboard_apptests",
318       "resource_provider",
319       "resource_provider_apptests",
320       "view_manager_apptests",
321       "network_service",
322       "network_service_apptests",
323     ]
325     args = []
326     foreach(path, apptest_outputs) {
327       args +=
328           [ "--files=" + rebase_path("$root_out_dir/$path", root_build_dir) ]
329     }
330   }
332   generate_mojo_shell_assets_list("build_mojo_runner_apptests_assets") {
333     testonly = true
334     deps = [
335       ":copy_mojo_runner_apptests_assets",
336     ]
337     dir = mojo_runner_apptests_assets_dir
338   }
340   copy("copy_mojo_runner") {
341     sources = [
342       "$root_out_dir/exe.stripped/mojo_runner",
343     ]
344     outputs = [
345       "$root_out_dir/lib.stripped/libmojo_runner$android_product_extension",
346     ]
347     deps = [
348       ":mojo_runner",
349     ]
350   }
352   copy_ex("copy_mojo_runner_test_assets") {
353     testonly = true
354     clear_dir = true
355     dest = mojo_runner_test_assets_dir
356     deps = [
357       "//mojo/services/test_service:test_app",
358       "//mojo/services/test_service:test_request_tracker_app",
359     ]
361     # Directories can't be specified as sources so pass manually to the script.
362     args = [
363       "--files=" + rebase_path("$root_out_dir/test_app", root_build_dir),
364       "--files=" +
365           rebase_path("$root_out_dir/test_request_tracker_app", root_build_dir),
366     ]
367   }
369   android_apk("mojo_runner_apptests_apk") {
370     testonly = true
371     apk_name = "MojoRunnerApptests"
372     android_manifest = "android/apk/AndroidManifest.xml"
373     native_libs = [ "libmojo_runner$android_product_extension" ]
374     asset_location = mojo_runner_apptests_assets_dir
376     deps = [
377       ":build_mojo_runner_apptests_assets",
378       ":copy_mojo_runner",
379       ":java",
380       ":resources",
381       "//base:base_java",
382       "//third_party/android_tools:google_play_services_default_resources",
383       "//ui/platform_window/android:platform_window_java",
384     ]
385   }
387   generate_mojo_shell_assets_list("build_mojo_runner_test_assets") {
388     testonly = true
389     deps = [
390       ":copy_mojo_runner_test_assets",
391     ]
392     dir = mojo_runner_test_assets_dir
393   }
395   android_library("mojo_runner_tests_java") {
396     java_files =
397         [ "android/tests/src/org/chromium/mojo/shell/ShellTestBase.java" ]
399     deps = [
400       ":java",
401       "//base:base_java",
402     ]
403   }
406 mojom("child_process_bindings") {
407   sources = [
408     "child_process.mojom",
409   ]
411   deps = [
412     "//mojo/application/public/interfaces",
413   ]
415   import_dirs = [ "//mojo/services" ]
418 test("mojo_runner_unittests") {
419   sources = [
420     "about_fetcher_unittest.cc",
421     "child_process_host_unittest.cc",
422     "data_pipe_peek_unittest.cc",
423     "in_process_native_runner_unittest.cc",
424     "native_runner_unittest.cc",
425     "shell_test_base.cc",
426     "shell_test_base.h",
427     "shell_test_base_android.cc",
428     "shell_test_base_unittest.cc",
429     "shell_test_main.cc",
430     "url_resolver_unittest.cc",
431   ]
433   deps = [
434     ":in_process_native_runner",
435     ":lib",
436     "//base",
437     "//base:i18n",
438     "//base/test:test_support",
439     "//mojo/application/public/cpp",
440     "//mojo/common",
441     "//mojo/environment:chromium",
442     "//mojo/services/test_service:bindings",
443     "//mojo/shell",
444     "//mojo/util:filename_util",
445     "//testing/gtest",
446     "//third_party/mojo/src/mojo/edk/system",
447     "//third_party/mojo/src/mojo/public/cpp/bindings",
448     "//url",
449   ]
451   data_deps = [
452     "//mojo/services/test_service:test_app",
453     "//mojo/services/test_service:test_request_tracker_app",
454   ]
456   if (is_android) {
457     sources += [ "android/background_application_loader_unittest.cc" ]
459     deps += [ ":jni_headers" ]
461     apk_deps = [
462       ":build_mojo_runner_test_assets",
463       ":mojo_runner_tests_java",
464     ]
466     apk_asset_location = mojo_runner_test_assets_dir
467   }
470 mojo_native_application("apptests") {
471   output_name = "runner_apptests"
473   testonly = true
475   sources = [
476     # TODO(jam): needs http_server service. http://crbug.com/479316
477     #"shell_apptest.cc",
478   ]
480   deps = [
481     "//base",
482     "//mojo/application/public/cpp:test_support",
483     "//mojo/runner/test:bindings",
484     "//mojo/services/network/public/interfaces",
485     "//third_party/mojo/src/mojo/public/cpp/bindings:callback",
486   ]