Pin Chrome's shortcut to the Win10 Start menu on install and OS upgrade.
[chromium-blink-merge.git] / mojo / runner / BUILD.gn
blobfb652a0163919bac0df8c134189fa9311d46c7de
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     "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     "url_resolver.cc",
114     "url_resolver.h",
115   ]
117   deps = [
118     ":child_process_bindings",
119     ":in_process_native_runner",
120     ":native_application_support",
121     "//base",
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",
131     "//mojo/shell",
132     "//mojo/services/tracing:bindings",
133     "//ui/gl",
134     "//url",
135   ]
137   public_deps = [
138     ":switches",
139   ]
141   data_deps = [
142     "//components/devtools_service",
143     "//mojo/services/tracing",
144   ]
146   if (is_android) {
147     sources += [
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",
156     ]
158     deps += [
159       ":jni_headers",
160       ":run_android_application_function",
161       "//components/view_manager/gles2",
162       "//components/view_manager/native_viewport",
163       "//mojo/application/public/cpp:content_handler",
164     ]
165   }
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") {
177   sources = [
178     "native_application_support.cc",
179     "native_application_support.h",
180     "platform_handle_impl.cc",
181   ]
183   public_deps = [
184     "//third_party/mojo/src/mojo/public/cpp/bindings",
185   ]
187   deps = [
188     "//base",
189     "//mojo/gles2",
190     "//mojo/platform_handle:defs",
191     "//mojo/shell",
192   ]
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
199   # this file.
200   check_includes = false
203 source_set("switches") {
204   sources = [
205     "switches.cc",
206     "switches.h",
207   ]
209   deps = [
210     "//base",
211   ]
214 if (is_android) {
215   generate_jni("jni_headers") {
216     sources = [
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",
221     ]
222     jni_package = "mojo/shell"
223   }
225   android_library("bootstrap_java") {
226     java_files = [ "android/apk/src/org/chromium/mojo/shell/Bootstrap.java" ]
228     deps = [
229       "//base:base_java",
230     ]
232     dex_path = "$target_out_dir/bootstrap_java.dex.jar"
233   }
235   shared_library("bootstrap") {
236     sources = [
237       "android/bootstrap.cc",
238     ]
239     deps = [
240       ":jni_headers",
241       ":lib",
242       ":run_android_application_function",
243       "//base",
244     ]
245   }
247   # Shared header between the bootstrap and the main shell .so.
248   source_set("run_android_application_function") {
249     sources = [
250       "android/run_android_application_function.h",
251     ]
253     deps = [
254       "//base",
255     ]
256   }
258   android_library("java") {
259     java_files = [
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",
265     ]
267     deps = [
268       ":resources",
269       "//base:base_java",
270     ]
271   }
273   android_resources("resources") {
274     resource_dirs = [ "android/apk/res" ]
275     custom_package = "org.chromium.mojo.shell"
276   }
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") {
283     testonly = true
284     clear_dir = true
285     dest = mojo_runner_apptests_assets_dir
287     deps = [
288       ":bootstrap",
289       ":bootstrap_java",
290       "//components/clipboard:apptests",
291       "//components/resource_provider:apptests",
292       "//components/view_manager:apptests",
293       "//mojo/services/network:apptests",
294     ]
296     sources = [
297       "$root_out_dir/lib.stripped/libbootstrap$android_product_extension",
298       "$root_out_dir/obj/mojo/runner/bootstrap_java.dex.jar",
299     ]
301     apptest_outputs = [
302       "clipboard",
303       "clipboard_apptests",
304       "resource_provider",
305       "resource_provider_apptests",
306       "view_manager_apptests",
307       "network_service",
308       "network_service_apptests",
309     ]
311     args = []
312     foreach(path, apptest_outputs) {
313       args +=
314           [ "--files=" + rebase_path("$root_out_dir/$path", root_build_dir) ]
315     }
316   }
318   generate_mojo_shell_assets_list("build_mojo_runner_apptests_assets") {
319     testonly = true
320     deps = [
321       ":copy_mojo_runner_apptests_assets",
322     ]
323     dir = mojo_runner_apptests_assets_dir
324   }
326   copy("copy_mojo_runner") {
327     sources = [
328       "$root_out_dir/exe.stripped/mojo_runner",
329     ]
330     outputs = [
331       "$root_out_dir/lib.stripped/libmojo_runner$android_product_extension",
332     ]
333     deps = [
334       ":mojo_runner",
335     ]
336   }
338   copy_ex("copy_mojo_runner_test_assets") {
339     testonly = true
340     clear_dir = true
341     dest = mojo_runner_test_assets_dir
342     deps = [
343       "//mojo/services/test_service:test_app",
344       "//mojo/services/test_service:test_request_tracker_app",
345     ]
347     # Directories can't be specified as sources so pass manually to the script.
348     args = [
349       "--files=" + rebase_path("$root_out_dir/test_app", root_build_dir),
350       "--files=" +
351           rebase_path("$root_out_dir/test_request_tracker_app", root_build_dir),
352     ]
353   }
355   android_apk("mojo_runner_apptests_apk") {
356     testonly = true
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
362     deps = [
363       ":build_mojo_runner_apptests_assets",
364       ":copy_mojo_runner",
365       ":java",
366       ":resources",
367       "//base:base_java",
368       "//third_party/android_tools:google_play_services_default_resources",
369       "//ui/platform_window/android:platform_window_java",
370     ]
371   }
373   generate_mojo_shell_assets_list("build_mojo_runner_test_assets") {
374     testonly = true
375     deps = [
376       ":copy_mojo_runner_test_assets",
377     ]
378     dir = mojo_runner_test_assets_dir
379   }
381   android_library("mojo_runner_tests_java") {
382     java_files =
383         [ "android/tests/src/org/chromium/mojo/shell/ShellTestBase.java" ]
385     deps = [
386       ":java",
387       "//base:base_java",
388     ]
389   }
392 mojom("child_process_bindings") {
393   sources = [
394     "child_process.mojom",
395   ]
397   deps = [
398     "//mojo/application/public/interfaces",
399   ]
401   import_dirs = [ "//mojo/services" ]
404 test("mojo_runner_unittests") {
405   sources = [
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",
411     "shell_test_base.h",
412     "shell_test_base_android.cc",
413     "shell_test_base_unittest.cc",
414     "shell_test_main.cc",
415     "url_resolver_unittest.cc",
416   ]
418   deps = [
419     ":in_process_native_runner",
420     ":lib",
421     "//base",
422     "//base:i18n",
423     "//base/test:test_support",
424     "//mojo/common",
425     "//mojo/environment:chromium",
426     "//mojo/services/test_service:bindings",
427     "//mojo/shell",
428     "//mojo/util:filename_util",
429     "//testing/gtest",
430     "//third_party/mojo/src/mojo/edk/system",
431     "//third_party/mojo/src/mojo/public/cpp/bindings",
432     "//url",
433   ]
435   data_deps = [
436     "//mojo/services/test_service:test_app",
437     "//mojo/services/test_service:test_request_tracker_app",
438   ]
440   if (is_android) {
441     sources += [ "android/background_application_loader_unittest.cc" ]
443     deps += [ ":jni_headers" ]
445     apk_deps = [
446       ":build_mojo_runner_test_assets",
447       ":mojo_runner_tests_java",
448     ]
450     apk_asset_location = mojo_runner_test_assets_dir
451   }
454 mojo_native_application("apptests") {
455   output_name = "runner_apptests"
457   testonly = true
459   sources = [
460     # TODO(jam): needs http_server service. http://crbug.com/479316
461     #"shell_apptest.cc",
462   ]
464   deps = [
465     "//base",
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",
470   ]