123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433 |
- # Copyright 2018 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/chromeos/ui_mode.gni")
- import("//build/config/compiler/compiler.gni")
- import("//build/config/nacl/config.gni")
- import("//chrome/process_version_rc_template.gni")
- import("//testing/libfuzzer/fuzzer_test.gni")
- import("//testing/test.gni")
- if (is_mac) {
- import("//third_party/protobuf/proto_library.gni")
- }
- component("embedder_internal") {
- output_name = "mojo_core_embedder_internal"
- public_deps = [ ":impl_for_embedder" ]
- visibility = [
- ":test_sources",
- "//mojo:*",
- "//mojo/core/embedder",
- "//mojo/core/test:test_support",
- ]
- }
- # Bits of the EDK library which do not depend on public API linkage. It is
- # not allowed for this target or any of its transitive dependencies to depend
- # on anything under //mojo/public beyond strict C type definitions.
- #
- # This is templated because it's consumed by both the ":embedder_internal"
- # component library as well as the ":mojo_core" shared library. In the former
- # case we want to export symbols, but in the latter case we don't. The template
- # stamps out two nearly identical targets which differ only in what symbols they
- # export.
- template("core_impl_source_set") {
- source_set(target_name) {
- if (invoker.for_shared_library) {
- visibility = [ ":shared_library" ]
- } else {
- visibility = [
- ":core_impl_for_fuzzers",
- ":embedder_internal",
- ]
- }
- public = [
- "channel.h",
- "configuration.h",
- "connection_params.h",
- "core.h",
- "core_ipcz.h",
- "data_pipe_consumer_dispatcher.h",
- "data_pipe_control_message.h",
- "data_pipe_producer_dispatcher.h",
- "dispatcher.h",
- "embedder/configuration.h",
- "embedder/process_error_callback.h",
- "entrypoints.h",
- "handle_signals_state.h",
- "handle_table.h",
- "invitation_dispatcher.h",
- "ipcz_api.h",
- "ipcz_driver/driver.h",
- "ipcz_driver/transmissible_platform_handle.h",
- "ipcz_driver/transport.h",
- "ipcz_driver/wrapped_platform_handle.h",
- "message_pipe_dispatcher.h",
- "node_channel.h",
- "node_controller.h",
- "options_validation.h",
- "platform_handle_dispatcher.h",
- "platform_handle_utils.h",
- "platform_shared_memory_mapping.h",
- "request_context.h",
- "shared_buffer_dispatcher.h",
- "user_message_impl.h",
- ]
- sources = [
- "atomic_flag.cc",
- "atomic_flag.h",
- "broker.h",
- "channel.cc",
- "configuration.cc",
- "connection_params.cc",
- "core.cc",
- "core_ipcz.cc",
- "data_pipe_consumer_dispatcher.cc",
- "data_pipe_control_message.cc",
- "data_pipe_producer_dispatcher.cc",
- "dispatcher.cc",
- "entrypoints.cc",
- "handle_table.cc",
- "invitation_dispatcher.cc",
- "ipcz_api.cc",
- "ipcz_driver/driver.cc",
- "ipcz_driver/mojo_trap.cc",
- "ipcz_driver/mojo_trap.h",
- "ipcz_driver/object.cc",
- "ipcz_driver/object.h",
- "ipcz_driver/transmissible_platform_handle.cc",
- "ipcz_driver/transport.cc",
- "ipcz_driver/wrapped_platform_handle.cc",
- "message_pipe_dispatcher.cc",
- "node_channel.cc",
- "node_controller.cc",
- "platform_handle_dispatcher.cc",
- "platform_handle_in_transit.cc",
- "platform_handle_in_transit.h",
- "platform_handle_utils.cc",
- "platform_shared_memory_mapping.cc",
- "request_context.cc",
- "shared_buffer_dispatcher.cc",
- "user_message_impl.cc",
- "watch.cc",
- "watch.h",
- "watcher_dispatcher.cc",
- "watcher_dispatcher.h",
- "watcher_set.cc",
- "watcher_set.h",
- ]
- public_deps = [
- "//base",
- "//mojo/core/embedder:features",
- "//mojo/core/ports",
- "//mojo/public/c/system:headers",
- "//mojo/public/cpp/bindings:mojo_buildflags",
- "//mojo/public/cpp/platform",
- "//third_party/ipcz/src:ipcz_chromium",
- ]
- if (is_fuchsia) {
- sources += [ "channel_fuchsia.cc" ]
- public_deps += [ "//third_party/fuchsia-sdk/sdk/pkg/fdio" ]
- }
- if (is_posix && !is_mac) {
- if (!is_nacl) {
- sources += [
- "broker_posix.cc",
- "channel_posix.cc",
- "channel_posix.h",
- ]
- }
- if ((is_linux || is_chromeos || is_android) && !is_nacl) {
- sources += [
- "channel_linux.cc",
- "channel_linux.h",
- ]
- public += [ "channel_linux.h" ]
- }
- }
- if (is_mac) {
- sources += [ "channel_mac.cc" ]
- }
- if (!is_nacl) {
- sources += [
- "broker_host.cc",
- "broker_host.h",
- ]
- }
- defines = []
- if (invoker.for_shared_library) {
- defines += [ "MOJO_CORE_SHARED_LIBRARY" ]
- } else {
- defines += [ "MOJO_SYSTEM_IMPL_IMPLEMENTATION" ]
- }
- deps = []
- if (is_android) {
- deps += [ "//third_party/ashmem" ]
- }
- if (!is_nacl) {
- deps += [ "//crypto" ]
- }
- if (is_win) {
- sources += [
- "broker_win.cc",
- "channel_win.cc",
- ]
- }
- # Use target_os == "chromeos" instead of is_chromeos because we need to
- # build NaCl targets (i.e. IRT) for ChromeOS the same as the rest of ChromeOS.
- if (is_android || target_os == "chromeos" ||
- (target_os == "linux" && chromeos_is_browser_only)) {
- defines += [ "MOJO_CORE_LEGACY_PROTOCOL" ]
- }
- if (!is_debug && !optimize_for_size) {
- configs -= [ "//build/config/compiler:default_optimization" ]
- configs += [ "//build/config/compiler:optimize_max" ]
- }
- }
- }
- core_impl_source_set("impl_for_embedder") {
- for_shared_library = false
- }
- if (is_win) {
- process_version_rc_template("mojo_core_version") {
- sources = [ "mojo_core.ver" ]
- output = "$target_gen_dir/mojo_core_version.rc"
- }
- }
- if (is_chromeos || is_linux || is_android || is_win || is_fuchsia) {
- core_impl_source_set("impl_for_shared_library") {
- for_shared_library = true
- }
- shared_library("shared_library") {
- output_name = "mojo_core"
- sources = [ "mojo_core.cc" ]
- defines = [ "MOJO_CORE_SHARED_LIBRARY" ]
- deps = [
- ":impl_for_shared_library",
- "//base:base_static",
- "//mojo/public/c/system:headers",
- ]
- if (is_win) {
- sources += [ "mojo_core.def" ]
- deps += [ ":mojo_core_version" ]
- } else {
- configs += [ ":export_only_thunks_api" ]
- }
- }
- if (is_chromeos_ash) {
- if (target_cpu == "arm" || target_cpu == "arm64") {
- android32_toolchain = "android_clang_arm"
- android64_toolchain = "android_clang_arm64"
- } else {
- android32_toolchain = "android_clang_x86"
- android64_toolchain = "android_clang_x64"
- }
- group("shared_libraries_for_arc") {
- deps = [
- ":shared_library_arc32",
- ":shared_library_arc64",
- ]
- }
- copy("shared_library_arc32") {
- sources = [ "${root_build_dir}/${android32_toolchain}/libmojo_core.so" ]
- outputs = [ "${root_build_dir}/libmojo_core_arc32.so" ]
- deps = [
- ":shared_library(//build/toolchain/android:${android32_toolchain})",
- ]
- }
- copy("shared_library_arc64") {
- sources = [ "${root_build_dir}/${android64_toolchain}/libmojo_core.so" ]
- outputs = [ "${root_build_dir}/libmojo_core_arc64.so" ]
- deps = [
- ":shared_library(//build/toolchain/android:${android64_toolchain})",
- ]
- }
- }
- config("export_only_thunks_api") {
- inputs = [ "export_only_thunks_api.lst" ]
- ldflags = [ "-Wl,--version-script=" +
- rebase_path("//mojo/core/export_only_thunks_api.lst",
- root_build_dir) ]
- }
- if (is_chromeos || is_linux || is_win || is_fuchsia) {
- test("mojo_core_unittests") {
- sources = [
- "mojo_core_unittest.cc",
- "mojo_core_unittest.h",
- "run_all_core_unittests.cc",
- ]
- deps = [
- "//base",
- "//base/test:test_support",
- "//mojo/public/c/system",
- "//mojo/public/cpp/platform",
- "//mojo/public/cpp/system",
- "//testing/gtest",
- ]
- data_deps = [ ":shared_library" ]
- }
- }
- }
- source_set("test_sources") {
- testonly = true
- sources = [
- "channel_unittest.cc",
- "core_ipcz_test.cc",
- "core_test_base.cc",
- "core_test_base.h",
- "core_unittest.cc",
- "embedder_unittest.cc",
- "handle_table_unittest.cc",
- "message_pipe_unittest.cc",
- "message_unittest.cc",
- "node_channel_unittest.cc",
- "options_validation_unittest.cc",
- "platform_handle_dispatcher_unittest.cc",
- "quota_unittest.cc",
- "shared_buffer_dispatcher_unittest.cc",
- "shared_buffer_unittest.cc",
- "signals_unittest.cc",
- "trap_unittest.cc",
- ]
- if (!is_ios) {
- sources += [
- "data_pipe_unittest.cc",
- "invitation_unittest.cc",
- "ipcz_driver/transport_test.cc",
- "multiprocess_message_pipe_unittest.cc",
- "node_controller_unittest.cc",
- "platform_wrapper_unittest.cc",
- ]
- }
- deps = [
- "//base",
- "//base/test:test_support",
- "//mojo/core:embedder_internal",
- "//mojo/core/embedder",
- "//mojo/core/ports:tests",
- "//mojo/core/test:run_all_unittests",
- "//mojo/core/test:test_support",
- "//mojo/public/cpp/system",
- "//testing/gmock",
- "//testing/gtest",
- "//third_party/ipcz/src:ipcz_chromium",
- ]
- }
- group("core_impl_for_fuzzers") {
- public_deps = [ ":impl_for_embedder" ]
- }
- fuzzer_test("mojo_core_channel_fuzzer") {
- sources = [ "channel_fuzzer.cc" ]
- deps = [
- ":core_impl_for_fuzzers",
- "//base",
- "//mojo/public/cpp/platform",
- ]
- }
- if (is_mac) {
- protoc_convert("mojo_core_channel_mac_fuzzer_convert_corpus") {
- sources = [
- "test/data/channel_mac/bad_handshake1.textproto",
- "test/data/channel_mac/bad_handshake2.textproto",
- "test/data/channel_mac/bad_handshake3.textproto",
- "test/data/channel_mac/bad_message1.textproto",
- "test/data/channel_mac/complex_messages.textproto",
- "test/data/channel_mac/double_handshake.textproto",
- "test/data/channel_mac/handshake.textproto",
- "test/data/channel_mac/invalid_handles.textproto",
- "test/data/channel_mac/non_complex_with_descriptor_count.textproto",
- "test/data/channel_mac/ool_type_mismatch.textproto",
- "test/data/channel_mac/simple_message1.textproto",
- "test/data/channel_mac/simple_message2.textproto",
- ]
- inputs = [
- "test/data/channel_mac/channel_mac.proto",
- "//testing/libfuzzer/fuzzers/mach/mach_message.proto",
- ]
- output_pattern = "$target_gen_dir/mojo_core_channel_mac_corpus/{{source_name_part}}.binarypb"
- args = [
- "--encode=mojo_fuzzer.ChannelMac",
- "-I",
- rebase_path("//"),
- "mojo/core/test/data/channel_mac/channel_mac.proto",
- ]
- }
- fuzzer_test("mojo_core_channel_mac_fuzzer") {
- sources = [ "channel_mac_fuzzer.cc" ]
- seed_corpus = "$target_gen_dir/mojo_core_channel_mac_corpus"
- seed_corpus_deps = [ ":mojo_core_channel_mac_fuzzer_convert_corpus" ]
- deps = [
- ":core_impl_for_fuzzers",
- "test:channel_mac_proto",
- "//base",
- "//base/test:test_support",
- "//testing/libfuzzer/fuzzers/mach:converter",
- "//third_party/libprotobuf-mutator",
- ]
- }
- }
- fuzzer_test("mojo_core_node_channel_fuzzer") {
- sources = [ "node_channel_fuzzer.cc" ]
- deps = [
- ":core_impl_for_fuzzers",
- "//base",
- "//mojo/core/test:test_support",
- "//mojo/public/cpp/platform",
- ]
- }
- fuzzer_test("mojo_core_port_event_fuzzer") {
- sources = [ "port_event_fuzzer.cc" ]
- deps = [
- ":core_impl_for_fuzzers",
- "//base",
- ]
- }
- fuzzer_test("mojo_core_user_message_fuzzer") {
- sources = [ "user_message_fuzzer.cc" ]
- deps = [
- ":core_impl_for_fuzzers",
- "//base",
- ]
- }
|