Add long running gmail memory benchmark for background tab.
[chromium-blink-merge.git] / mojo / runner / BUILD.gn
blobeacefb61a87f2ac52f3b86e200deb4492005507f
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("//mojo/generate_mojo_shell_assets_list.gni")
6 import("//mojo/public/mojo_application.gni")
7 import("//testing/test.gni")
8 import("//third_party/mojo/src/mojo/public/tools/bindings/mojom.gni")
10 # We don't support building in the component build since mojo apps are
11 # inherently components.
12 assert(!is_component_build)
14 group("runner") {
15   testonly = true
17   deps = [
18     ":mojo_runner",
19   ]
22 if (is_android) {
23   import("//build/config/android/config.gni")
24   import("//build/config/android/rules.gni")
27 source_set("mojo_runner_lib") {
28   sources = []
30   deps = [
31     ":lib",
32     "//base",
33     "//build/config/sanitizers:deps",
34     "//mojo/common",
35     "//mojo/environment:chromium",
36   ]
38   if (!is_android) {
39     sources += [
40       "desktop/launcher_process.cc",
41       "desktop/launcher_process.h",
42       "desktop/main.cc",
43     ]
44     deps += [ "//components/tracing:startup_tracing" ]
45   } else {
46     sources += [
47       "android/context_init.h",
48       "android/library_loader.cc",
49       "android/main.cc",
50       "android/main.h",
51     ]
53     deps += [
54       ":jni_headers",
55       "//components/view_manager",
56       "//mojo/shell",
57       "//ui/gl",
58       "//ui/platform_window/android",
59     ]
60   }
63 executable("mojo_runner") {
64   deps = [
65     ":mojo_runner_lib",
66   ]
68   if (is_android) {
69     sources = [
70       "android/context_init.cc",
71     ]
73     # On android, the executable is also the native library used by the apk.
74     # It means dynamic symbols must be preserved and exported.
75     ldflags = [ "-Wl,--export-dynamic" ]
76   }
78   deps += [ "//build/config/sanitizers:deps" ]
81 source_set("in_process_native_runner") {
82   sources = [
83     "in_process_native_runner.cc",
84     "in_process_native_runner.h",
85   ]
87   public_deps = [
88     ":native_application_support",
89     "//mojo/shell",
90   ]
92   deps = [
93     "//base",
94   ]
97 source_set("lib") {
98   sources = [
99     "child_process.cc",
100     "child_process.h",
101     "child_process_host.cc",
102     "child_process_host.h",
103     "context.cc",
104     "context.h",
105     "init.cc",
106     "init.h",
107     "out_of_process_native_runner.cc",
108     "out_of_process_native_runner.h",
109     "scoped_user_data_dir.cc",
110     "scoped_user_data_dir.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     "//components/devtools_service/public/cpp",
125     "//components/devtools_service/public/interfaces",
126     "//mojo/application/public/cpp",
127     "//mojo/common:tracing_impl",
128     "//mojo/util:filename_util",
129     "//third_party/mojo/src/mojo/edk/system",
130     "//mojo/services/network/public/interfaces",
131     "//mojo/shell",
132     "//mojo/services/tracing:bindings",
133     "//ui/gl",
134     "//url",
135   ]
137   if (is_linux && !is_android) {
138     sources += [
139       "linux_sandbox.cc",
140       "linux_sandbox.h",
141     ]
143     deps += [
144       "//sandbox/linux:sandbox",
145       "//sandbox/linux:sandbox_services",
146     ]
147   }
149   public_deps = [
150     ":switches",
151   ]
153   data_deps = [
154     "//components/devtools_service",
155     "//mojo/services/tracing",
156   ]
158   if (is_android) {
159     sources += [
160       "android/android_handler.cc",
161       "android/android_handler.h",
162       "android/android_handler_loader.cc",
163       "android/android_handler_loader.h",
164       "android/background_application_loader.cc",
165       "android/background_application_loader.h",
166       "android/ui_application_loader_android.cc",
167       "android/ui_application_loader_android.h",
168     ]
170     deps += [
171       ":jni_headers",
172       ":run_android_application_function",
173       "//components/view_manager/gles2",
174       "//components/view_manager/native_viewport",
175       "//mojo/application/public/cpp:content_handler",
176     ]
177   }
179   # This target includes some files behind #ifdef OS... guards. Since gn is not
180   # smart enough to understand preprocess includes, it does complains about
181   # these includes when not using the build files for that OS. Suppress checking
182   # so we can enable checking for the rest of the targets in this file.
183   # TODO: Might be better to split the files with OS-specific includes out to a
184   # separate source_set so we can leave checking on for the rest of the target.
185   check_includes = false
188 source_set("native_application_support") {
189   sources = [
190     "native_application_support.cc",
191     "native_application_support.h",
192     "platform_handle_impl.cc",
193   ]
195   public_deps = [
196     "//third_party/mojo/src/mojo/public/cpp/bindings",
197   ]
199   deps = [
200     "//base",
201     "//mojo/gles2",
202     "//mojo/platform_handle:defs",
203     "//mojo/shell",
204   ]
206   # This target has to include the public thunk headers, which generally
207   # shouldn't be included without picking an implementation. We are providing
208   # the implementation but the thunk header target cannot declare that we are
209   # permitted to include it since it's in the public SDK and we are not.
210   # Suppress include checking so we can still check the rest of the targets in
211   # this file.
212   check_includes = false
215 source_set("switches") {
216   sources = [
217     "switches.cc",
218     "switches.h",
219   ]
221   deps = [
222     "//base",
223   ]
226 if (is_android) {
227   generate_jni("jni_headers") {
228     sources = [
229       "android/apk/src/org/chromium/mojo/shell/AndroidHandler.java",
230       "android/apk/src/org/chromium/mojo/shell/Bootstrap.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/MojoShellActivity.java",
275       "android/apk/src/org/chromium/mojo/shell/MojoShellApplication.java",
276       "android/apk/src/org/chromium/mojo/shell/ShellMain.java",
277     ]
279     deps = [
280       ":resources",
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_runner_test_assets_dir = "$root_build_dir/mojo_runner_test_assets"
291   mojo_runner_apptests_assets_dir =
292       "$root_build_dir/mojo_runner_apptests_assets"
294   copy_ex("copy_mojo_runner_apptests_assets") {
295     testonly = true
296     clear_dir = true
297     dest = mojo_runner_apptests_assets_dir
299     deps = [
300       ":bootstrap",
301       ":bootstrap_java",
302       "//components/clipboard:apptests",
303       "//components/resource_provider:apptests",
304       "//components/view_manager:apptests",
305       "//mojo/services/network:apptests",
306     ]
308     sources = [
309       "$root_out_dir/lib.stripped/libbootstrap$android_product_extension",
310       "$root_out_dir/obj/mojo/runner/bootstrap_java.dex.jar",
311     ]
313     apptest_outputs = [
314       "clipboard",
315       "clipboard_apptests",
316       "resource_provider",
317       "resource_provider_apptests",
318       "view_manager_apptests",
319       "network_service",
320       "network_service_apptests",
321     ]
323     args = []
324     foreach(path, apptest_outputs) {
325       args +=
326           [ "--files=" + rebase_path("$root_out_dir/$path", root_build_dir) ]
327     }
328   }
330   generate_mojo_shell_assets_list("build_mojo_runner_apptests_assets") {
331     testonly = true
332     deps = [
333       ":copy_mojo_runner_apptests_assets",
334     ]
335     dir = mojo_runner_apptests_assets_dir
336   }
338   copy("copy_mojo_runner") {
339     sources = [
340       "$root_out_dir/exe.stripped/mojo_runner",
341     ]
342     outputs = [
343       "$root_out_dir/lib.stripped/libmojo_runner$android_product_extension",
344     ]
345     deps = [
346       ":mojo_runner",
347     ]
348   }
350   copy_ex("copy_mojo_runner_test_assets") {
351     testonly = true
352     clear_dir = true
353     dest = mojo_runner_test_assets_dir
354     deps = [
355       "//mojo/services/test_service:test_app",
356       "//mojo/services/test_service:test_request_tracker_app",
357     ]
359     # Directories can't be specified as sources so pass manually to the script.
360     args = [
361       "--files=" + rebase_path("$root_out_dir/test_app", root_build_dir),
362       "--files=" +
363           rebase_path("$root_out_dir/test_request_tracker_app", root_build_dir),
364     ]
365   }
367   android_apk("mojo_runner_apptests_apk") {
368     testonly = true
369     apk_name = "MojoRunnerApptests"
370     android_manifest = "android/apk/AndroidManifest.xml"
371     native_libs = [ "libmojo_runner$android_product_extension" ]
372     asset_location = mojo_runner_apptests_assets_dir
374     deps = [
375       ":build_mojo_runner_apptests_assets",
376       ":copy_mojo_runner",
377       ":java",
378       ":resources",
379       "//base:base_java",
380       "//third_party/android_tools:google_play_services_default_resources",
381       "//ui/platform_window/android:platform_window_java",
382     ]
383   }
385   generate_mojo_shell_assets_list("build_mojo_runner_test_assets") {
386     testonly = true
387     deps = [
388       ":copy_mojo_runner_test_assets",
389     ]
390     dir = mojo_runner_test_assets_dir
391   }
393   android_library("mojo_runner_tests_java") {
394     java_files =
395         [ "android/tests/src/org/chromium/mojo/shell/ShellTestBase.java" ]
397     deps = [
398       ":java",
399       "//base:base_java",
400     ]
401   }
404 mojom("child_process_bindings") {
405   sources = [
406     "child_process.mojom",
407   ]
409   deps = [
410     "//mojo/application/public/interfaces",
411   ]
413   import_dirs = [ "//mojo/services" ]
416 test("mojo_runner_unittests") {
417   sources = [
418     "child_process_host_unittest.cc",
419     "data_pipe_peek_unittest.cc",
420     "in_process_native_runner_unittest.cc",
421     "native_runner_unittest.cc",
422     "shell_test_base.cc",
423     "shell_test_base.h",
424     "shell_test_base_android.cc",
425     "shell_test_base_unittest.cc",
426     "shell_test_main.cc",
427     "url_resolver_unittest.cc",
428   ]
430   deps = [
431     ":in_process_native_runner",
432     ":lib",
433     "//base",
434     "//base:i18n",
435     "//base/test:test_support",
436     "//mojo/common",
437     "//mojo/environment:chromium",
438     "//mojo/services/test_service:bindings",
439     "//mojo/shell",
440     "//mojo/util:filename_util",
441     "//testing/gtest",
442     "//third_party/mojo/src/mojo/edk/system",
443     "//third_party/mojo/src/mojo/public/cpp/bindings",
444     "//url",
445   ]
447   data_deps = [
448     "//mojo/services/test_service:test_app",
449     "//mojo/services/test_service:test_request_tracker_app",
450   ]
452   if (is_android) {
453     sources += [ "android/background_application_loader_unittest.cc" ]
455     deps += [ ":jni_headers" ]
457     apk_deps = [
458       ":build_mojo_runner_test_assets",
459       ":mojo_runner_tests_java",
460     ]
462     apk_asset_location = mojo_runner_test_assets_dir
463   }
466 mojo_native_application("apptests") {
467   output_name = "runner_apptests"
469   testonly = true
471   sources = [
472     # TODO(jam): needs http_server service. http://crbug.com/479316
473     #"shell_apptest.cc",
474   ]
476   deps = [
477     "//base",
478     "//mojo/application/public/cpp:test_support",
479     "//mojo/runner/test:bindings",
480     "//mojo/services/network/public/interfaces",
481     "//third_party/mojo/src/mojo/public/cpp/bindings:callback",
482   ]