Gets mandoline working on android
[chromium-blink-merge.git] / mojo / runner / BUILD.gn
blob5d78611e1864928cc604237eebc7c6d6ded5d2af
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/native_viewport:lib",
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   }
83 source_set("in_process_native_runner") {
84   sources = [
85     "in_process_native_runner.cc",
86     "in_process_native_runner.h",
87   ]
89   public_deps = [
90     ":native_application_support",
91     "//mojo/shell",
92   ]
94   deps = [
95     "//base",
96   ]
99 source_set("lib") {
100   sources = [
101     "child_process.cc",
102     "child_process.h",
103     "child_process_host.cc",
104     "child_process_host.h",
105     "context.cc",
106     "context.h",
107     "init.cc",
108     "init.h",
109     "out_of_process_native_runner.cc",
110     "out_of_process_native_runner.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     "//mojo/application",
125     "//mojo/common",
126     "//mojo/common:tracing_impl",
127     "//mojo/util:filename_util",
128     "//third_party/mojo/src/mojo/edk/system",
129     "//third_party/mojo/src/mojo/public/cpp/bindings",
130     "//third_party/mojo/src/mojo/public/interfaces/application",
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 = [ "//mojo/services/tracing" ]
144   if (is_android) {
145     sources += [
146       "android/android_handler.cc",
147       "android/android_handler.h",
148       "android/android_handler_loader.cc",
149       "android/android_handler_loader.h",
150       "android/background_application_loader.cc",
151       "android/background_application_loader.h",
152       "android/native_viewport_application_loader.cc",
153       "android/native_viewport_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/gles2",
162       "//components/native_viewport:lib",
163       "//mojo/application: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   ]
193   # This target has to include the public thunk headers, which generally
194   # shouldn't be included without picking an implementation. We are providing
195   # the implementation but the thunk header target cannot declare that we are
196   # permitted to include it since it's in the public SDK and we are not.
197   # Suppress include checking so we can still check the rest of the targets in
198   # this file.
199   check_includes = false
202 source_set("switches") {
203   sources = [
204     "switches.cc",
205     "switches.h",
206   ]
208   deps = [
209     "//base",
210   ]
213 if (is_android) {
214   generate_jni("jni_headers") {
215     sources = [
216       "android/apk/src/org/chromium/mojo/shell/AndroidHandler.java",
217       "android/apk/src/org/chromium/mojo/shell/Bootstrap.java",
218       "android/apk/src/org/chromium/mojo/shell/ShellMain.java",
219       "android/tests/src/org/chromium/mojo/shell/ShellTestBase.java",
220     ]
221     jni_package = "mojo/shell"
222   }
224   android_library("bootstrap_java") {
225     java_files = [ "android/apk/src/org/chromium/mojo/shell/Bootstrap.java" ]
227     deps = [
228       "//base:base_java",
229     ]
231     dex_path = "$target_out_dir/bootstrap_java.dex.jar"
232   }
234   shared_library("bootstrap") {
235     sources = [
236       "android/bootstrap.cc",
237     ]
238     deps = [
239       ":jni_headers",
240       ":lib",
241       ":run_android_application_function",
242       "//base",
243     ]
244   }
246   # Shared header between the bootstrap and the main shell .so.
247   source_set("run_android_application_function") {
248     sources = [
249       "android/run_android_application_function.h",
250     ]
252     deps = [
253       "//base",
254     ]
255   }
257   android_library("java") {
258     java_files = [
259       "android/apk/src/org/chromium/mojo/shell/AndroidHandler.java",
260       "android/apk/src/org/chromium/mojo/shell/FileHelper.java",
261       "android/apk/src/org/chromium/mojo/shell/MojoShellActivity.java",
262       "android/apk/src/org/chromium/mojo/shell/MojoShellApplication.java",
263       "android/apk/src/org/chromium/mojo/shell/ShellMain.java",
264     ]
266     deps = [
267       ":resources",
268       "//base:base_java",
269     ]
270   }
272   android_resources("resources") {
273     resource_dirs = [ "android/apk/res" ]
274     custom_package = "org.chromium.mojo.shell"
275   }
277   mojo_runner_assets_dir = "$root_build_dir/mojo_runner_assets"
278   mojo_runner_test_assets_dir = "$root_build_dir/mojo_runner_test_assets"
280   copy_ex("copy_mojo_runner_assets") {
281     clear_dir = true
282     dest = mojo_runner_assets_dir
283     deps = [
284       ":copy_mojo_runner",
285     ]
286     sources = [
287       "$root_out_dir/lib.stripped/libbootstrap.so",
288       "$root_out_dir/network_service.mojo",
289       "$root_out_dir/obj/mojo/runner/bootstrap_java.dex.jar",
290     ]
291   }
293   generate_mojo_shell_assets_list("build_mojo_runner_assets") {
294     deps = [
295       ":copy_mojo_runner_assets",
296     ]
297     dir = mojo_runner_assets_dir
298   }
300   copy("copy_mojo_runner") {
301     sources = [
302       "$root_out_dir/exe.stripped/mojo_runner",
303     ]
304     outputs = [
305       "$root_out_dir/lib.stripped/libmojo_runner.so",
306     ]
307   }
309   copy_ex("copy_mojo_runner_test_assets") {
310     clear_dir = true
311     dest = mojo_runner_test_assets_dir
312     sources = [
313       "$root_out_dir/test_app.mojo",
314       "$root_out_dir/test_request_tracker_app.mojo",
315     ]
316   }
318   android_apk("mojo_runner_apk") {
319     apk_name = "MojoRunner"
321     android_manifest = "android/apk/AndroidManifest.xml"
323     native_libs = [ "libmojo_runner.so" ]
325     asset_location = mojo_runner_assets_dir
327     deps = [
328       ":build_mojo_runner_assets",
329       ":java",
330       ":resources",
331       "//base:base_java",
332       "//components/native_viewport:native_viewport_java",
333       "//third_party/android_tools:google_play_services_default_resources",
334     ]
335   }
337   generate_mojo_shell_assets_list("build_mojo_runner_test_assets") {
338     deps = [
339       ":copy_mojo_runner_test_assets",
340     ]
341     dir = mojo_runner_test_assets_dir
342   }
344   android_library("mojo_runner_tests_java") {
345     java_files =
346         [ "android/tests/src/org/chromium/mojo/shell/ShellTestBase.java" ]
348     deps = [
349       ":java",
350       "//base:base_java",
351     ]
352   }
355 mojom("child_process_bindings") {
356   sources = [
357     "child_process.mojom",
358   ]
360   deps = [
361     "//third_party/mojo/src/mojo/public/interfaces/application",
362   ]
365 test("tests") {
366   output_name = "mojo_runner_unittests"
367   sources = [
368     "child_process_host_unittest.cc",
369     "data_pipe_peek_unittest.cc",
370     "in_process_native_runner_unittest.cc",
371     "native_runner_unittest.cc",
372     "shell_test_base.cc",
373     "shell_test_base.h",
374     "shell_test_base_android.cc",
375     "shell_test_base_unittest.cc",
376     "shell_test_main.cc",
377     "url_resolver_unittest.cc",
378   ]
380   deps = [
381     ":in_process_native_runner",
382     ":lib",
383     "//base",
384     "//base:i18n",
385     "//base/test:test_support",
386     "//mojo/common",
387     "//mojo/environment:chromium",
388     "//mojo/services/test_service:bindings",
389     "//mojo/shell",
390     "//mojo/util:filename_util",
391     "//testing/gtest",
392     "//third_party/mojo/src/mojo/edk/system",
393     "//third_party/mojo/src/mojo/public/cpp/bindings",
394     "//url",
395   ]
397   datadeps = [
398     "//mojo/services/test_service:test_app",
399     "//mojo/services/test_service:test_request_tracker_app",
400   ]
402   if (is_android) {
403     sources += [ "android/background_application_loader_unittest.cc" ]
405     deps += [ ":jni_headers" ]
407     apk_deps = [
408       ":build_mojo_runner_test_assets",
409       ":mojo_runner_tests_java",
410     ]
412     apk_asset_location = mojo_runner_test_assets_dir
413   }
416 mojo_native_application("apptests") {
417   output_name = "runner_apptests"
419   testonly = true
421   sources = [
422     # TODO(jam): needs http_server service.
423     #"shell_apptest.cc",
424   ]
426   deps = [
427     "//base",
428     "//mojo/application",
429     "//mojo/application:test_support",
430     "//mojo/common:common",
431     "//mojo/runner/test:bindings",
433     #"//mojo/services/http_server/public/cpp",
434     #"//mojo/services/http_server/public/interfaces",
435     "//mojo/services/network/public/interfaces",
437     "//third_party/mojo/src/mojo/public/cpp/bindings:callback",
438     "//third_party/mojo/src/mojo/public/cpp/environment",
439     "//third_party/mojo/src/mojo/public/cpp/system:system",
440   ]
442   #data_deps = [ "//services/http_server:http_server($default_toolchain)" ]