Remove 'RemoveTrailingSeparators' function from SimpleMenuModel
[chromium-blink-merge.git] / mojo / shell / BUILD.gn
blob10c5b2c0ef26b2e253716c4cc4f97b7f0b9c92fe
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   ]
23   if (is_android) {
24     deps += [
25       ":mojo_shell_apk",
26       ":mojo_shell_tests_apk",
27     ]
28   }
31 group("tests") {
32   testonly = true
33   deps = [
34     ":mojo_shell_tests",
35     "//mojo/shell/application_manager:mojo_application_manager_unittests",
36   ]
39 if (is_android) {
40   import("//build/config/android/config.gni")
41   import("//build/config/android/rules.gni")
44 executable("mojo_shell") {
45   sources = []
47   deps = [
48     ":init",
49     ":lib",
50     "//base",
51     "//build/config/sanitizers:deps",
52     "//mojo/common",
53     "//mojo/environment:chromium",
54   ]
56   if (!is_android) {
57     sources += [
58       "desktop/launcher_process.cc",
59       "desktop/launcher_process.h",
60       "desktop/main.cc",
61     ]
62   } else {
63     sources += [
64       "android/library_loader.cc",
65       "android/main.cc",
66       "android/main.h",
67     ]
69     # On android, the executable is also the native library used by the apk.
70     # It means dynamic symbols must be preserved and exported.
71     ldflags = [ "-Wl,--export-dynamic" ]
73     deps += [
74       ":jni_headers",
75       "//mojo/services/native_viewport:lib",
76       "//mojo/shell/application_manager",
77       "//ui/gl",
78     ]
79   }
82 source_set("init") {
83   sources = [
84     "init.cc",
85     "init.h",
86   ]
88   deps = [
89     "//base",
90   ]
93 source_set("in_process_native_runner") {
94   sources = [
95     "in_process_native_runner.cc",
96     "in_process_native_runner.h",
97   ]
99   public_deps = [
100     ":native_application_support",
101     "//mojo/shell/application_manager",
102   ]
104   deps = [
105     "//base",
106   ]
109 source_set("lib") {
110   sources = [
111     "child_process.cc",
112     "child_process.h",
113     "child_process_host.cc",
114     "child_process_host.h",
115     "context.cc",
116     "context.h",
117     "filename_util.cc",
118     "filename_util.h",
119     "out_of_process_native_runner.cc",
120     "out_of_process_native_runner.h",
121     "task_runners.cc",
122     "task_runners.h",
123     "url_resolver.cc",
124     "url_resolver.h",
125   ]
127   deps = [
128     ":child_process_bindings",
129     ":init",
130     ":in_process_native_runner",
131     ":native_application_support",
132     "//base",
133     "//base/third_party/dynamic_annotations",
134     "//base:base_static",
135     "//mojo/application",
136     "//mojo/common",
137     "//mojo/common:tracing_impl",
138     "//third_party/mojo/src/mojo/edk/system",
139     "//third_party/mojo/src/mojo/public/cpp/bindings",
140     "//third_party/mojo/src/mojo/public/interfaces/application",
141     "//mojo/services/network/public/interfaces",
142     "//mojo/shell/application_manager",
143     "//mojo/services/tracing:bindings",
144     "//url",
145   ]
147   public_deps = [
148     ":switches",
149   ]
151   if (is_android) {
152     sources += [
153       "android/android_handler.cc",
154       "android/android_handler.h",
155       "android/android_handler_loader.cc",
156       "android/android_handler_loader.h",
157       "android/background_application_loader.cc",
158       "android/background_application_loader.h",
159       "android/keyboard_impl.cc",
160       "android/keyboard_impl.h",
161       "android/native_viewport_application_loader.cc",
162       "android/native_viewport_application_loader.h",
163       "android/ui_application_loader_android.cc",
164       "android/ui_application_loader_android.h",
165     ]
167     deps += [
168       ":jni_headers",
169       ":run_android_application_function",
170       "//mojo/application:content_handler",
171       "//mojo/services/keyboard/public/interfaces",
172       "//mojo/services/gles2",
173       "//mojo/services/native_viewport:lib",
174     ]
175   }
177   # This target includes some files behind #ifdef OS... guards. Since gn is not
178   # smart enough to understand preprocess includes, it does complains about
179   # these includes when not using the build files for that OS. Suppress checking
180   # so we can enable checking for the rest of the targets in this file.
181   # TODO: Might be better to split the files with OS-specific includes out to a
182   # separate source_set so we can leave checking on for the rest of the target.
183   check_includes = false
186 source_set("native_application_support") {
187   sources = [
188     "native_application_support.cc",
189     "native_application_support.h",
190   ]
192   public_deps = [
193     "//third_party/mojo/src/mojo/public/cpp/bindings",
194   ]
196   deps = [
197     "//base",
198     "//mojo/gles2",
199   ]
201   # This target has to include the public thunk headers, which generally
202   # shouldn't be included without picking an implementation. We are providing
203   # the implementation but the thunk header target cannot declare that we are
204   # permitted to include it since it's in the public SDK and we are not.
205   # Suppress include checking so we can still check the rest of the targets in
206   # this file.
207   check_includes = false
210 source_set("switches") {
211   sources = [
212     "switches.cc",
213     "switches.h",
214   ]
216   deps = [
217     "//base",
218   ]
221 if (is_android) {
222   generate_jni("jni_headers") {
223     sources = [
224       "android/apk/src/org/chromium/mojo/shell/AndroidHandler.java",
225       "android/apk/src/org/chromium/mojo/shell/Bootstrap.java",
226       "android/apk/src/org/chromium/mojo/shell/Keyboard.java",
227       "android/apk/src/org/chromium/mojo/shell/ShellMain.java",
228       "android/tests/src/org/chromium/mojo/shell/ShellTestBase.java",
229     ]
230     jni_package = "mojo/shell"
231   }
233   android_library("bootstrap_java") {
234     java_files = [ "android/apk/src/org/chromium/mojo/shell/Bootstrap.java" ]
236     deps = [
237       "//base:base_java",
238     ]
240     dex_path = "$target_out_dir/bootstrap_java.dex.jar"
241   }
243   shared_library("bootstrap") {
244     sources = [
245       "android/bootstrap.cc",
246     ]
247     deps = [
248       ":jni_headers",
249       ":lib",
250       ":run_android_application_function",
251       "//base",
252     ]
253   }
255   # Shared header between the bootstrap and the main shell .so.
256   source_set("run_android_application_function") {
257     sources = [
258       "android/run_android_application_function.h",
259     ]
261     deps = [
262       "//base",
263     ]
264   }
266   android_library("java") {
267     java_files = [
268       "android/apk/src/org/chromium/mojo/shell/AndroidHandler.java",
269       "android/apk/src/org/chromium/mojo/shell/FileHelper.java",
270       "android/apk/src/org/chromium/mojo/shell/Keyboard.java",
271       "android/apk/src/org/chromium/mojo/shell/MojoShellActivity.java",
272       "android/apk/src/org/chromium/mojo/shell/MojoShellApplication.java",
273       "android/apk/src/org/chromium/mojo/shell/ShellMain.java",
274     ]
276     deps = [
277       "//base:base_java",
278     ]
279   }
281   android_resources("resources") {
282     resource_dirs = [ "android/apk/res" ]
283     custom_package = "org.chromium.mojo.shell"
284   }
286   mojo_shell_assets_dir = "$root_build_dir/mojo_shell_assets"
287   mojo_shell_test_assets_dir = "$root_build_dir/mojo_shell_test_assets"
289   copy_ex("copy_mojo_shell_assets") {
290     clear_dir = true
291     dest = mojo_shell_assets_dir
292     sources = [
293       "$root_out_dir/lib.stripped/libbootstrap.so",
294       "$root_out_dir/network_service.mojo",
295       "$root_out_dir/obj/mojo/shell/bootstrap_java.dex.jar",
296     ]
297   }
299   copy("copy_mojo_shell") {
300     sources = [
301       "$root_out_dir/exe.stripped/mojo_shell",
302     ]
303     outputs = [
304       "$root_out_dir/lib.stripped/libmojo_shell.so",
305     ]
306   }
308   copy_ex("copy_mojo_shell_test_assets") {
309     clear_dir = true
310     dest = mojo_shell_test_assets_dir
311     sources = [
312       "$root_out_dir/test_app.mojo",
313       "$root_out_dir/test_request_tracker_app.mojo",
314     ]
315   }
317   android_apk("mojo_shell_apk") {
318     apk_name = "MojoShell"
320     android_manifest = "android/apk/AndroidManifest.xml"
322     native_libs = [ "libmojo_shell.so" ]
324     asset_location = mojo_shell_assets_dir
326     deps = [
327       ":copy_mojo_shell",
328       ":copy_mojo_shell_assets",
329       ":java",
330       ":resources",
331       "//base:base_java",
332       "//mojo/services/native_viewport:native_viewport_java",
333       "//third_party/android_tools:google_play_services_default_resources",
334     ]
335   }
337   android_library("mojo_shell_tests_java") {
338     java_files =
339         [ "android/tests/src/org/chromium/mojo/shell/ShellTestBase.java" ]
341     deps = [
342       ":java",
343       "//base:base_java",
344     ]
345   }
348 mojom("child_process_bindings") {
349   sources = [
350     "child_process.mojom",
351   ]
353   deps = [
354     "//third_party/mojo/src/mojo/public/interfaces/application",
355   ]
358 # GYP version: mojo/mojo.gyp:mojo_shell_tests
359 test("mojo_shell_tests") {
360   sources = [
361     "child_process_host_unittest.cc",
362     "data_pipe_peek_unittest.cc",
363     "in_process_native_runner_unittest.cc",
364     "native_runner_unittest.cc",
365     "shell_test_base.cc",
366     "shell_test_base.h",
367     "shell_test_base_android.cc",
368     "shell_test_base_unittest.cc",
369     "shell_test_main.cc",
370     "url_resolver_unittest.cc",
371   ]
373   deps = [
374     ":in_process_native_runner",
375     ":lib",
376     "//base",
377     "//base:i18n",
378     "//base/test:test_support",
379     "//testing/gtest",
380     "//url",
381     "//mojo/common",
382     "//third_party/mojo/src/mojo/edk/system",
383     "//mojo/environment:chromium",
384     "//third_party/mojo/src/mojo/public/cpp/bindings",
385     "//mojo/services/test_service:bindings",
386     "//mojo/shell/application_manager",
387   ]
389   datadeps = [
390     "//mojo/services/test_service:test_app",
391     "//mojo/services/test_service:test_request_tracker_app",
392   ]
394   if (is_android) {
395     sources += [ "android/background_application_loader_unittest.cc" ]
397     deps += [ ":jni_headers" ]
399     apk_deps = [
400       ":copy_mojo_shell_test_assets",
401       ":mojo_shell_tests_java",
402     ]
404     apk_asset_location = mojo_shell_test_assets_dir
405   }
408 # GYP version: mojo/mojo.gyp:mojo_shell_test_support
409 source_set("test_support") {
410   sources = [
411     "shell_test_helper.cc",
412     "shell_test_helper.h",
413   ]
415   deps = [
416     ":init",
417     ":lib",
418     "//base",
419     "//third_party/mojo/src/mojo/edk/system",
420     "//mojo/shell/application_manager",
421   ]
424 mojo_native_application("apptests") {
425   output_name = "shell_apptests"
427   testonly = true
429   sources = [
430     # TODO(jam): needs http_server service.
431     #"shell_apptest.cc",
432   ]
434   deps = [
435     "//base",
436     "//mojo/application",
437     "//mojo/application:test_support",
438     "//mojo/common:common",
439     "//third_party/mojo/src/mojo/public/cpp/bindings:callback",
440     "//third_party/mojo/src/mojo/public/cpp/environment",
441     "//third_party/mojo/src/mojo/public/cpp/system:system",
443     #"//mojo/services/http_server/public/cpp",
444     #"//mojo/services/http_server/public/interfaces",
445     "//mojo/services/network/public/interfaces",
446     "//mojo/shell/test:bindings",
447   ]
449   #data_deps = [ "//services/http_server:http_server($default_toolchain)" ]