naiveproxy/components/nacl/loader/BUILD.gn
2018-12-09 21:59:24 -05:00

336 lines
8.8 KiB
Plaintext

# Copyright 2015 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/c++/c++.gni")
import("//build/config/compiler/compiler.gni")
import("//build/config/nacl/config.gni")
import("//components/nacl/features.gni")
import("//services/service_manager/public/service_manifest.gni")
import("//testing/test.gni")
assert(enable_nacl)
# This is separate so it can be used by ../broker:nacl64.
source_set("minimal") {
sources = [
"nacl_ipc_adapter.cc",
"nacl_ipc_adapter.h",
"nacl_listener.cc",
"nacl_listener.h",
"nacl_main.cc",
"nacl_main_platform_delegate.h",
"nacl_main_platform_delegate_linux.cc",
"nacl_main_platform_delegate_mac.mm",
"nacl_main_platform_delegate_win.cc",
"nacl_trusted_listener.cc",
"nacl_trusted_listener.h",
"nacl_validation_db.h",
"nacl_validation_query.cc",
"nacl_validation_query.h",
]
deps = [
":minimal_content_dummy",
"//base",
"//components/nacl/common:minimal",
"//components/nacl/common:mojo_bindings",
"//crypto",
"//ipc",
"//mojo/core/embedder",
"//native_client/src/trusted/service_runtime:sel_main_chrome",
"//ppapi/c",
"//ppapi/proxy:ipc",
"//sandbox",
"//services/service_manager/public/cpp",
]
if (is_linux) {
deps += [ "//services/service_manager/zygote" ]
}
}
# This exists just to make 'gn check' happy with :minimal and
# :nacl_helper_win_64 (below). They can't depend on //content/public/common
# or anything like that, because that would bring in lots more than counts
# as "minimal" (stuff that should not be in the nacl64.exe build).
source_set("minimal_content_dummy") {
check_includes = false
sources = [
"//content/public/common/common_sandbox_support_linux.h",
"//content/public/common/main_function_params.h",
"//content/public/common/sandbox_init.h",
]
# Deps required by the above headers.
deps = [
"//media:media_buildflags",
]
}
source_set("loader") {
public_deps = [
":minimal",
]
deps = [
"//components/nacl/common",
"//content/public/common",
"//ppapi/shared_impl",
"//services/service_manager/public/cpp",
]
data_deps = [
"//ppapi/native_client:irt",
"//ppapi/native_client/src/untrusted/pnacl_support_extension",
]
}
test("nacl_loader_unittests") {
sources = [
"nacl_ipc_adapter_unittest.cc",
"nacl_validation_query_unittest.cc",
"run_all_unittests.cc",
]
deps = [
":loader",
"//base/test:test_support",
"//ipc:test_support",
"//ppapi/c",
"//testing/gtest",
]
if (is_nacl_nonsfi) {
sources += [
# TODO(hamaji): Currently, we build them twice. Stop building
# them for components_unittests. See crbug.com/364751
"nonsfi/nonsfi_sandbox_sigsys_unittest.cc",
"nonsfi/nonsfi_sandbox_unittest.cc",
]
deps += [
":nacl_linux",
"//sandbox/linux:sandbox_linux_test_utils",
]
}
}
if (is_linux) {
executable("nacl_helper") {
sources = [
"nacl_helper_linux.cc",
"nacl_helper_linux.h",
]
deps = [
":loader",
"//base",
"//components/nacl/common:switches",
"//components/nacl/loader/sandbox_linux",
"//content/public/common",
"//crypto",
"//ipc",
"//mojo/core/embedder",
"//sandbox/linux:sandbox_services",
"//services/service_manager/sandbox",
"//services/service_manager/zygote",
"//url/ipc:url_ipc",
]
cflags = [ "-fPIE" ]
ldflags = [ "-pie" ]
if (is_chromeos) {
# NaCl is not working with compiler-rt in ChromeOS.
# Force libgcc as a workaround. See https://crbug.com/761103
ldflags += [ "-rtlib=libgcc" ]
# Nacl crashes when enabling ThinLTO. See https://crbug.com/799642
# We haven't triaged down to the root cause yet. For now, disabling
# dead function removal from LTO optimization is a workaround, so that
# we can enable ThinLTO and CFI.
if (use_thin_lto) {
if (use_lld) {
ldflags += [ "-Wl,-mllvm,-compute-dead=false" ]
} else {
ldflags += [ "-Wl,-plugin-opt,-compute-dead=false" ]
}
}
}
# The only symbols that nacl_helper needs to export are those specified by
# its direct dependencies, so -rdynamic would only serve to unnecessarily
# increase the binary size.
if (!export_libcxxabi_from_executables) {
configs -= [ "//build/config/compiler:export_dynamic" ]
}
data_deps = [
"//native_client/src/trusted/service_runtime/linux:bootstrap",
]
}
# For setting up nacl_helper.
source_set("nacl_helper_integration") {
public = [
"nacl_helper_linux.h",
]
data_deps = [
":nacl_helper",
]
}
if (enable_nacl_nonsfi) {
test("nacl_helper_nonsfi_unittests") {
sources = [
"nonsfi/nacl_helper_nonsfi_unittests.cc",
]
deps = [
"//base",
"//base/test:test_launcher_nacl_nonsfi",
]
data_deps = [
":nacl_helper_nonsfi_unittests_main_copy(//build/toolchain/nacl:newlib_pnacl_nonsfi)",
]
}
group("helper_nonsfi") {
data_deps = [
":nacl_helper_nonsfi_copy(//build/toolchain/nacl:newlib_pnacl_nonsfi)",
]
}
}
}
if (is_win && target_cpu == "x86" && current_cpu == "x64") {
source_set("nacl_helper_win_64") {
sources = [
"nacl_helper_win_64.cc",
"nacl_helper_win_64.h",
]
deps = [
":minimal",
":minimal_content_dummy",
"//base",
"//components/nacl/broker",
"//components/nacl/common:switches",
"//content/public/common:static_switches",
"//mojo/core/embedder",
"//sandbox",
"//services/service_manager/sandbox:sandbox",
]
}
}
if (is_nacl_nonsfi) {
executable("nacl_helper_nonsfi_nexe") {
output_name = "nacl_helper_nonsfi"
set_sources_assignment_filter([])
sources = [
"nacl_helper_linux.cc",
"nacl_helper_linux.h",
"nacl_trusted_listener.cc",
"nacl_trusted_listener.h",
"nonsfi/nonsfi_listener.cc",
"nonsfi/nonsfi_listener.h",
"nonsfi/nonsfi_main.cc",
"nonsfi/nonsfi_main.h",
]
deps = [
":nacl_helper_nonsfi_sandbox",
"//base",
"//components/nacl/common:minimal",
"//components/nacl/common:mojo_bindings",
"//components/nacl/common:switches",
"//components/tracing",
"//content",
"//ipc",
"//mojo/core/embedder",
"//native_client/src/nonsfi/irt:nacl_sys_private",
"//native_client/src/nonsfi/loader:elf_loader",
# Normally libnacl is included implicitly by libc and is part of the
# toolchain. But //build/config/nacl:compiler uses -nodefaultlibs and so
# omits the default libnacl. When the nonsfi toolchain is more complete
# and that kludge is no longer required, this dependency should be
# removed.
"//native_client/src/untrusted/nacl",
"//ppapi/proxy",
"//sandbox/linux:sandbox",
"//services/service_manager/public/cpp",
"//services/service_manager/sandbox",
"//services/service_manager/zygote:zygote_util",
]
}
source_set("nacl_helper_nonsfi_sandbox") {
set_sources_assignment_filter([])
sources = [
"nonsfi/nonsfi_sandbox.cc",
"nonsfi/nonsfi_sandbox.h",
"sandbox_linux/nacl_sandbox_linux.cc",
"sandbox_linux/nacl_sandbox_linux.h",
]
deps = [
"//base",
"//components/nacl/common:minimal",
"//components/nacl/common:switches",
"//content",
"//sandbox/linux:sandbox",
"//sandbox/linux:sandbox_services_headers",
]
}
copy("nacl_helper_nonsfi_copy") {
sources = [
"${root_out_dir}/nacl_helper_nonsfi",
]
outputs = [
"${root_build_dir}/{{source_file_part}}",
]
deps = [
":nacl_helper_nonsfi_nexe",
]
}
test("nacl_helper_nonsfi_unittests_main") {
sources = [
"nonsfi/nonsfi_sandbox_sigsys_unittest.cc",
"nonsfi/nonsfi_sandbox_unittest.cc",
"nonsfi/run_all_unittests.cc",
]
deps = [
":nacl_helper_nonsfi_sandbox",
"//base",
"//base/test:test_support",
"//content",
"//native_client/src/nonsfi/irt:nacl_sys_private",
"//native_client/src/untrusted/nacl:nacl",
"//sandbox/linux:sandbox",
"//sandbox/linux:sandbox_linux_test_utils",
"//sandbox/linux:sandbox_services_headers",
"//testing/gtest",
]
}
copy("nacl_helper_nonsfi_unittests_main_copy") {
testonly = true
sources = [
"${root_out_dir}/nacl_helper_nonsfi_unittests_main",
]
outputs = [
"${root_build_dir}/{{source_file_part}}",
]
deps = [
":nacl_helper_nonsfi_unittests_main",
]
}
}
service_manifest("nacl_loader_manifest") {
name = "nacl_loader"
source = "nacl_loader_manifest.json"
}