blob: 59f9a3c6f16b3b354b3981beb21abad163ab32e9 [file] [log] [blame]
# Copyright 2020 The Fuchsia 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/cpp/sdk_shared_library.gni")
import("//build/cpp/sdk_source_set.gni")
import("//build/fuzzing/fuzzer.gni")
import("//build/test.gni")
import("//build/test/test_package.gni")
sdk_source_set("cpp") {
# TODO(fxbug.dev/59937): Remove when Mac links OK against this.
if ((current_toolchain == "//build/toolchain:host_x64" && host_os == "mac") ||
(current_toolchain == "//build/toolchain:host_arm64" &&
host_os == "mac")) {
build_as_static = true
}
# Keep internal for now until the API stabilizes.
category = "internal"
sdk_name = "syslog_cpp"
include_base = "//sdk"
sources = [
"log_level.h",
"log_settings.cc",
"log_settings.h",
"logging_backend.h",
"macros.cc",
"macros.h",
]
public_deps = [ "//zircon/public/lib/fit" ]
public_configs = [ "//sdk/config" ]
}
sdk_source_set("backend_host") {
# TODO(fxbug.dev/59937): Remove when Mac links OK against this.
if ((current_toolchain == "//build/toolchain:host_x64" && host_os == "mac") ||
(current_toolchain == "//build/toolchain:host_arm64" &&
host_os == "mac")) {
build_as_static = true
}
# Keep internal for now until the API stabilizes.
category = "internal"
sdk_name = "syslog_cpp_backend_host"
include_base = "//sdk"
sources = [
"logging_backend_host.cc",
"logging_backend_shared.cc",
]
deps = [
":cpp",
"//zircon/public/lib/fit",
]
public_configs = [ "//sdk/config" ]
}
sdk_source_set("backend_legacy_fuchsia") {
# Keep internal for now until the API stabilizes.
category = "internal"
sdk_name = "syslog_cpp_backend_legacy_fuchsia"
include_base = "//sdk"
sources = [
"logging_backend_fuchsia_legacy.cc",
"logging_backend_shared.cc",
]
deps = [
":cpp",
"//src/zircon/lib/zircon",
]
public_deps = [
"//zircon/public/lib/fit",
"//zircon/public/lib/zx",
"//zircon/system/ulib/syslog",
]
public_configs = [ "//sdk/config" ]
}
sdk_source_set("backend_legacy") {
# Keep internal for now until the API stabilizes.
category = "internal"
sdk_name = "syslog_cpp_backend_legacy"
include_base = "//sdk"
if (is_fuchsia) {
public_deps = [ ":backend_legacy_fuchsia" ]
} else {
public_deps = [ ":backend_host" ]
}
}
sdk_shared_library("backend_fuchsia_globals") {
category = "internal"
sources = [
"logging_backend_fuchsia_globals.cc",
"logging_backend_fuchsia_globals.h",
]
deps = [ "//src/zircon/lib/zircon" ]
}
sdk_source_set("backend_fuchsia_lib") {
# Keep internal for now until the API stabilizes.
category = "internal"
sdk_name = "syslog_cpp_backend_fuchsia_lib"
include_base = "//sdk"
sources = [
"logging_backend_fuchsia.cc",
"logging_backend_fuchsia_globals.h",
]
deps = [
":backend_fuchsia_globals",
":cpp",
"//sdk/fidl/fuchsia.diagnostics.stream",
"//sdk/fidl/fuchsia.logger:fuchsia.logger",
"//sdk/lib/fdio",
"//sdk/lib/syslog/streams/cpp:streams-encoder",
"//zircon/public/lib/fit",
]
data_deps = [ "//sdk/lib/diagnostics/syslog:client_includes" ]
public_configs = [ "//sdk/config" ]
}
sdk_source_set("backend") {
# Keep internal for now until the API stabilizes.
category = "internal"
sdk_name = "syslog_cpp_backend"
if (is_fuchsia) {
public_deps = [ ":backend_fuchsia_lib" ]
} else {
public_deps = [ ":backend_host" ]
}
}
# TODO(fxbug.dev/62157) switch to test() template when host tests fixed
executable("logging_cpp_unittests") {
testonly = true
sources = [
"log_settings_unittest.cc",
"logging_unittest.cc",
]
deps = [
":backend_legacy",
":cpp",
"//src/lib/fxl",
"//src/lib/fxl/test:gtest_main",
"//third_party/googletest:gmock",
"//third_party/googletest:gtest",
]
if (is_fuchsia) {
sources += [ "logging_socket_unittest.cc" ]
deps += [ ":backend_legacy" ]
}
}
executable("logging_cpp_unittests_structured") {
testonly = true
sources = [ "log_structure_unittest.cc" ]
deps = [
":backend",
":cpp",
"//third_party/googletest:gtest",
"//third_party/googletest:gtest_main",
]
}
test_package("logging-cpp-tests") {
deps = [
":logging_cpp_unittests",
":logging_cpp_unittests_structured",
]
tests = [
{
name = "logging_cpp_unittests"
},
{
name = "logging_cpp_unittests_structured"
},
]
}
group("tests") {
testonly = true
deps = [
":logging-cpp-tests",
# Refer to the README.md for instructions on host tests
":logging_cpp_unittests($host_toolchain)",
]
}