blob: d10dc287c2daa3c11bc751622cae782e4c9d09c4 [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("//build/config/ui.gni")
import("//mojo/public/mojo.gni")
import("//mojo/public/mojo_application.gni")
import("//mojo/public/tools/bindings/mojom.gni")
import("//mojo/tools/embed/rules.gni")
import("//testing/test.gni")
# We don't support building in the component build since mojo apps are
# inherently components.
assert(!is_component_build)
group("shell") {
testonly = true
deps = [
":mojo_shell",
":tests",
]
if (!is_win) {
deps += [ ":mojo_launcher" ]
}
if (is_android) {
deps += [
":mojo_shell_apk",
":mojo_shell_tests_apk",
]
}
}
group("tests") {
testonly = true
deps = [
":external_application_unittests",
":mojo_shell_tests",
"//shell/application_manager:mojo_application_manager_unittests",
]
}
if (is_android) {
import("//build/config/android/config.gni")
import("//build/config/android/rules.gni")
}
if (!mojo_use_prebuilt_mojo_shell) {
executable("mojo_shell") {
sources = []
deps = [
":init",
":lib",
"//base",
"//build/config/sanitizers:deps",
"//mojo/common",
"//mojo/environment:chromium",
]
if (!is_android) {
sources += [ "desktop/main.cc" ]
} else {
sources += [
"android/library_loader.cc",
"android/main.cc",
"android/main.h",
]
# 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 += [
":jni_headers",
"//services/native_viewport:lib",
"//shell/application_manager",
"//ui/gl",
]
}
}
} # !mojo_use_prebuilt_mojo_shell
executable("mojo_launcher") {
sources = [
"launcher_main.cc",
]
deps = [
":external_application_registrar_bindings",
":external_application_registrar_connection",
":init",
":in_process_native_runner",
"//base",
"//build/config/sanitizers:deps",
"//mojo/common",
"//mojo/edk/system",
"//mojo/environment:chromium",
"//url",
]
}
source_set("init") {
sources = [
"init.cc",
"init.h",
]
deps = [
"//base",
]
}
source_set("in_process_native_runner") {
sources = [
"in_process_native_runner.cc",
"in_process_native_runner.h",
]
public_deps = [
":native_application_support",
"//shell/application_manager",
]
deps = [
"//base",
]
}
source_set("lib") {
sources = [
"app_child_process.cc",
"app_child_process.h",
"app_child_process_host.cc",
"app_child_process_host.h",
"child_process.cc",
"child_process.h",
"child_process_host.cc",
"child_process_host.h",
"command_line_util.cc",
"command_line_util.h",
"context.cc",
"context.h",
"external_application_listener.cc",
"external_application_listener.h",
"filename_util.cc",
"filename_util.h",
"incoming_connection_listener.cc",
"incoming_connection_listener.h",
"out_of_process_native_runner.cc",
"out_of_process_native_runner.h",
"task_runners.cc",
"task_runners.h",
"url_resolver.cc",
"url_resolver.h",
]
deps = [
":app_child_process_bindings",
":external_application_registrar_bindings",
":init",
":in_process_native_runner",
":native_application_support",
"//base",
"//base/third_party/dynamic_annotations",
"//base:base_static",
"//mojo/application",
"//mojo/common",
"//mojo/common:tracing_impl",
"//mojo/edk/system",
"//mojo/public/cpp/bindings",
"//mojo/public/interfaces/application",
"//mojo/services/network/public/interfaces",
"//shell/application_manager",
"//shell/domain_socket",
"//services/tracing:bindings",
"//url",
]
public_deps = [
":switches",
]
if (is_win) {
deps -= [ "//shell/domain_socket" ]
}
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/keyboard_impl.cc",
"android/keyboard_impl.h",
"android/native_viewport_application_loader.cc",
"android/native_viewport_application_loader.h",
"android/ui_application_loader_android.cc",
"android/ui_application_loader_android.h",
]
deps += [
":jni_headers",
":run_android_application_function",
"//mojo/application:content_handler",
"//mojo/services/keyboard/public/interfaces",
"//services/gles2",
"//services/native_viewport:lib",
]
}
# 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",
]
public_deps = [
"//mojo/public/cpp/bindings",
]
deps = [
"//base",
"//mojo/gles2",
]
# 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/Keyboard.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/Keyboard.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 = [
"//base:base_java",
]
}
android_resources("resources") {
resource_dirs = [ "android/apk/res" ]
custom_package = "org.chromium.mojo.shell"
}
mojo_shell_assets_dir = "$root_build_dir/mojo_shell_assets"
mojo_shell_test_assets_dir = "$root_build_dir/mojo_shell_test_assets"
copy_ex("copy_mojo_shell_assets") {
clear_dir = true
dest = mojo_shell_assets_dir
sources = [
"$root_out_dir/lib.stripped/libbootstrap.so",
"$root_out_dir/network_service.mojo",
"$root_out_dir/obj/shell/bootstrap_java.dex.jar",
]
}
copy("copy_mojo_shell") {
sources = [
"$root_out_dir/exe.stripped/mojo_shell",
]
outputs = [
"$root_out_dir/lib.stripped/libmojo_shell.so",
]
}
copy_ex("copy_mojo_shell_test_assets") {
clear_dir = true
dest = mojo_shell_test_assets_dir
sources = [
"$root_out_dir/test_app.mojo",
"$root_out_dir/test_request_tracker_app.mojo",
]
}
android_apk("mojo_shell_apk") {
apk_name = "MojoShell"
android_manifest = "android/apk/AndroidManifest.xml"
native_libs = [ "libmojo_shell.so" ]
asset_location = mojo_shell_assets_dir
deps = [
":copy_mojo_shell",
":copy_mojo_shell_assets",
":java",
":resources",
"//base:base_java",
"//services/native_viewport:native_viewport_java",
"//third_party/android_tools:google_play_services_default_resources",
]
}
android_library("mojo_shell_tests_java") {
java_files =
[ "android/tests/src/org/chromium/mojo/shell/ShellTestBase.java" ]
deps = [
":java",
"//base:base_java",
]
}
}
mojom("app_child_process_bindings") {
sources = [
"app_child_process.mojom",
]
deps = [
"//mojo/public/interfaces/application",
]
}
mojom("external_application_registrar_bindings") {
sources = [
"external_application_registrar.mojom",
]
deps = [
"//mojo/public/interfaces/application",
]
}
source_set("external_application_registrar_connection") {
sources = [
"external_application_registrar_connection.cc",
"external_application_registrar_connection.h",
]
deps = [
":external_application_registrar_bindings",
"//base",
"//mojo/common",
"//mojo/edk/system",
"//mojo/public/cpp/bindings",
"//mojo/public/interfaces/application",
"//shell/domain_socket",
"//url",
]
if (is_win) {
deps -= [ "//shell/domain_socket" ]
}
}
# GYP version: mojo/mojo.gyp:mojo_shell_tests
test("mojo_shell_tests") {
sources = [
"app_child_process_host_unittest.cc",
"command_line_util_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",
"//testing/gtest",
"//url",
"//mojo/common",
"//mojo/edk/system",
"//mojo/environment:chromium",
"//mojo/public/cpp/bindings",
"//services/test_service:bindings",
"//shell/application_manager",
]
datadeps = [
"//services/test_service:test_app",
"//services/test_service:test_request_tracker_app",
]
if (is_android) {
sources += [ "android/background_application_loader_unittest.cc" ]
deps += [ ":jni_headers" ]
apk_deps = [
":copy_mojo_shell_test_assets",
":mojo_shell_tests_java",
]
apk_asset_location = mojo_shell_test_assets_dir
}
}
# GYP version: mojo/mojo.gyp:mojo_shell_test_support
source_set("test_support") {
sources = [
"shell_test_helper.cc",
"shell_test_helper.h",
]
deps = [
":init",
":lib",
"//base",
"//mojo/edk/system",
"//shell/application_manager",
]
}
test("external_application_unittests") {
sources = [
"external_application_listener_unittest.cc",
"incoming_connection_listener_unittest.cc",
]
deps = [
":lib",
":external_application_registrar_connection",
":external_application_registrar_bindings",
"//base",
"//base/test:test_support",
"//testing/gtest",
"//url",
"//mojo/application",
"//mojo/common",
"//mojo/edk/system",
"//mojo/edk/test:run_all_unittests",
"//mojo/edk/test:test_support",
"//mojo/environment:chromium",
"//shell/application_manager",
"//shell/domain_socket",
"//shell/domain_socket:tests",
]
if (is_win) {
sources -= [
"external_application_listener_unittest.cc",
"incoming_connection_listener_unittest.cc",
]
deps -= [
":lib",
":external_application_registrar_connection",
":external_application_registrar_bindings",
"//shell/domain_socket",
"//shell/domain_socket:tests",
]
}
}
embed_file("embed_pingable") {
source = "$root_build_dir/pingable_app.mojo"
namespace = "mojo"
variable = "kPingable"
testonly = true
deps = [
"//shell/test:pingable_app",
]
}
mojo_native_application("apptests") {
output_name = "shell_apptests"
testonly = true
sources = [
"shell_apptest.cc",
]
deps = [
"//base",
"//mojo/application",
"//mojo/application:test_support",
"//mojo/common:common",
"//mojo/public/cpp/bindings:callback",
"//mojo/public/cpp/environment",
"//mojo/public/cpp/system:system",
"//mojo/services/http_server/public/cpp",
"//mojo/services/http_server/public/interfaces",
"//mojo/services/network/public/interfaces",
"//shell/test:bindings",
":embed_pingable",
]
data_deps = [ "//services/http_server:http_server($default_toolchain)" ]
}