Add abhijeet.k@samsung.com to AUTHORS list.
[chromium-blink-merge.git] / mojo / shell / BUILD.gn
blob1dbe6ad77363bd85d31e7590b2fba3330862c4c5
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     "app_child_process_host.cc",
112     "app_child_process_host.h",
113     "child_process.cc",
114     "child_process.h",
115     "child_process_host.cc",
116     "child_process_host.h",
117     "command_line_util.cc",
118     "command_line_util.h",
119     "context.cc",
120     "context.h",
121     "filename_util.cc",
122     "filename_util.h",
123     "out_of_process_native_runner.cc",
124     "out_of_process_native_runner.h",
125     "task_runners.cc",
126     "task_runners.h",
127     "url_resolver.cc",
128     "url_resolver.h",
129   ]
131   deps = [
132     ":app_child_process_bindings",
133     ":init",
134     ":in_process_native_runner",
135     ":native_application_support",
136     "//base",
137     "//base/third_party/dynamic_annotations",
138     "//base:base_static",
139     "//mojo/application",
140     "//mojo/common",
141     "//mojo/common:tracing_impl",
142     "//third_party/mojo/src/mojo/edk/system",
143     "//third_party/mojo/src/mojo/public/cpp/bindings",
144     "//third_party/mojo/src/mojo/public/interfaces/application",
145     "//mojo/services/network/public/interfaces",
146     "//mojo/shell/application_manager",
147     "//mojo/services/tracing:bindings",
148     "//url",
149   ]
151   public_deps = [
152     ":switches",
153   ]
155   if (is_android) {
156     sources += [
157       "android/android_handler.cc",
158       "android/android_handler.h",
159       "android/android_handler_loader.cc",
160       "android/android_handler_loader.h",
161       "android/background_application_loader.cc",
162       "android/background_application_loader.h",
163       "android/keyboard_impl.cc",
164       "android/keyboard_impl.h",
165       "android/native_viewport_application_loader.cc",
166       "android/native_viewport_application_loader.h",
167       "android/ui_application_loader_android.cc",
168       "android/ui_application_loader_android.h",
169     ]
171     deps += [
172       ":jni_headers",
173       ":run_android_application_function",
174       "//mojo/application:content_handler",
175       "//mojo/services/keyboard/public/interfaces",
176       "//mojo/services/gles2",
177       "//mojo/services/native_viewport:lib",
178     ]
179   }
181   # This target includes some files behind #ifdef OS... guards. Since gn is not
182   # smart enough to understand preprocess includes, it does complains about
183   # these includes when not using the build files for that OS. Suppress checking
184   # so we can enable checking for the rest of the targets in this file.
185   # TODO: Might be better to split the files with OS-specific includes out to a
186   # separate source_set so we can leave checking on for the rest of the target.
187   check_includes = false
190 source_set("native_application_support") {
191   sources = [
192     "native_application_support.cc",
193     "native_application_support.h",
194   ]
196   public_deps = [
197     "//third_party/mojo/src/mojo/public/cpp/bindings",
198   ]
200   deps = [
201     "//base",
202     "//mojo/gles2",
203   ]
205   # This target has to include the public thunk headers, which generally
206   # shouldn't be included without picking an implementation. We are providing
207   # the implementation but the thunk header target cannot declare that we are
208   # permitted to include it since it's in the public SDK and we are not.
209   # Suppress include checking so we can still check the rest of the targets in
210   # this file.
211   check_includes = false
214 source_set("switches") {
215   sources = [
216     "switches.cc",
217     "switches.h",
218   ]
220   deps = [
221     "//base",
222   ]
225 if (is_android) {
226   generate_jni("jni_headers") {
227     sources = [
228       "android/apk/src/org/chromium/mojo/shell/AndroidHandler.java",
229       "android/apk/src/org/chromium/mojo/shell/Bootstrap.java",
230       "android/apk/src/org/chromium/mojo/shell/Keyboard.java",
231       "android/apk/src/org/chromium/mojo/shell/ShellMain.java",
232       "android/tests/src/org/chromium/mojo/shell/ShellTestBase.java",
233     ]
234     jni_package = "mojo/shell"
235   }
237   android_library("bootstrap_java") {
238     java_files = [ "android/apk/src/org/chromium/mojo/shell/Bootstrap.java" ]
240     deps = [
241       "//base:base_java",
242     ]
244     dex_path = "$target_out_dir/bootstrap_java.dex.jar"
245   }
247   shared_library("bootstrap") {
248     sources = [
249       "android/bootstrap.cc",
250     ]
251     deps = [
252       ":jni_headers",
253       ":lib",
254       ":run_android_application_function",
255       "//base",
256     ]
257   }
259   # Shared header between the bootstrap and the main shell .so.
260   source_set("run_android_application_function") {
261     sources = [
262       "android/run_android_application_function.h",
263     ]
265     deps = [
266       "//base",
267     ]
268   }
270   android_library("java") {
271     java_files = [
272       "android/apk/src/org/chromium/mojo/shell/AndroidHandler.java",
273       "android/apk/src/org/chromium/mojo/shell/FileHelper.java",
274       "android/apk/src/org/chromium/mojo/shell/Keyboard.java",
275       "android/apk/src/org/chromium/mojo/shell/MojoShellActivity.java",
276       "android/apk/src/org/chromium/mojo/shell/MojoShellApplication.java",
277       "android/apk/src/org/chromium/mojo/shell/ShellMain.java",
278     ]
280     deps = [
281       "//base:base_java",
282     ]
283   }
285   android_resources("resources") {
286     resource_dirs = [ "android/apk/res" ]
287     custom_package = "org.chromium.mojo.shell"
288   }
290   mojo_shell_assets_dir = "$root_build_dir/mojo_shell_assets"
291   mojo_shell_test_assets_dir = "$root_build_dir/mojo_shell_test_assets"
293   copy_ex("copy_mojo_shell_assets") {
294     clear_dir = true
295     dest = mojo_shell_assets_dir
296     sources = [
297       "$root_out_dir/lib.stripped/libbootstrap.so",
298       "$root_out_dir/network_service.mojo",
299       "$root_out_dir/obj/mojo/shell/bootstrap_java.dex.jar",
300     ]
301   }
303   copy("copy_mojo_shell") {
304     sources = [
305       "$root_out_dir/exe.stripped/mojo_shell",
306     ]
307     outputs = [
308       "$root_out_dir/lib.stripped/libmojo_shell.so",
309     ]
310   }
312   copy_ex("copy_mojo_shell_test_assets") {
313     clear_dir = true
314     dest = mojo_shell_test_assets_dir
315     sources = [
316       "$root_out_dir/test_app.mojo",
317       "$root_out_dir/test_request_tracker_app.mojo",
318     ]
319   }
321   android_apk("mojo_shell_apk") {
322     apk_name = "MojoShell"
324     android_manifest = "android/apk/AndroidManifest.xml"
326     native_libs = [ "libmojo_shell.so" ]
328     asset_location = mojo_shell_assets_dir
330     deps = [
331       ":copy_mojo_shell",
332       ":copy_mojo_shell_assets",
333       ":java",
334       ":resources",
335       "//base:base_java",
336       "//mojo/services/native_viewport:native_viewport_java",
337       "//third_party/android_tools:google_play_services_default_resources",
338     ]
339   }
341   android_library("mojo_shell_tests_java") {
342     java_files =
343         [ "android/tests/src/org/chromium/mojo/shell/ShellTestBase.java" ]
345     deps = [
346       ":java",
347       "//base:base_java",
348     ]
349   }
352 mojom("app_child_process_bindings") {
353   sources = [
354     "app_child_process.mojom",
355   ]
357   deps = [
358     "//third_party/mojo/src/mojo/public/interfaces/application",
359   ]
362 # GYP version: mojo/mojo.gyp:mojo_shell_tests
363 test("mojo_shell_tests") {
364   sources = [
365     "app_child_process_host_unittest.cc",
366     "command_line_util_unittest.cc",
367     "data_pipe_peek_unittest.cc",
368     "in_process_native_runner_unittest.cc",
369     "native_runner_unittest.cc",
370     "shell_test_base.cc",
371     "shell_test_base.h",
372     "shell_test_base_android.cc",
373     "shell_test_base_unittest.cc",
374     "shell_test_main.cc",
375     "url_resolver_unittest.cc",
376   ]
378   deps = [
379     ":in_process_native_runner",
380     ":lib",
381     "//base",
382     "//base:i18n",
383     "//base/test:test_support",
384     "//testing/gtest",
385     "//url",
386     "//mojo/common",
387     "//third_party/mojo/src/mojo/edk/system",
388     "//mojo/environment:chromium",
389     "//third_party/mojo/src/mojo/public/cpp/bindings",
390     "//mojo/services/test_service:bindings",
391     "//mojo/shell/application_manager",
392   ]
394   datadeps = [
395     "//mojo/services/test_service:test_app",
396     "//mojo/services/test_service:test_request_tracker_app",
397   ]
399   if (is_android) {
400     sources += [ "android/background_application_loader_unittest.cc" ]
402     deps += [ ":jni_headers" ]
404     apk_deps = [
405       ":copy_mojo_shell_test_assets",
406       ":mojo_shell_tests_java",
407     ]
409     apk_asset_location = mojo_shell_test_assets_dir
410   }
413 # GYP version: mojo/mojo.gyp:mojo_shell_test_support
414 source_set("test_support") {
415   sources = [
416     "shell_test_helper.cc",
417     "shell_test_helper.h",
418   ]
420   deps = [
421     ":init",
422     ":lib",
423     "//base",
424     "//third_party/mojo/src/mojo/edk/system",
425     "//mojo/shell/application_manager",
426   ]
429 mojo_native_application("apptests") {
430   output_name = "shell_apptests"
432   testonly = true
434   sources = [
435     # TODO(jam): needs http_server service.
436     #"shell_apptest.cc",
437   ]
439   deps = [
440     "//base",
441     "//mojo/application",
442     "//mojo/application:test_support",
443     "//mojo/common:common",
444     "//third_party/mojo/src/mojo/public/cpp/bindings:callback",
445     "//third_party/mojo/src/mojo/public/cpp/environment",
446     "//third_party/mojo/src/mojo/public/cpp/system:system",
448     #"//mojo/services/http_server/public/cpp",
449     #"//mojo/services/http_server/public/interfaces",
450     "//mojo/services/network/public/interfaces",
451     "//mojo/shell/test:bindings",
452   ]
454   #data_deps = [ "//services/http_server:http_server($default_toolchain)" ]