Mandoline: Merge Surfaces and Views apps
[chromium-blink-merge.git] / mojo / runner / BUILD.gn
blobf27543209545f1e439af6bd97320d9d2ab746618
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     "//mojo/message_pump",
37   ]
39   if (!is_android) {
40     sources += [
41       "desktop/launcher_process.cc",
42       "desktop/launcher_process.h",
43       "desktop/main.cc",
44     ]
45     deps += [ "//components/tracing:startup_tracing" ]
46   } else {
47     sources += [
48       "android/context_init.h",
49       "android/library_loader.cc",
50       "android/main.cc",
51       "android/main.h",
52     ]
54     deps += [
55       ":jni_headers",
56       "//components/view_manager",
57       "//mojo/shell",
58       "//ui/gl",
59       "//ui/platform_window/android",
60     ]
61   }
64 executable("mojo_runner") {
65   deps = [
66     ":mojo_runner_lib",
67   ]
69   if (is_android) {
70     sources = [
71       "android/context_init.cc",
72     ]
74     # On android, the executable is also the native library used by the apk.
75     # It means dynamic symbols must be preserved and exported.
76     ldflags = [ "-Wl,--export-dynamic" ]
77   }
79   deps += [ "//build/config/sanitizers:deps" ]
82 source_set("in_process_native_runner") {
83   sources = [
84     "in_process_native_runner.cc",
85     "in_process_native_runner.h",
86   ]
88   public_deps = [
89     ":native_application_support",
90     "//mojo/shell",
91   ]
93   deps = [
94     "//base",
95   ]
98 source_set("lib") {
99   sources = [
100     "about_fetcher.cc",
101     "about_fetcher.h",
102     "child_process.cc",
103     "child_process.h",
104     "child_process_host.cc",
105     "child_process_host.h",
106     "context.cc",
107     "context.h",
108     "init.cc",
109     "init.h",
110     "out_of_process_native_runner.cc",
111     "out_of_process_native_runner.h",
112     "scoped_user_data_dir.cc",
113     "scoped_user_data_dir.h",
114     "task_runners.cc",
115     "task_runners.h",
116     "url_resolver.cc",
117     "url_resolver.h",
118   ]
120   deps = [
121     ":child_process_bindings",
122     ":in_process_native_runner",
123     ":native_application_support",
124     "//base",
125     "//base/third_party/dynamic_annotations",
126     "//base:base_static",
127     "//components/devtools_service/public/cpp",
128     "//components/devtools_service/public/interfaces",
129     "//mojo/application/public/cpp",
130     "//mojo/common:tracing_impl",
131     "//mojo/message_pump",
132     "//mojo/services/network/public/interfaces",
133     "//mojo/services/tracing/public/cpp",
134     "//mojo/services/tracing/public/interfaces",
135     "//mojo/shell",
136     "//mojo/util:filename_util",
137     "//third_party/mojo/src/mojo/edk/system",
138     "//ui/gl",
139     "//url",
140   ]
142   if (is_linux && !is_android) {
143     sources += [
144       "linux_sandbox.cc",
145       "linux_sandbox.h",
146     ]
148     deps += [
149       "//sandbox/linux:sandbox",
150       "//sandbox/linux:sandbox_services",
151     ]
152   }
154   public_deps = [
155     ":switches",
156   ]
158   data_deps = [
159     "//components/devtools_service",
160     "//mojo/services/tracing",
161   ]
163   if (is_android) {
164     sources += [
165       "android/android_handler.cc",
166       "android/android_handler.h",
167       "android/android_handler_loader.cc",
168       "android/android_handler_loader.h",
169       "android/background_application_loader.cc",
170       "android/background_application_loader.h",
171       "android/ui_application_loader_android.cc",
172       "android/ui_application_loader_android.h",
173     ]
175     deps += [
176       ":jni_headers",
177       ":run_android_application_function",
178       "//components/view_manager/gles2",
179       "//mojo/application/public/cpp:content_handler",
180     ]
181   }
183   # This target includes some files behind #ifdef OS... guards. Since gn is not
184   # smart enough to understand preprocess includes, it does complains about
185   # these includes when not using the build files for that OS. Suppress checking
186   # so we can enable checking for the rest of the targets in this file.
187   # TODO: Might be better to split the files with OS-specific includes out to a
188   # separate source_set so we can leave checking on for the rest of the target.
189   check_includes = false
192 source_set("native_application_support") {
193   sources = [
194     "native_application_support.cc",
195     "native_application_support.h",
196     "platform_handle_impl.cc",
197   ]
199   public_deps = [
200     "//third_party/mojo/src/mojo/public/cpp/bindings",
201   ]
203   deps = [
204     "//base",
205     "//mojo/gles2",
206     "//mojo/platform_handle:defs",
207     "//mojo/shell",
208   ]
210   # This target has to include the public thunk headers, which generally
211   # shouldn't be included without picking an implementation. We are providing
212   # the implementation but the thunk header target cannot declare that we are
213   # permitted to include it since it's in the public SDK and we are not.
214   # Suppress include checking so we can still check the rest of the targets in
215   # this file.
216   check_includes = false
219 source_set("switches") {
220   sources = [
221     "switches.cc",
222     "switches.h",
223   ]
225   deps = [
226     "//base",
227   ]
230 if (is_android) {
231   generate_jni("jni_headers") {
232     sources = [
233       "android/apk/src/org/chromium/mojo/shell/AndroidHandler.java",
234       "android/apk/src/org/chromium/mojo/shell/Bootstrap.java",
235       "android/apk/src/org/chromium/mojo/shell/ShellMain.java",
236       "android/tests/src/org/chromium/mojo/shell/ShellTestBase.java",
237     ]
238     jni_package = "mojo/shell"
239   }
241   android_library("bootstrap_java") {
242     java_files = [ "android/apk/src/org/chromium/mojo/shell/Bootstrap.java" ]
244     deps = [
245       "//base:base_java",
246     ]
248     dex_path = "$target_out_dir/bootstrap_java.dex.jar"
249   }
251   shared_library("bootstrap") {
252     sources = [
253       "android/bootstrap.cc",
254     ]
255     deps = [
256       ":jni_headers",
257       ":lib",
258       ":run_android_application_function",
259       "//base",
260     ]
261   }
263   # Shared header between the bootstrap and the main shell .so.
264   source_set("run_android_application_function") {
265     sources = [
266       "android/run_android_application_function.h",
267     ]
269     deps = [
270       "//base",
271     ]
272   }
274   android_library("java") {
275     java_files = [
276       "android/apk/src/org/chromium/mojo/shell/AndroidHandler.java",
277       "android/apk/src/org/chromium/mojo/shell/FileHelper.java",
278       "android/apk/src/org/chromium/mojo/shell/MojoShellActivity.java",
279       "android/apk/src/org/chromium/mojo/shell/MojoShellApplication.java",
280       "android/apk/src/org/chromium/mojo/shell/ShellMain.java",
281     ]
283     deps = [
284       ":resources",
285       "//base:base_java",
286     ]
287   }
289   android_resources("resources") {
290     resource_dirs = [ "android/apk/res" ]
291     custom_package = "org.chromium.mojo.shell"
292   }
294   mojo_runner_test_assets_dir = "$root_build_dir/mojo_runner_test_assets"
295   mojo_runner_apptests_assets_dir =
296       "$root_build_dir/mojo_runner_apptests_assets"
298   copy_ex("copy_mojo_runner_apptests_assets") {
299     testonly = true
300     clear_dir = true
301     dest = mojo_runner_apptests_assets_dir
303     deps = [
304       ":bootstrap",
305       ":bootstrap_java",
306       "//components/clipboard:apptests",
307       "//components/resource_provider:apptests",
308       "//components/view_manager:apptests",
309       "//mojo/services/network:apptests",
310     ]
312     sources = [
313       "$root_out_dir/obj/mojo/runner/bootstrap_java.dex.jar",
314       "$root_shlib_dir/${shlib_prefix}bootstrap$shlib_extension",
315     ]
317     apptest_outputs = [
318       "clipboard",
319       "clipboard_apptests",
320       "resource_provider",
321       "resource_provider_apptests",
322       "view_manager_apptests",
323       "network_service",
324       "network_service_apptests",
325     ]
327     args = []
328     foreach(path, apptest_outputs) {
329       args +=
330           [ "--files=" + rebase_path("$root_out_dir/$path", root_build_dir) ]
331     }
332   }
334   generate_mojo_shell_assets_list("build_mojo_runner_apptests_assets") {
335     testonly = true
336     deps = [
337       ":copy_mojo_runner_apptests_assets",
338     ]
339     dir = mojo_runner_apptests_assets_dir
340   }
342   copy("copy_mojo_runner") {
343     sources = [
344       "$root_out_dir/mojo_runner",
345     ]
346     outputs = [
347       "$root_shlib_dir/${shlib_prefix}mojo_runner$shlib_extension",
348     ]
349     deps = [
350       ":mojo_runner",
351     ]
352   }
354   copy_ex("copy_mojo_runner_test_assets") {
355     testonly = true
356     clear_dir = true
357     dest = mojo_runner_test_assets_dir
358     deps = [
359       "//mojo/services/test_service:test_app",
360       "//mojo/services/test_service:test_request_tracker_app",
361     ]
363     # Directories can't be specified as sources so pass manually to the script.
364     args = [
365       "--files=" + rebase_path("$root_out_dir/test_app", root_build_dir),
366       "--files=" +
367           rebase_path("$root_out_dir/test_request_tracker_app", root_build_dir),
368     ]
369   }
371   android_apk("mojo_runner_apptests_apk") {
372     testonly = true
373     apk_name = "MojoRunnerApptests"
374     android_manifest = "android/apk/AndroidManifest.xml"
375     native_libs = [ "${shlib_prefix}mojo_runner$shlib_extension" ]
376     asset_location = mojo_runner_apptests_assets_dir
378     deps = [
379       ":build_mojo_runner_apptests_assets",
380       ":copy_mojo_runner",
381       ":java",
382       ":resources",
383       "//base:base_java",
384       "//ui/platform_window/android:platform_window_java",
385       google_play_services_resources,
386     ]
387   }
389   generate_mojo_shell_assets_list("build_mojo_runner_test_assets") {
390     testonly = true
391     deps = [
392       ":copy_mojo_runner_test_assets",
393     ]
394     dir = mojo_runner_test_assets_dir
395   }
397   android_library("mojo_runner_tests_java") {
398     java_files =
399         [ "android/tests/src/org/chromium/mojo/shell/ShellTestBase.java" ]
401     deps = [
402       ":java",
403       "//base:base_java",
404     ]
405   }
408 mojom("child_process_bindings") {
409   sources = [
410     "child_process.mojom",
411   ]
413   deps = [
414     "//mojo/application/public/interfaces",
415   ]
417   import_dirs = [ "//mojo/services" ]
420 test("mojo_runner_unittests") {
421   sources = [
422     "about_fetcher_unittest.cc",
423     "child_process_host_unittest.cc",
424     "data_pipe_peek_unittest.cc",
425     "in_process_native_runner_unittest.cc",
426     "native_runner_unittest.cc",
427     "shell_test_base.cc",
428     "shell_test_base.h",
429     "shell_test_base_android.cc",
430     "shell_test_base_unittest.cc",
431     "shell_test_main.cc",
432     "url_resolver_unittest.cc",
433   ]
435   deps = [
436     ":in_process_native_runner",
437     ":lib",
438     "//base",
439     "//base:i18n",
440     "//base/test:test_support",
441     "//mojo/application/public/cpp",
442     "//mojo/common",
443     "//mojo/environment:chromium",
444     "//mojo/message_pump",
445     "//mojo/services/test_service:bindings",
446     "//mojo/shell",
447     "//mojo/util:filename_util",
448     "//testing/gtest",
449     "//third_party/mojo/src/mojo/edk/system",
450     "//third_party/mojo/src/mojo/public/cpp/bindings",
451     "//url",
452   ]
454   data_deps = [
455     "//mojo/services/test_service:test_app",
456     "//mojo/services/test_service:test_request_tracker_app",
457   ]
459   if (is_android) {
460     sources += [ "android/background_application_loader_unittest.cc" ]
462     deps += [ ":jni_headers" ]
464     apk_deps = [
465       ":build_mojo_runner_test_assets",
466       ":mojo_runner_tests_java",
467     ]
469     apk_asset_location = mojo_runner_test_assets_dir
470   }
473 mojo_native_application("apptests") {
474   output_name = "runner_apptests"
476   testonly = true
478   sources = [
479     # TODO(jam): needs http_server service. http://crbug.com/479316
480     #"shell_apptest.cc",
481   ]
483   deps = [
484     "//base",
485     "//mojo/application/public/cpp:test_support",
486     "//mojo/runner/test:bindings",
487     "//mojo/services/network/public/interfaces",
488     "//third_party/mojo/src/mojo/public/cpp/bindings:callback",
489   ]