core_services: Bundle clipboard, window_manager, and view_manager.
[chromium-blink-merge.git] / mojo / runner / BUILD.gn
blobdb9ac617b36adc471f32798c0a69e1e6b2dcfb2a
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("//third_party/mojo/src/mojo/public/mojo.gni")
7 import("//third_party/mojo/src/mojo/public/mojo_application.gni")
8 import("//third_party/mojo/src/mojo/public/tools/bindings/mojom.gni")
9 import("//testing/test.gni")
11 # We don't support building in the component build since mojo apps are
12 # inherently components.
13 assert(!is_component_build)
15 group("runner") {
16   testonly = true
18   deps = [
19     ":mojo_runner",
20   ]
22   if (is_android) {
23     deps += [ ":mojo_runner_apk" ]
24   }
27 if (is_android) {
28   import("//build/config/android/config.gni")
29   import("//build/config/android/rules.gni")
32 executable("mojo_runner") {
33   sources = []
35   deps = [
36     ":lib",
37     "//base",
38     "//build/config/sanitizers:deps",
39     "//mojo/common",
40     "//mojo/environment:chromium",
41   ]
43   if (!is_android) {
44     sources += [
45       "desktop/launcher_process.cc",
46       "desktop/launcher_process.h",
47       "desktop/main.cc",
48     ]
49   } else {
50     sources += [
51       "android/library_loader.cc",
52       "android/main.cc",
53       "android/main.h",
54     ]
56     # On android, the executable is also the native library used by the apk.
57     # It means dynamic symbols must be preserved and exported.
58     ldflags = [ "-Wl,--export-dynamic" ]
60     deps += [
61       ":jni_headers",
62       "//components/native_viewport:lib",
63       "//mojo/shell",
64       "//ui/gl",
65     ]
66   }
69 source_set("in_process_native_runner") {
70   sources = [
71     "in_process_native_runner.cc",
72     "in_process_native_runner.h",
73   ]
75   public_deps = [
76     ":native_application_support",
77     "//mojo/shell",
78   ]
80   deps = [
81     "//base",
82   ]
85 source_set("lib") {
86   sources = [
87     "child_process.cc",
88     "child_process.h",
89     "child_process_host.cc",
90     "child_process_host.h",
91     "context.cc",
92     "context.h",
93     "init.cc",
94     "init.h",
95     "out_of_process_native_runner.cc",
96     "out_of_process_native_runner.h",
97     "task_runners.cc",
98     "task_runners.h",
99     "url_resolver.cc",
100     "url_resolver.h",
101   ]
103   deps = [
104     ":child_process_bindings",
105     ":in_process_native_runner",
106     ":native_application_support",
107     "//base",
108     "//base/third_party/dynamic_annotations",
109     "//base:base_static",
110     "//mojo/application",
111     "//mojo/common",
112     "//mojo/common:tracing_impl",
113     "//mojo/util:filename_util",
114     "//third_party/mojo/src/mojo/edk/system",
115     "//third_party/mojo/src/mojo/public/cpp/bindings",
116     "//third_party/mojo/src/mojo/public/interfaces/application",
117     "//mojo/services/network/public/interfaces",
118     "//mojo/shell",
119     "//mojo/services/tracing:bindings",
120     "//ui/gl",
121     "//url",
122   ]
124   public_deps = [
125     ":switches",
126   ]
128   data_deps = [ "//mojo/services/tracing" ]
130   if (is_android) {
131     sources += [
132       "android/android_handler.cc",
133       "android/android_handler.h",
134       "android/android_handler_loader.cc",
135       "android/android_handler_loader.h",
136       "android/background_application_loader.cc",
137       "android/background_application_loader.h",
138       "android/native_viewport_application_loader.cc",
139       "android/native_viewport_application_loader.h",
140       "android/ui_application_loader_android.cc",
141       "android/ui_application_loader_android.h",
142     ]
144     deps += [
145       ":jni_headers",
146       ":run_android_application_function",
147       "//components/gles2",
148       "//components/native_viewport:lib",
149       "//mojo/application:content_handler",
150     ]
151   }
153   # This target includes some files behind #ifdef OS... guards. Since gn is not
154   # smart enough to understand preprocess includes, it does complains about
155   # these includes when not using the build files for that OS. Suppress checking
156   # so we can enable checking for the rest of the targets in this file.
157   # TODO: Might be better to split the files with OS-specific includes out to a
158   # separate source_set so we can leave checking on for the rest of the target.
159   check_includes = false
162 source_set("native_application_support") {
163   sources = [
164     "native_application_support.cc",
165     "native_application_support.h",
166     "platform_handle_impl.cc",
167   ]
169   public_deps = [
170     "//third_party/mojo/src/mojo/public/cpp/bindings",
171   ]
173   deps = [
174     "//base",
175     "//mojo/gles2",
176     "//mojo/platform_handle:defs",
177   ]
179   # This target has to include the public thunk headers, which generally
180   # shouldn't be included without picking an implementation. We are providing
181   # the implementation but the thunk header target cannot declare that we are
182   # permitted to include it since it's in the public SDK and we are not.
183   # Suppress include checking so we can still check the rest of the targets in
184   # this file.
185   check_includes = false
188 source_set("switches") {
189   sources = [
190     "switches.cc",
191     "switches.h",
192   ]
194   deps = [
195     "//base",
196   ]
199 if (is_android) {
200   generate_jni("jni_headers") {
201     sources = [
202       "android/apk/src/org/chromium/mojo/shell/AndroidHandler.java",
203       "android/apk/src/org/chromium/mojo/shell/Bootstrap.java",
204       "android/apk/src/org/chromium/mojo/shell/ShellMain.java",
205       "android/tests/src/org/chromium/mojo/shell/ShellTestBase.java",
206     ]
207     jni_package = "mojo/shell"
208   }
210   android_library("bootstrap_java") {
211     java_files = [ "android/apk/src/org/chromium/mojo/shell/Bootstrap.java" ]
213     deps = [
214       "//base:base_java",
215     ]
217     dex_path = "$target_out_dir/bootstrap_java.dex.jar"
218   }
220   shared_library("bootstrap") {
221     sources = [
222       "android/bootstrap.cc",
223     ]
224     deps = [
225       ":jni_headers",
226       ":lib",
227       ":run_android_application_function",
228       "//base",
229     ]
230   }
232   # Shared header between the bootstrap and the main shell .so.
233   source_set("run_android_application_function") {
234     sources = [
235       "android/run_android_application_function.h",
236     ]
238     deps = [
239       "//base",
240     ]
241   }
243   android_library("java") {
244     java_files = [
245       "android/apk/src/org/chromium/mojo/shell/AndroidHandler.java",
246       "android/apk/src/org/chromium/mojo/shell/FileHelper.java",
247       "android/apk/src/org/chromium/mojo/shell/MojoShellActivity.java",
248       "android/apk/src/org/chromium/mojo/shell/MojoShellApplication.java",
249       "android/apk/src/org/chromium/mojo/shell/ShellMain.java",
250     ]
252     deps = [
253       "//base:base_java",
254     ]
255   }
257   android_resources("resources") {
258     resource_dirs = [ "android/apk/res" ]
259     custom_package = "org.chromium.mojo.shell"
260   }
262   mojo_runner_assets_dir = "$root_build_dir/mojo_runner_assets"
263   mojo_runner_test_assets_dir = "$root_build_dir/mojo_runner_test_assets"
265   copy_ex("copy_mojo_runner_assets") {
266     clear_dir = true
267     dest = mojo_runner_assets_dir
268     sources = [
269       "$root_out_dir/lib.stripped/libbootstrap.so",
270       "$root_out_dir/network_service.mojo",
271       "$root_out_dir/obj/mojo/runner/bootstrap_java.dex.jar",
272     ]
273   }
275   copy("copy_mojo_runner") {
276     sources = [
277       "$root_out_dir/exe.stripped/mojo_runner",
278     ]
279     outputs = [
280       "$root_out_dir/lib.stripped/libmojo_runner.so",
281     ]
282   }
284   copy_ex("copy_mojo_runner_test_assets") {
285     clear_dir = true
286     dest = mojo_runner_test_assets_dir
287     sources = [
288       "$root_out_dir/test_app.mojo",
289       "$root_out_dir/test_request_tracker_app.mojo",
290     ]
291   }
293   android_apk("mojo_runner_apk") {
294     apk_name = "MojoRunner"
296     android_manifest = "android/apk/AndroidManifest.xml"
298     native_libs = [ "libmojo_runner.so" ]
300     asset_location = mojo_runner_assets_dir
302     deps = [
303       ":copy_mojo_runner",
304       ":copy_mojo_runner_assets",
305       ":java",
306       ":resources",
307       "//base:base_java",
308       "//components/native_viewport:native_viewport_java",
309       "//third_party/android_tools:google_play_services_default_resources",
310     ]
311   }
313   android_library("mojo_runner_tests_java") {
314     java_files =
315         [ "android/tests/src/org/chromium/mojo/shell/ShellTestBase.java" ]
317     deps = [
318       ":java",
319       "//base:base_java",
320     ]
321   }
324 mojom("child_process_bindings") {
325   sources = [
326     "child_process.mojom",
327   ]
329   deps = [
330     "//third_party/mojo/src/mojo/public/interfaces/application",
331   ]
334 test("tests") {
335   output_name = "mojo_runner_unittests"
336   sources = [
337     "child_process_host_unittest.cc",
338     "data_pipe_peek_unittest.cc",
339     "in_process_native_runner_unittest.cc",
340     "native_runner_unittest.cc",
341     "shell_test_base.cc",
342     "shell_test_base.h",
343     "shell_test_base_android.cc",
344     "shell_test_base_unittest.cc",
345     "shell_test_main.cc",
346     "url_resolver_unittest.cc",
347   ]
349   deps = [
350     ":in_process_native_runner",
351     ":lib",
352     "//base",
353     "//base:i18n",
354     "//base/test:test_support",
355     "//mojo/common",
356     "//mojo/environment:chromium",
357     "//mojo/services/test_service:bindings",
358     "//mojo/shell",
359     "//mojo/util:filename_util",
360     "//testing/gtest",
361     "//third_party/mojo/src/mojo/edk/system",
362     "//third_party/mojo/src/mojo/public/cpp/bindings",
363     "//url",
364   ]
366   datadeps = [
367     "//mojo/services/test_service:test_app",
368     "//mojo/services/test_service:test_request_tracker_app",
369   ]
371   if (is_android) {
372     sources += [ "android/background_application_loader_unittest.cc" ]
374     deps += [ ":jni_headers" ]
376     apk_deps = [
377       ":copy_mojo_runner_test_assets",
378       ":mojo_runner_tests_java",
379     ]
381     apk_asset_location = mojo_runner_test_assets_dir
382   }
385 mojo_native_application("apptests") {
386   output_name = "runner_apptests"
388   testonly = true
390   sources = [
391     # TODO(jam): needs http_server service.
392     #"shell_apptest.cc",
393   ]
395   deps = [
396     "//base",
397     "//mojo/application",
398     "//mojo/application:test_support",
399     "//mojo/common:common",
400     "//mojo/runner/test:bindings",
402     #"//mojo/services/http_server/public/cpp",
403     #"//mojo/services/http_server/public/interfaces",
404     "//mojo/services/network/public/interfaces",
406     "//third_party/mojo/src/mojo/public/cpp/bindings:callback",
407     "//third_party/mojo/src/mojo/public/cpp/environment",
408     "//third_party/mojo/src/mojo/public/cpp/system:system",
409   ]
411   #data_deps = [ "//services/http_server:http_server($default_toolchain)" ]