blob: a975bceb574aef644f5ccd47511b8cad5fd4fa68 [file] [log] [blame]
# Copyright 2014 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
import("//mojo/generate_mojo_shell_assets_list.gni")
import("//mojo/public/mojo_application.gni")
import("//testing/test.gni")
import("//third_party/mojo/src/mojo/public/tools/bindings/mojom.gni")
# We don't support building in the component build since mojo apps are
# inherently components.
assert(!is_component_build)
group("runner") {
testonly = true
deps = [
":mojo_runner",
]
if (is_android) {
deps += [ ":mojo_runner_apk" ]
}
}
if (is_android) {
import("//build/config/android/config.gni")
import("//build/config/android/rules.gni")
}
source_set("mojo_runner_lib") {
sources = []
deps = [
":lib",
"//base",
"//build/config/sanitizers:deps",
"//mojo/common",
"//mojo/environment:chromium",
]
if (!is_android) {
sources += [
"desktop/launcher_process.cc",
"desktop/launcher_process.h",
"desktop/main.cc",
]
deps += [ "//components/tracing:startup_tracing" ]
} else {
sources += [
"android/context_init.h",
"android/library_loader.cc",
"android/main.cc",
"android/main.h",
]
deps += [
":jni_headers",
"//components/view_manager",
"//mojo/shell",
"//ui/gl",
]
}
}
executable("mojo_runner") {
deps = [
":mojo_runner_lib",
]
if (is_android) {
sources = [
"android/context_init.cc",
]
# On android, the executable is also the native library used by the apk.
# It means dynamic symbols must be preserved and exported.
ldflags = [ "-Wl,--export-dynamic" ]
}
deps += [ "//build/config/sanitizers:deps" ]
}
source_set("in_process_native_runner") {
sources = [
"in_process_native_runner.cc",
"in_process_native_runner.h",
]
public_deps = [
":native_application_support",
"//mojo/shell",
]
deps = [
"//base",
]
}
source_set("lib") {
sources = [
"child_process.cc",
"child_process.h",
"child_process_host.cc",
"child_process_host.h",
"context.cc",
"context.h",
"init.cc",
"init.h",
"out_of_process_native_runner.cc",
"out_of_process_native_runner.h",
"scoped_user_data_dir.cc",
"scoped_user_data_dir.h",
"task_runners.cc",
"task_runners.h",
"url_resolver.cc",
"url_resolver.h",
]
deps = [
":child_process_bindings",
":in_process_native_runner",
":native_application_support",
"//base",
"//base/third_party/dynamic_annotations",
"//base:base_static",
"//components/devtools_service/public/cpp",
"//components/devtools_service/public/interfaces",
"//mojo/application/public/cpp",
"//mojo/common:tracing_impl",
"//mojo/util:filename_util",
"//third_party/mojo/src/mojo/edk/system",
"//mojo/services/network/public/interfaces",
"//mojo/shell",
"//mojo/services/tracing:bindings",
"//ui/gl",
"//url",
]
public_deps = [
":switches",
]
data_deps = [
"//components/devtools_service",
"//mojo/services/tracing",
]
if (is_android) {
sources += [
"android/android_handler.cc",
"android/android_handler.h",
"android/android_handler_loader.cc",
"android/android_handler_loader.h",
"android/background_application_loader.cc",
"android/background_application_loader.h",
"android/ui_application_loader_android.cc",
"android/ui_application_loader_android.h",
]
deps += [
":jni_headers",
":run_android_application_function",
"//components/view_manager/gles2",
"//components/view_manager/native_viewport",
"//mojo/application/public/cpp:content_handler",
]
}
# This target includes some files behind #ifdef OS... guards. Since gn is not
# smart enough to understand preprocess includes, it does complains about
# these includes when not using the build files for that OS. Suppress checking
# so we can enable checking for the rest of the targets in this file.
# TODO: Might be better to split the files with OS-specific includes out to a
# separate source_set so we can leave checking on for the rest of the target.
check_includes = false
}
source_set("native_application_support") {
sources = [
"native_application_support.cc",
"native_application_support.h",
"platform_handle_impl.cc",
]
public_deps = [
"//third_party/mojo/src/mojo/public/cpp/bindings",
]
deps = [
"//base",
"//mojo/gles2",
"//mojo/platform_handle:defs",
"//mojo/shell",
]
# This target has to include the public thunk headers, which generally
# shouldn't be included without picking an implementation. We are providing
# the implementation but the thunk header target cannot declare that we are
# permitted to include it since it's in the public SDK and we are not.
# Suppress include checking so we can still check the rest of the targets in
# this file.
check_includes = false
}
source_set("switches") {
sources = [
"switches.cc",
"switches.h",
]
deps = [
"//base",
]
}
if (is_android) {
generate_jni("jni_headers") {
sources = [
"android/apk/src/org/chromium/mojo/shell/AndroidHandler.java",
"android/apk/src/org/chromium/mojo/shell/Bootstrap.java",
"android/apk/src/org/chromium/mojo/shell/ShellMain.java",
"android/tests/src/org/chromium/mojo/shell/ShellTestBase.java",
]
jni_package = "mojo/shell"
}
android_library("bootstrap_java") {
java_files = [ "android/apk/src/org/chromium/mojo/shell/Bootstrap.java" ]
deps = [
"//base:base_java",
]
dex_path = "$target_out_dir/bootstrap_java.dex.jar"
}
shared_library("bootstrap") {
sources = [
"android/bootstrap.cc",
]
deps = [
":jni_headers",
":lib",
":run_android_application_function",
"//base",
]
}
# Shared header between the bootstrap and the main shell .so.
source_set("run_android_application_function") {
sources = [
"android/run_android_application_function.h",
]
deps = [
"//base",
]
}
android_library("java") {
java_files = [
"android/apk/src/org/chromium/mojo/shell/AndroidHandler.java",
"android/apk/src/org/chromium/mojo/shell/FileHelper.java",
"android/apk/src/org/chromium/mojo/shell/MojoShellActivity.java",
"android/apk/src/org/chromium/mojo/shell/MojoShellApplication.java",
"android/apk/src/org/chromium/mojo/shell/ShellMain.java",
]
deps = [
":resources",
"//base:base_java",
]
}
android_resources("resources") {
resource_dirs = [ "android/apk/res" ]
custom_package = "org.chromium.mojo.shell"
}
mojo_runner_assets_dir = "$root_build_dir/mojo_runner_assets"
mojo_runner_test_assets_dir = "$root_build_dir/mojo_runner_test_assets"
copy_ex("copy_mojo_runner_assets") {
clear_dir = true
dest = mojo_runner_assets_dir
deps = [
":bootstrap",
":bootstrap_java",
":copy_mojo_runner",
"//mojo/services/network",
]
sources = [
"$root_out_dir/lib.stripped/libbootstrap$android_product_extension",
"$root_out_dir/obj/mojo/runner/bootstrap_java.dex.jar",
]
# Directories can't be specified as sources so pass manually to the script.
args = [ "--files=" +
rebase_path("$root_out_dir/network_service", root_build_dir) ]
}
generate_mojo_shell_assets_list("build_mojo_runner_assets") {
deps = [
":copy_mojo_runner_assets",
]
dir = mojo_runner_assets_dir
}
copy("copy_mojo_runner") {
sources = [
"$root_out_dir/exe.stripped/mojo_runner",
]
outputs = [
"$root_out_dir/lib.stripped/libmojo_runner$android_product_extension",
]
deps = [
":mojo_runner",
]
}
copy_ex("copy_mojo_runner_test_assets") {
clear_dir = true
dest = mojo_runner_test_assets_dir
deps = [
"//mojo/services/test_service:test_app",
"//mojo/services/test_service:test_request_tracker_app",
]
# Directories can't be specified as sources so pass manually to the script.
args = [
"--files=" + rebase_path("$root_out_dir/test_app", root_build_dir),
"--files=" +
rebase_path("$root_out_dir/test_request_tracker_app", root_build_dir),
]
}
android_apk("mojo_runner_apk") {
apk_name = "MojoRunner"
android_manifest = "android/apk/AndroidManifest.xml"
native_libs = [ "libmojo_runner$android_product_extension" ]
asset_location = mojo_runner_assets_dir
deps = [
":build_mojo_runner_assets",
":copy_mojo_runner",
":java",
":resources",
"//base:base_java",
"//third_party/android_tools:google_play_services_default_resources",
"//ui/platform_window/android:platform_window_java",
]
}
generate_mojo_shell_assets_list("build_mojo_runner_test_assets") {
deps = [
":copy_mojo_runner_test_assets",
]
dir = mojo_runner_test_assets_dir
}
android_library("mojo_runner_tests_java") {
java_files =
[ "android/tests/src/org/chromium/mojo/shell/ShellTestBase.java" ]
deps = [
":java",
"//base:base_java",
]
}
}
mojom("child_process_bindings") {
sources = [
"child_process.mojom",
]
deps = [
"//mojo/application/public/interfaces",
]
import_dirs = [ "//mojo/services" ]
}
test("mojo_runner_unittests") {
sources = [
"child_process_host_unittest.cc",
"data_pipe_peek_unittest.cc",
"in_process_native_runner_unittest.cc",
"native_runner_unittest.cc",
"shell_test_base.cc",
"shell_test_base.h",
"shell_test_base_android.cc",
"shell_test_base_unittest.cc",
"shell_test_main.cc",
"url_resolver_unittest.cc",
]
deps = [
":in_process_native_runner",
":lib",
"//base",
"//base:i18n",
"//base/test:test_support",
"//mojo/common",
"//mojo/environment:chromium",
"//mojo/services/test_service:bindings",
"//mojo/shell",
"//mojo/util:filename_util",
"//testing/gtest",
"//third_party/mojo/src/mojo/edk/system",
"//third_party/mojo/src/mojo/public/cpp/bindings",
"//url",
]
data_deps = [
"//mojo/services/test_service:test_app",
"//mojo/services/test_service:test_request_tracker_app",
]
if (is_android) {
sources += [ "android/background_application_loader_unittest.cc" ]
deps += [ ":jni_headers" ]
apk_deps = [
":build_mojo_runner_test_assets",
":mojo_runner_tests_java",
]
apk_asset_location = mojo_runner_test_assets_dir
}
}
mojo_native_application("apptests") {
output_name = "runner_apptests"
testonly = true
sources = [
# TODO(jam): needs http_server service.
#"shell_apptest.cc",
]
deps = [
"//base",
"//mojo/application/public/cpp:test_support",
"//mojo/runner/test:bindings",
"//mojo/services/network/public/interfaces",
"//third_party/mojo/src/mojo/public/cpp/bindings:callback",
]
}