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)
23 import("//build/config/android/config.gni")
24 import("//build/config/android/rules.gni")
27 source_set("mojo_runner_lib") {
33 "//build/config/sanitizers:deps",
35 "//mojo/environment:chromium",
40 "desktop/launcher_process.cc",
41 "desktop/launcher_process.h",
44 deps += [ "//components/tracing:startup_tracing" ]
47 "android/context_init.h",
48 "android/library_loader.cc",
55 "//components/view_manager",
58 "//ui/platform_window/android",
63 executable("mojo_runner") {
70 "android/context_init.cc",
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" ]
78 deps += [ "//build/config/sanitizers:deps" ]
81 source_set("in_process_native_runner") {
83 "in_process_native_runner.cc",
84 "in_process_native_runner.h",
88 ":native_application_support",
101 "child_process_host.cc",
102 "child_process_host.h",
107 "out_of_process_native_runner.cc",
108 "out_of_process_native_runner.h",
109 "scoped_user_data_dir.cc",
110 "scoped_user_data_dir.h",
118 ":child_process_bindings",
119 ":in_process_native_runner",
120 ":native_application_support",
122 "//base/third_party/dynamic_annotations",
123 "//base:base_static",
124 "//components/devtools_service/public/cpp",
125 "//components/devtools_service/public/interfaces",
126 "//mojo/application/public/cpp",
127 "//mojo/common:tracing_impl",
128 "//mojo/util:filename_util",
129 "//third_party/mojo/src/mojo/edk/system",
130 "//mojo/services/network/public/interfaces",
132 "//mojo/services/tracing:bindings",
142 "//components/devtools_service",
143 "//mojo/services/tracing",
148 "android/android_handler.cc",
149 "android/android_handler.h",
150 "android/android_handler_loader.cc",
151 "android/android_handler_loader.h",
152 "android/background_application_loader.cc",
153 "android/background_application_loader.h",
154 "android/ui_application_loader_android.cc",
155 "android/ui_application_loader_android.h",
160 ":run_android_application_function",
161 "//components/view_manager/gles2",
162 "//components/view_manager/native_viewport",
163 "//mojo/application/public/cpp:content_handler",
167 # This target includes some files behind #ifdef OS... guards. Since gn is not
168 # smart enough to understand preprocess includes, it does complains about
169 # these includes when not using the build files for that OS. Suppress checking
170 # so we can enable checking for the rest of the targets in this file.
171 # TODO: Might be better to split the files with OS-specific includes out to a
172 # separate source_set so we can leave checking on for the rest of the target.
173 check_includes = false
176 source_set("native_application_support") {
178 "native_application_support.cc",
179 "native_application_support.h",
180 "platform_handle_impl.cc",
184 "//third_party/mojo/src/mojo/public/cpp/bindings",
190 "//mojo/platform_handle:defs",
194 # This target has to include the public thunk headers, which generally
195 # shouldn't be included without picking an implementation. We are providing
196 # the implementation but the thunk header target cannot declare that we are
197 # permitted to include it since it's in the public SDK and we are not.
198 # Suppress include checking so we can still check the rest of the targets in
200 check_includes = false
203 source_set("switches") {
215 generate_jni("jni_headers") {
217 "android/apk/src/org/chromium/mojo/shell/AndroidHandler.java",
218 "android/apk/src/org/chromium/mojo/shell/Bootstrap.java",
219 "android/apk/src/org/chromium/mojo/shell/ShellMain.java",
220 "android/tests/src/org/chromium/mojo/shell/ShellTestBase.java",
222 jni_package = "mojo/shell"
225 android_library("bootstrap_java") {
226 java_files = [ "android/apk/src/org/chromium/mojo/shell/Bootstrap.java" ]
232 dex_path = "$target_out_dir/bootstrap_java.dex.jar"
235 shared_library("bootstrap") {
237 "android/bootstrap.cc",
242 ":run_android_application_function",
247 # Shared header between the bootstrap and the main shell .so.
248 source_set("run_android_application_function") {
250 "android/run_android_application_function.h",
258 android_library("java") {
260 "android/apk/src/org/chromium/mojo/shell/AndroidHandler.java",
261 "android/apk/src/org/chromium/mojo/shell/FileHelper.java",
262 "android/apk/src/org/chromium/mojo/shell/MojoShellActivity.java",
263 "android/apk/src/org/chromium/mojo/shell/MojoShellApplication.java",
264 "android/apk/src/org/chromium/mojo/shell/ShellMain.java",
273 android_resources("resources") {
274 resource_dirs = [ "android/apk/res" ]
275 custom_package = "org.chromium.mojo.shell"
278 mojo_runner_test_assets_dir = "$root_build_dir/mojo_runner_test_assets"
279 mojo_runner_apptests_assets_dir =
280 "$root_build_dir/mojo_runner_apptests_assets"
282 copy_ex("copy_mojo_runner_apptests_assets") {
285 dest = mojo_runner_apptests_assets_dir
290 "//components/clipboard:apptests",
291 "//components/resource_provider:apptests",
292 "//components/view_manager:apptests",
293 "//mojo/services/network:apptests",
297 "$root_out_dir/lib.stripped/libbootstrap$android_product_extension",
298 "$root_out_dir/obj/mojo/runner/bootstrap_java.dex.jar",
303 "clipboard_apptests",
305 "resource_provider_apptests",
306 "view_manager_apptests",
308 "network_service_apptests",
312 foreach(path, apptest_outputs) {
314 [ "--files=" + rebase_path("$root_out_dir/$path", root_build_dir) ]
318 generate_mojo_shell_assets_list("build_mojo_runner_apptests_assets") {
321 ":copy_mojo_runner_apptests_assets",
323 dir = mojo_runner_apptests_assets_dir
326 copy("copy_mojo_runner") {
328 "$root_out_dir/exe.stripped/mojo_runner",
331 "$root_out_dir/lib.stripped/libmojo_runner$android_product_extension",
338 copy_ex("copy_mojo_runner_test_assets") {
341 dest = mojo_runner_test_assets_dir
343 "//mojo/services/test_service:test_app",
344 "//mojo/services/test_service:test_request_tracker_app",
347 # Directories can't be specified as sources so pass manually to the script.
349 "--files=" + rebase_path("$root_out_dir/test_app", root_build_dir),
351 rebase_path("$root_out_dir/test_request_tracker_app", root_build_dir),
355 android_apk("mojo_runner_apptests_apk") {
357 apk_name = "MojoRunnerApptests"
358 android_manifest = "android/apk/AndroidManifest.xml"
359 native_libs = [ "libmojo_runner$android_product_extension" ]
360 asset_location = mojo_runner_apptests_assets_dir
363 ":build_mojo_runner_apptests_assets",
368 "//third_party/android_tools:google_play_services_default_resources",
369 "//ui/platform_window/android:platform_window_java",
373 generate_mojo_shell_assets_list("build_mojo_runner_test_assets") {
376 ":copy_mojo_runner_test_assets",
378 dir = mojo_runner_test_assets_dir
381 android_library("mojo_runner_tests_java") {
383 [ "android/tests/src/org/chromium/mojo/shell/ShellTestBase.java" ]
392 mojom("child_process_bindings") {
394 "child_process.mojom",
398 "//mojo/application/public/interfaces",
401 import_dirs = [ "//mojo/services" ]
404 test("mojo_runner_unittests") {
406 "child_process_host_unittest.cc",
407 "data_pipe_peek_unittest.cc",
408 "in_process_native_runner_unittest.cc",
409 "native_runner_unittest.cc",
410 "shell_test_base.cc",
412 "shell_test_base_android.cc",
413 "shell_test_base_unittest.cc",
414 "shell_test_main.cc",
415 "url_resolver_unittest.cc",
419 ":in_process_native_runner",
423 "//base/test:test_support",
425 "//mojo/environment:chromium",
426 "//mojo/services/test_service:bindings",
428 "//mojo/util:filename_util",
430 "//third_party/mojo/src/mojo/edk/system",
431 "//third_party/mojo/src/mojo/public/cpp/bindings",
436 "//mojo/services/test_service:test_app",
437 "//mojo/services/test_service:test_request_tracker_app",
441 sources += [ "android/background_application_loader_unittest.cc" ]
443 deps += [ ":jni_headers" ]
446 ":build_mojo_runner_test_assets",
447 ":mojo_runner_tests_java",
450 apk_asset_location = mojo_runner_test_assets_dir
454 mojo_native_application("apptests") {
455 output_name = "runner_apptests"
460 # TODO(jam): needs http_server service. http://crbug.com/479316
466 "//mojo/application/public/cpp:test_support",
467 "//mojo/runner/test:bindings",
468 "//mojo/services/network/public/interfaces",
469 "//third_party/mojo/src/mojo/public/cpp/bindings:callback",