Roll src/third_party/WebKit eac3800:0237a66 (svn 202606:202607)
[chromium-blink-merge.git] / mojo / runner / BUILD.gn
blob558b3274f142f7ca1ee74863c596105e28fecc24
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/mus",
57       "//mojo/shell",
58       "//ui/gl",
59       "//ui/platform_window/android",
60     ]
61   }
64 executable("mojo_runner") {
65   deps = [
66     ":mojo_runner_lib",
67     "//build/config/sanitizers:deps",
68   ]
70   if (is_android) {
71     sources = [
72       "android/context_init.cc",
73     ]
75     # On android, the executable is also the native library used by the apk.
76     # It means dynamic symbols must be preserved and exported.
77     ldflags = [ "-Wl,--export-dynamic" ]
78   }
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     "child_process.cc",
100     "child_process.h",
101     "child_process_host.cc",
102     "child_process_host.h",
103     "context.cc",
104     "context.h",
105     "init.cc",
106     "init.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",
111     "task_runners.cc",
112     "task_runners.h",
113   ]
115   deps = [
116     ":child_process_bindings",
117     ":in_process_native_runner",
118     ":native_application_support",
119     "//base",
120     "//base/third_party/dynamic_annotations",
121     "//base:base_static",
122     "//components/devtools_service/public/cpp",
123     "//components/devtools_service/public/interfaces",
124     "//mojo/application/public/cpp",
125     "//mojo/common:tracing_impl",
126     "//mojo/message_pump",
127     "//mojo/package_manager",
128     "//mojo/services/network/public/interfaces",
129     "//mojo/services/tracing/public/cpp",
130     "//mojo/services/tracing/public/interfaces",
131     "//mojo/shell",
132     "//mojo/util:filename_util",
133     "//third_party/mojo/src/mojo/edk/system",
134     "//ui/gl",
135     "//url",
136   ]
138   if (is_linux && !is_android) {
139     sources += [
140       "linux_sandbox.cc",
141       "linux_sandbox.h",
142     ]
144     deps += [
145       "//sandbox/linux:sandbox",
146       "//sandbox/linux:sandbox_services",
147     ]
148   }
150   public_deps = [
151     ":switches",
152   ]
154   data_deps = [
155     "//components/devtools_service",
156     "//mojo/services/tracing",
157   ]
159   if (is_android) {
160     sources += [
161       "android/android_handler.cc",
162       "android/android_handler.h",
163       "android/android_handler_loader.cc",
164       "android/android_handler_loader.h",
165       "android/background_application_loader.cc",
166       "android/background_application_loader.h",
167       "android/ui_application_loader_android.cc",
168       "android/ui_application_loader_android.h",
169     ]
171     deps += [
172       ":jni_headers",
173       ":run_android_application_function",
174       "//components/mus/gles2",
175       "//mojo/application/public/cpp:content_handler",
176     ]
177   }
179   # This target includes some files behind #ifdef OS... guards. Since gn is not
180   # smart enough to understand preprocess includes, it does complains about
181   # these includes when not using the build files for that OS. Suppress checking
182   # so we can enable checking for the rest of the targets in this file.
183   # TODO: Might be better to split the files with OS-specific includes out to a
184   # separate source_set so we can leave checking on for the rest of the target.
185   check_includes = false
188 source_set("native_application_support") {
189   sources = [
190     "native_application_support.cc",
191     "native_application_support.h",
192     "platform_handle_impl.cc",
193   ]
195   public_deps = [
196     "//third_party/mojo/src/mojo/public/cpp/bindings",
197   ]
199   deps = [
200     "//base",
201     "//mojo/gles2",
202     "//mojo/platform_handle:defs",
203     "//mojo/shell",
204   ]
206   # This target has to include the public thunk headers, which generally
207   # shouldn't be included without picking an implementation. We are providing
208   # the implementation but the thunk header target cannot declare that we are
209   # permitted to include it since it's in the public SDK and we are not.
210   # Suppress include checking so we can still check the rest of the targets in
211   # this file.
212   check_includes = false
215 source_set("switches") {
216   sources = [
217     "switches.cc",
218     "switches.h",
219   ]
221   deps = [
222     "//base",
223   ]
226 if (is_android) {
227   generate_jni("jni_headers") {
228     sources = [
229       "android/apk/src/org/chromium/mojo/shell/AndroidHandler.java",
230       "android/apk/src/org/chromium/mojo/shell/Bootstrap.java",
231       "android/apk/src/org/chromium/mojo/shell/ShellMain.java",
232       "android/tests/src/org/chromium/mojo/shell/ShellTestBase.java",
233     ]
234     jni_package = "mojo/shell"
235   }
237   android_library("bootstrap_java") {
238     java_files = [ "android/apk/src/org/chromium/mojo/shell/Bootstrap.java" ]
240     deps = [
241       "//base:base_java",
242     ]
244     dex_path = "$target_out_dir/bootstrap_java.dex.jar"
245   }
247   shared_library("bootstrap") {
248     sources = [
249       "android/bootstrap.cc",
250     ]
251     deps = [
252       ":jni_headers",
253       ":lib",
254       ":run_android_application_function",
255       "//base",
256       "//build/config/sanitizers:deps",
257     ]
258   }
260   # Shared header between the bootstrap and the main shell .so.
261   source_set("run_android_application_function") {
262     sources = [
263       "android/run_android_application_function.h",
264     ]
266     deps = [
267       "//base",
268     ]
269   }
271   android_library("java") {
272     java_files = [
273       "android/apk/src/org/chromium/mojo/shell/AndroidHandler.java",
274       "android/apk/src/org/chromium/mojo/shell/FileHelper.java",
275       "android/apk/src/org/chromium/mojo/shell/MojoShellActivity.java",
276       "android/apk/src/org/chromium/mojo/shell/MojoShellApplication.java",
277       "android/apk/src/org/chromium/mojo/shell/ShellMain.java",
278     ]
280     deps = [
281       ":resources",
282       "//base:base_java",
283     ]
284   }
286   android_resources("resources") {
287     resource_dirs = [ "android/apk/res" ]
288     custom_package = "org.chromium.mojo.shell"
289   }
291   mojo_runner_test_assets_dir = "$root_build_dir/mojo_runner_test_assets"
292   mojo_runner_apptests_assets_dir =
293       "$root_build_dir/mojo_runner_apptests_assets"
295   copy_ex("copy_mojo_runner_apptests_assets") {
296     testonly = true
297     clear_dir = true
298     dest = mojo_runner_apptests_assets_dir
300     deps = [
301       ":bootstrap",
302       ":bootstrap_java",
303       "//components/clipboard:apptests",
304       "//components/mus:apptests",
305       "//components/resource_provider:apptests",
306       "//mojo/services/network:apptests",
307     ]
309     sources = [
310       "$root_out_dir/obj/mojo/runner/bootstrap_java.dex.jar",
311       "$root_shlib_dir/${shlib_prefix}bootstrap$shlib_extension",
312     ]
314     apptest_outputs = [
315       "clipboard",
316       "clipboard_apptests",
317       "mus_apptests",
318       "resource_provider",
319       "resource_provider_apptests",
320       "network_service",
321       "network_service_apptests",
322     ]
324     args = []
325     foreach(path, apptest_outputs) {
326       args +=
327           [ "--files=" + rebase_path("$root_out_dir/$path", root_build_dir) ]
328     }
329   }
331   generate_mojo_shell_assets_list("build_mojo_runner_apptests_assets") {
332     testonly = true
333     deps = [
334       ":copy_mojo_runner_apptests_assets",
335     ]
336     dir = mojo_runner_apptests_assets_dir
337   }
339   copy("copy_mojo_runner") {
340     sources = [
341       "$root_out_dir/mojo_runner",
342     ]
343     outputs = [
344       "$root_shlib_dir/${shlib_prefix}mojo_runner$shlib_extension",
345     ]
346     deps = [
347       ":mojo_runner",
348     ]
349   }
351   copy_ex("copy_mojo_runner_test_assets") {
352     testonly = true
353     clear_dir = true
354     dest = mojo_runner_test_assets_dir
355     deps = [
356       "//mojo/services/test_service:test_app",
357       "//mojo/services/test_service:test_request_tracker_app",
358     ]
360     # Directories can't be specified as sources so pass manually to the script.
361     args = [
362       "--files=" + rebase_path("$root_out_dir/test_app", root_build_dir),
363       "--files=" +
364           rebase_path("$root_out_dir/test_request_tracker_app", root_build_dir),
365     ]
366   }
368   android_apk("mojo_runner_apptests_apk") {
369     testonly = true
370     apk_name = "MojoRunnerApptests"
371     android_manifest = "android/apk/AndroidManifest.xml"
372     native_libs = [ "${shlib_prefix}mojo_runner$shlib_extension" ]
373     asset_location = mojo_runner_apptests_assets_dir
375     deps = [
376       ":build_mojo_runner_apptests_assets",
377       ":copy_mojo_runner",
378       ":java",
379       ":resources",
380       "//base:base_java",
381       "//ui/platform_window/android:platform_window_java",
382       google_play_services_resources,
383     ]
384   }
386   generate_mojo_shell_assets_list("build_mojo_runner_test_assets") {
387     testonly = true
388     deps = [
389       ":copy_mojo_runner_test_assets",
390     ]
391     dir = mojo_runner_test_assets_dir
392   }
394   android_library("mojo_runner_tests_java") {
395     java_files =
396         [ "android/tests/src/org/chromium/mojo/shell/ShellTestBase.java" ]
398     deps = [
399       ":java",
400       "//base:base_java",
401     ]
402   }
405 mojom("child_process_bindings") {
406   sources = [
407     "child_process.mojom",
408   ]
410   deps = [
411     "//mojo/application/public/interfaces",
412   ]
414   import_dirs = [ "//mojo/services" ]
417 test("mojo_runner_unittests") {
418   sources = [
419     "../fetcher/about_fetcher_unittest.cc",
420     "../fetcher/data_fetcher_unittest.cc",
421     "../fetcher/network_fetcher_unittest.cc",
422     "../fetcher/url_resolver_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   ]
434   deps = [
435     ":in_process_native_runner",
436     ":lib",
437     "//base",
438     "//base:i18n",
439     "//base/test:test_support",
440     "//mojo/application/public/cpp",
441     "//mojo/common",
442     "//mojo/environment:chromium",
443     "//mojo/fetcher",
444     "//mojo/message_pump",
445     "//mojo/package_manager",
446     "//mojo/services/test_service:bindings",
447     "//mojo/shell",
448     "//mojo/util:filename_util",
449     "//testing/gtest",
450     "//third_party/mojo/src/mojo/edk/system",
451     "//third_party/mojo/src/mojo/public/cpp/bindings",
452     "//url",
453   ]
455   data_deps = [
456     "//mojo/services/test_service:test_app",
457     "//mojo/services/test_service:test_request_tracker_app",
458   ]
460   if (is_android) {
461     sources += [ "android/background_application_loader_unittest.cc" ]
463     deps += [ ":jni_headers" ]
465     apk_deps = [
466       ":build_mojo_runner_test_assets",
467       ":mojo_runner_tests_java",
468     ]
470     apk_asset_location = mojo_runner_test_assets_dir
471   }
474 mojo_native_application("apptests") {
475   output_name = "runner_apptests"
477   testonly = true
479   sources = [
480     # TODO(jam): needs http_server service. http://crbug.com/479316
481     #"shell_apptest.cc",
482   ]
484   deps = [
485     "//base",
486     "//mojo/application/public/cpp:test_support",
487     "//mojo/runner/test:bindings",
488     "//mojo/services/network/public/interfaces",
489     "//third_party/mojo/src/mojo/public/cpp/bindings:callback",
490   ]