Supervised user whitelists: Cleanup
[chromium-blink-merge.git] / mojo / shell / BUILD.gn
blob3c06107b47d2f22028fdd051c72bf55c44648202
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("shell") {
16   testonly = true
18   deps = [
19     ":mojo_shell",
20     ":tests",
21     "//mojo/shell/application_manager:tests",
22   ]
24   if (is_android) {
25     deps += [
26       ":mojo_shell_apk",
27       ":tests_apk",
28     ]
29   }
32 if (is_android) {
33   import("//build/config/android/config.gni")
34   import("//build/config/android/rules.gni")
37 executable("mojo_shell") {
38   sources = []
40   deps = [
41     ":lib",
42     "//base",
43     "//build/config/sanitizers:deps",
44     "//mojo/common",
45     "//mojo/environment:chromium",
46   ]
48   if (!is_android) {
49     sources += [
50       "desktop/launcher_process.cc",
51       "desktop/launcher_process.h",
52       "desktop/main.cc",
53     ]
54   } else {
55     sources += [
56       "android/library_loader.cc",
57       "android/main.cc",
58       "android/main.h",
59     ]
61     # On android, the executable is also the native library used by the apk.
62     # It means dynamic symbols must be preserved and exported.
63     ldflags = [ "-Wl,--export-dynamic" ]
65     deps += [
66       ":jni_headers",
67       "//components/native_viewport:lib",
68       "//mojo/shell/application_manager",
69       "//ui/gl",
70     ]
71   }
74 source_set("in_process_native_runner") {
75   sources = [
76     "in_process_native_runner.cc",
77     "in_process_native_runner.h",
78   ]
80   public_deps = [
81     ":native_application_support",
82     "//mojo/shell/application_manager",
83   ]
85   deps = [
86     "//base",
87   ]
90 source_set("lib") {
91   sources = [
92     "child_process.cc",
93     "child_process.h",
94     "child_process_host.cc",
95     "child_process_host.h",
96     "context.cc",
97     "context.h",
98     "filename_util.cc",
99     "filename_util.h",
100     "init.cc",
101     "init.h",
102     "out_of_process_native_runner.cc",
103     "out_of_process_native_runner.h",
104     "task_runners.cc",
105     "task_runners.h",
106     "url_resolver.cc",
107     "url_resolver.h",
108   ]
110   deps = [
111     ":child_process_bindings",
112     ":in_process_native_runner",
113     ":native_application_support",
114     "//base",
115     "//base/third_party/dynamic_annotations",
116     "//base:base_static",
117     "//mojo/application",
118     "//mojo/common",
119     "//mojo/common:tracing_impl",
120     "//third_party/mojo/src/mojo/edk/system",
121     "//third_party/mojo/src/mojo/public/cpp/bindings",
122     "//third_party/mojo/src/mojo/public/interfaces/application",
123     "//mojo/services/network/public/interfaces",
124     "//mojo/shell/application_manager",
125     "//mojo/services/tracing:bindings",
126     "//url",
127   ]
129   public_deps = [
130     ":switches",
131   ]
133   if (is_android) {
134     sources += [
135       "android/android_handler.cc",
136       "android/android_handler.h",
137       "android/android_handler_loader.cc",
138       "android/android_handler_loader.h",
139       "android/background_application_loader.cc",
140       "android/background_application_loader.h",
141       "android/native_viewport_application_loader.cc",
142       "android/native_viewport_application_loader.h",
143       "android/ui_application_loader_android.cc",
144       "android/ui_application_loader_android.h",
145     ]
147     deps += [
148       ":jni_headers",
149       ":run_android_application_function",
150       "//components/gles2",
151       "//components/native_viewport:lib",
152       "//mojo/application:content_handler",
153     ]
154   }
156   # This target includes some files behind #ifdef OS... guards. Since gn is not
157   # smart enough to understand preprocess includes, it does complains about
158   # these includes when not using the build files for that OS. Suppress checking
159   # so we can enable checking for the rest of the targets in this file.
160   # TODO: Might be better to split the files with OS-specific includes out to a
161   # separate source_set so we can leave checking on for the rest of the target.
162   check_includes = false
165 source_set("native_application_support") {
166   sources = [
167     "native_application_support.cc",
168     "native_application_support.h",
169   ]
171   public_deps = [
172     "//third_party/mojo/src/mojo/public/cpp/bindings",
173   ]
175   deps = [
176     "//base",
177     "//mojo/gles2",
178   ]
180   # This target has to include the public thunk headers, which generally
181   # shouldn't be included without picking an implementation. We are providing
182   # the implementation but the thunk header target cannot declare that we are
183   # permitted to include it since it's in the public SDK and we are not.
184   # Suppress include checking so we can still check the rest of the targets in
185   # this file.
186   check_includes = false
189 source_set("switches") {
190   sources = [
191     "switches.cc",
192     "switches.h",
193   ]
195   deps = [
196     "//base",
197   ]
200 if (is_android) {
201   generate_jni("jni_headers") {
202     sources = [
203       "android/apk/src/org/chromium/mojo/shell/AndroidHandler.java",
204       "android/apk/src/org/chromium/mojo/shell/Bootstrap.java",
205       "android/apk/src/org/chromium/mojo/shell/ShellMain.java",
206       "android/tests/src/org/chromium/mojo/shell/ShellTestBase.java",
207     ]
208     jni_package = "mojo/shell"
209   }
211   android_library("bootstrap_java") {
212     java_files = [ "android/apk/src/org/chromium/mojo/shell/Bootstrap.java" ]
214     deps = [
215       "//base:base_java",
216     ]
218     dex_path = "$target_out_dir/bootstrap_java.dex.jar"
219   }
221   shared_library("bootstrap") {
222     sources = [
223       "android/bootstrap.cc",
224     ]
225     deps = [
226       ":jni_headers",
227       ":lib",
228       ":run_android_application_function",
229       "//base",
230     ]
231   }
233   # Shared header between the bootstrap and the main shell .so.
234   source_set("run_android_application_function") {
235     sources = [
236       "android/run_android_application_function.h",
237     ]
239     deps = [
240       "//base",
241     ]
242   }
244   android_library("java") {
245     java_files = [
246       "android/apk/src/org/chromium/mojo/shell/AndroidHandler.java",
247       "android/apk/src/org/chromium/mojo/shell/FileHelper.java",
248       "android/apk/src/org/chromium/mojo/shell/MojoShellActivity.java",
249       "android/apk/src/org/chromium/mojo/shell/MojoShellApplication.java",
250       "android/apk/src/org/chromium/mojo/shell/ShellMain.java",
251     ]
253     deps = [
254       "//base:base_java",
255     ]
256   }
258   android_resources("resources") {
259     resource_dirs = [ "android/apk/res" ]
260     custom_package = "org.chromium.mojo.shell"
261   }
263   mojo_shell_assets_dir = "$root_build_dir/mojo_shell_assets"
264   mojo_shell_test_assets_dir = "$root_build_dir/mojo_shell_test_assets"
266   copy_ex("copy_mojo_shell_assets") {
267     clear_dir = true
268     dest = mojo_shell_assets_dir
269     sources = [
270       "$root_out_dir/lib.stripped/libbootstrap.so",
271       "$root_out_dir/network_service.mojo",
272       "$root_out_dir/obj/mojo/shell/bootstrap_java.dex.jar",
273     ]
274   }
276   copy("copy_mojo_shell") {
277     sources = [
278       "$root_out_dir/exe.stripped/mojo_shell",
279     ]
280     outputs = [
281       "$root_out_dir/lib.stripped/libmojo_shell.so",
282     ]
283   }
285   copy_ex("copy_mojo_shell_test_assets") {
286     clear_dir = true
287     dest = mojo_shell_test_assets_dir
288     sources = [
289       "$root_out_dir/test_app.mojo",
290       "$root_out_dir/test_request_tracker_app.mojo",
291     ]
292   }
294   android_apk("mojo_shell_apk") {
295     apk_name = "MojoShell"
297     android_manifest = "android/apk/AndroidManifest.xml"
299     native_libs = [ "libmojo_shell.so" ]
301     asset_location = mojo_shell_assets_dir
303     deps = [
304       ":copy_mojo_shell",
305       ":copy_mojo_shell_assets",
306       ":java",
307       ":resources",
308       "//base:base_java",
309       "//components/native_viewport:native_viewport_java",
310       "//third_party/android_tools:google_play_services_default_resources",
311     ]
312   }
314   android_library("mojo_shell_tests_java") {
315     java_files =
316         [ "android/tests/src/org/chromium/mojo/shell/ShellTestBase.java" ]
318     deps = [
319       ":java",
320       "//base:base_java",
321     ]
322   }
325 mojom("child_process_bindings") {
326   sources = [
327     "child_process.mojom",
328   ]
330   deps = [
331     "//third_party/mojo/src/mojo/public/interfaces/application",
332   ]
335 test("tests") {
336   output_name = "mojo_shell_unittests"
338   sources = [
339     "child_process_host_unittest.cc",
340     "data_pipe_peek_unittest.cc",
341     "in_process_native_runner_unittest.cc",
342     "native_runner_unittest.cc",
343     "shell_test_base.cc",
344     "shell_test_base.h",
345     "shell_test_base_android.cc",
346     "shell_test_base_unittest.cc",
347     "shell_test_main.cc",
348     "url_resolver_unittest.cc",
349   ]
351   deps = [
352     ":in_process_native_runner",
353     ":lib",
354     "//base",
355     "//base:i18n",
356     "//base/test:test_support",
357     "//testing/gtest",
358     "//url",
359     "//mojo/common",
360     "//third_party/mojo/src/mojo/edk/system",
361     "//mojo/environment:chromium",
362     "//third_party/mojo/src/mojo/public/cpp/bindings",
363     "//mojo/services/test_service:bindings",
364     "//mojo/shell/application_manager",
365   ]
367   datadeps = [
368     "//mojo/services/test_service:test_app",
369     "//mojo/services/test_service:test_request_tracker_app",
370   ]
372   if (is_android) {
373     sources += [ "android/background_application_loader_unittest.cc" ]
375     deps += [ ":jni_headers" ]
377     apk_deps = [
378       ":copy_mojo_shell_test_assets",
379       ":mojo_shell_tests_java",
380     ]
382     apk_asset_location = mojo_shell_test_assets_dir
383   }
386 mojo_native_application("apptests") {
387   output_name = "shell_apptests"
389   testonly = true
391   sources = [
392     # TODO(jam): needs http_server service.
393     #"shell_apptest.cc",
394   ]
396   deps = [
397     "//base",
398     "//mojo/application",
399     "//mojo/application:test_support",
400     "//mojo/common:common",
401     "//third_party/mojo/src/mojo/public/cpp/bindings:callback",
402     "//third_party/mojo/src/mojo/public/cpp/environment",
403     "//third_party/mojo/src/mojo/public/cpp/system:system",
405     #"//mojo/services/http_server/public/cpp",
406     #"//mojo/services/http_server/public/interfaces",
407     "//mojo/services/network/public/interfaces",
408     "//mojo/shell/test:bindings",
409   ]
411   #data_deps = [ "//services/http_server:http_server($default_toolchain)" ]