Include all dupe types (event when value is zero) in scan stats.
[chromium-blink-merge.git] / mojo / runner / BUILD.gn
blobaad598d5d193244b2c473ea7c3dbb41f705c7799
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("//build/config/ui.gni")
6 import("//mojo/generate_mojo_shell_assets_list.gni")
7 import("//third_party/mojo/src/mojo/public/mojo.gni")
8 import("//third_party/mojo/src/mojo/public/mojo_application.gni")
9 import("//third_party/mojo/src/mojo/public/tools/bindings/mojom.gni")
10 import("//testing/test.gni")
12 # We don't support building in the component build since mojo apps are
13 # inherently components.
14 assert(!is_component_build)
16 group("runner") {
17   testonly = true
19   deps = [
20     ":mojo_runner",
21   ]
23   if (is_android) {
24     deps += [ ":mojo_runner_apk" ]
25   }
28 if (is_android) {
29   import("//build/config/android/config.gni")
30   import("//build/config/android/rules.gni")
33 source_set("mojo_runner_lib") {
34   sources = []
36   deps = [
37     ":lib",
38     "//base",
39     "//build/config/sanitizers:deps",
40     "//mojo/common",
41     "//mojo/environment:chromium",
42   ]
44   if (!is_android) {
45     sources += [
46       "desktop/launcher_process.cc",
47       "desktop/launcher_process.h",
48       "desktop/main.cc",
49     ]
50   } else {
51     sources += [
52       "android/context_init.h",
53       "android/library_loader.cc",
54       "android/main.cc",
55       "android/main.h",
56     ]
58     deps += [
59       ":jni_headers",
60       "//components/view_manager",
61       "//mojo/shell",
62       "//ui/gl",
63     ]
64   }
67 executable("mojo_runner") {
68   deps = [
69     ":mojo_runner_lib",
70   ]
72   if (is_android) {
73     sources = [
74       "android/context_init.cc",
75     ]
77     # On android, the executable is also the native library used by the apk.
78     # It means dynamic symbols must be preserved and exported.
79     ldflags = [ "-Wl,--export-dynamic" ]
80   }
82   deps += [ "//build/config/sanitizers:deps" ]
85 source_set("in_process_native_runner") {
86   sources = [
87     "in_process_native_runner.cc",
88     "in_process_native_runner.h",
89   ]
91   public_deps = [
92     ":native_application_support",
93     "//mojo/shell",
94   ]
96   deps = [
97     "//base",
98   ]
101 source_set("lib") {
102   sources = [
103     "child_process.cc",
104     "child_process.h",
105     "child_process_host.cc",
106     "child_process_host.h",
107     "context.cc",
108     "context.h",
109     "init.cc",
110     "init.h",
111     "out_of_process_native_runner.cc",
112     "out_of_process_native_runner.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/interfaces",
127     "//mojo/application/public/cpp",
128     "//mojo/common:tracing_impl",
129     "//mojo/util:filename_util",
130     "//third_party/mojo/src/mojo/edk/system",
131     "//mojo/services/network/public/interfaces",
132     "//mojo/shell",
133     "//mojo/services/tracing:bindings",
134     "//ui/gl",
135     "//url",
136   ]
138   public_deps = [
139     ":switches",
140   ]
142   data_deps = [
143     "//components/devtools_service",
144     "//mojo/services/tracing",
145   ]
147   if (is_android) {
148     sources += [
149       "android/android_handler.cc",
150       "android/android_handler.h",
151       "android/android_handler_loader.cc",
152       "android/android_handler_loader.h",
153       "android/background_application_loader.cc",
154       "android/background_application_loader.h",
155       "android/ui_application_loader_android.cc",
156       "android/ui_application_loader_android.h",
157     ]
159     deps += [
160       ":jni_headers",
161       ":run_android_application_function",
162       "//components/view_manager/gles2",
163       "//components/view_manager/native_viewport",
164       "//mojo/application/public/cpp:content_handler",
165     ]
166   }
168   # This target includes some files behind #ifdef OS... guards. Since gn is not
169   # smart enough to understand preprocess includes, it does complains about
170   # these includes when not using the build files for that OS. Suppress checking
171   # so we can enable checking for the rest of the targets in this file.
172   # TODO: Might be better to split the files with OS-specific includes out to a
173   # separate source_set so we can leave checking on for the rest of the target.
174   check_includes = false
177 source_set("native_application_support") {
178   sources = [
179     "native_application_support.cc",
180     "native_application_support.h",
181     "platform_handle_impl.cc",
182   ]
184   public_deps = [
185     "//third_party/mojo/src/mojo/public/cpp/bindings",
186   ]
188   deps = [
189     "//base",
190     "//mojo/gles2",
191     "//mojo/platform_handle:defs",
192     "//mojo/shell",
193   ]
195   # This target has to include the public thunk headers, which generally
196   # shouldn't be included without picking an implementation. We are providing
197   # the implementation but the thunk header target cannot declare that we are
198   # permitted to include it since it's in the public SDK and we are not.
199   # Suppress include checking so we can still check the rest of the targets in
200   # this file.
201   check_includes = false
204 source_set("switches") {
205   sources = [
206     "switches.cc",
207     "switches.h",
208   ]
210   deps = [
211     "//base",
212   ]
215 if (is_android) {
216   generate_jni("jni_headers") {
217     sources = [
218       "android/apk/src/org/chromium/mojo/shell/AndroidHandler.java",
219       "android/apk/src/org/chromium/mojo/shell/Bootstrap.java",
220       "android/apk/src/org/chromium/mojo/shell/ShellMain.java",
221       "android/tests/src/org/chromium/mojo/shell/ShellTestBase.java",
222     ]
223     jni_package = "mojo/shell"
224   }
226   android_library("bootstrap_java") {
227     java_files = [ "android/apk/src/org/chromium/mojo/shell/Bootstrap.java" ]
229     deps = [
230       "//base:base_java",
231     ]
233     dex_path = "$target_out_dir/bootstrap_java.dex.jar"
234   }
236   shared_library("bootstrap") {
237     sources = [
238       "android/bootstrap.cc",
239     ]
240     deps = [
241       ":jni_headers",
242       ":lib",
243       ":run_android_application_function",
244       "//base",
245     ]
246   }
248   # Shared header between the bootstrap and the main shell .so.
249   source_set("run_android_application_function") {
250     sources = [
251       "android/run_android_application_function.h",
252     ]
254     deps = [
255       "//base",
256     ]
257   }
259   android_library("java") {
260     java_files = [
261       "android/apk/src/org/chromium/mojo/shell/AndroidHandler.java",
262       "android/apk/src/org/chromium/mojo/shell/FileHelper.java",
263       "android/apk/src/org/chromium/mojo/shell/MojoShellActivity.java",
264       "android/apk/src/org/chromium/mojo/shell/MojoShellApplication.java",
265       "android/apk/src/org/chromium/mojo/shell/ShellMain.java",
266     ]
268     deps = [
269       ":resources",
270       "//base:base_java",
271     ]
272   }
274   android_resources("resources") {
275     resource_dirs = [ "android/apk/res" ]
276     custom_package = "org.chromium.mojo.shell"
277   }
279   mojo_runner_assets_dir = "$root_build_dir/mojo_runner_assets"
280   mojo_runner_test_assets_dir = "$root_build_dir/mojo_runner_test_assets"
282   copy_ex("copy_mojo_runner_assets") {
283     clear_dir = true
284     dest = mojo_runner_assets_dir
285     deps = [
286       ":bootstrap",
287       ":bootstrap_java",
288       ":copy_mojo_runner",
289       "//mojo/services/network",
290     ]
291     sources = [
292       "$root_out_dir/lib.stripped/libbootstrap.so",
293       "$root_out_dir/network_service.mojo",
294       "$root_out_dir/obj/mojo/runner/bootstrap_java.dex.jar",
295     ]
296   }
298   generate_mojo_shell_assets_list("build_mojo_runner_assets") {
299     deps = [
300       ":copy_mojo_runner_assets",
301     ]
302     dir = mojo_runner_assets_dir
303   }
305   copy("copy_mojo_runner") {
306     sources = [
307       "$root_out_dir/exe.stripped/mojo_runner",
308     ]
309     outputs = [
310       "$root_out_dir/lib.stripped/libmojo_runner.so",
311     ]
312   }
314   copy_ex("copy_mojo_runner_test_assets") {
315     clear_dir = true
316     dest = mojo_runner_test_assets_dir
317     sources = [
318       "$root_out_dir/test_app.mojo",
319       "$root_out_dir/test_request_tracker_app.mojo",
320     ]
321     deps = [
322       "//mojo/services/test_service:test_app",
323       "//mojo/services/test_service:test_request_tracker_app",
324     ]
325   }
327   android_apk("mojo_runner_apk") {
328     apk_name = "MojoRunner"
330     android_manifest = "android/apk/AndroidManifest.xml"
332     native_libs = [ "libmojo_runner.so" ]
334     asset_location = mojo_runner_assets_dir
336     deps = [
337       ":build_mojo_runner_assets",
338       ":copy_mojo_runner",
339       ":java",
340       ":resources",
341       "//base:base_java",
342       "//components/view_manager:view_manager_java",
343       "//third_party/android_tools:google_play_services_default_resources",
344     ]
345   }
347   generate_mojo_shell_assets_list("build_mojo_runner_test_assets") {
348     deps = [
349       ":copy_mojo_runner_test_assets",
350     ]
351     dir = mojo_runner_test_assets_dir
352   }
354   android_library("mojo_runner_tests_java") {
355     java_files =
356         [ "android/tests/src/org/chromium/mojo/shell/ShellTestBase.java" ]
358     deps = [
359       ":java",
360       "//base:base_java",
361     ]
362   }
365 mojom("child_process_bindings") {
366   sources = [
367     "child_process.mojom",
368   ]
370   deps = [
371     "//mojo/application/public/interfaces",
372   ]
374   import_dirs = [ "//mojo/services" ]
377 test("tests") {
378   output_name = "mojo_runner_unittests"
379   sources = [
380     "child_process_host_unittest.cc",
381     "data_pipe_peek_unittest.cc",
382     "in_process_native_runner_unittest.cc",
383     "native_runner_unittest.cc",
384     "shell_test_base.cc",
385     "shell_test_base.h",
386     "shell_test_base_android.cc",
387     "shell_test_base_unittest.cc",
388     "shell_test_main.cc",
389     "url_resolver_unittest.cc",
390   ]
392   deps = [
393     ":in_process_native_runner",
394     ":lib",
395     "//base",
396     "//base:i18n",
397     "//base/test:test_support",
398     "//mojo/common",
399     "//mojo/environment:chromium",
400     "//mojo/services/test_service:bindings",
401     "//mojo/shell",
402     "//mojo/util:filename_util",
403     "//testing/gtest",
404     "//third_party/mojo/src/mojo/edk/system",
405     "//third_party/mojo/src/mojo/public/cpp/bindings",
406     "//url",
407   ]
409   data_deps = [
410     "//mojo/services/test_service:test_app",
411     "//mojo/services/test_service:test_request_tracker_app",
412   ]
414   if (is_android) {
415     sources += [ "android/background_application_loader_unittest.cc" ]
417     deps += [ ":jni_headers" ]
419     apk_deps = [
420       ":build_mojo_runner_test_assets",
421       ":mojo_runner_tests_java",
422     ]
424     apk_asset_location = mojo_runner_test_assets_dir
425   }
428 mojo_native_application("apptests") {
429   output_name = "runner_apptests"
431   testonly = true
433   sources = [
434     # TODO(jam): needs http_server service.
435     #"shell_apptest.cc",
436   ]
438   deps = [
439     "//base",
440     "//mojo/application/public/cpp:test_support",
441     "//mojo/runner/test:bindings",
442     "//mojo/services/network/public/interfaces",
443     "//third_party/mojo/src/mojo/public/cpp/bindings:callback",
444   ]