blob: e65c7843b374ae0e98b31de565a53fe2ab1e3f8f [file] [log] [blame]
# Copyright 2019 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/components.gni")
import("//build/test.gni")
import("//build/zircon/zx_library.gni")
# ________ _________ ________ ________
# |\ ____\|\___ ___\\ __ \|\ __ \
# \ \ \___|\|___ \ \_\ \ \|\ \ \ \|\ \
# \ \_____ \ \ \ \ \ \ \\\ \ \ ____\
# \|____|\ \ \ \ \ \ \ \\\ \ \ \___|
# ____\_\ \ \ \__\ \ \_______\ \__\
# |\_________\ \|__| \|_______|\|__|
# \|_________|
#
# This is an allowlist of targets that use the deprecated `syslog` C++ library.
# C++ libraries should now be using `//sdk/lib/syslog/cpp` instead.
#
# Developers are encouraged to migrate to use the `diagnostics_log` and `tracing` libraries
# instead which bring structured logging support.
#
# The policy at this time is:
# 1. Pre-existing use of syslog in fuchsia.git are allowlisted.
# 2. Use of syslog in new libraries and binaries is strongly discouraged and only allowed
# under special circumstances under which the new library isn't covering the needs.
#
# To add items to the allowlist, please send a change to one of the OWNERS of
# this file to add an element to the visibility list below.
# Please allowlist entire directories rather than individual targets as it
# requires less allowlist churn over time.
#
# To regenerate:
# fx gn refs $(fx get-build-dir) /zircon/system/ulib/syslog:syslog //zircon/system/ulib/syslog | sed 's|\(.*:\).*|"\1*",|' | sort | uniq
syslog_visibility_allowlist = [
"//sdk/lib/syslog/duplicate_header_test:*",
"//sdk/lib/ui/scenic/cpp:*",
"//sdk/lib/ui/scenic/cpp/testing:*",
"//src/connectivity/network/drivers/network-device/device:*",
"//src/connectivity/network/drivers/network-device/mac:*",
"//src/connectivity/network/tun/network-tun:*",
"//src/devices/bin/driver_manager:driver_shared_libraries",
"//src/devices/testing/mock-ddk:*",
"//src/devices/tests/fx-logger:*",
"//src/lib/metrics_buffer:*",
"//src/virtualization/bin/vmm/device:*",
"//src/virtualization/bin/vmm/device/virtio_magma:*",
]
# At this time we are not enforcing restrictions on the below.
syslog_visibility_allowlist += [
"//third_party/*",
"//vendor/*",
]
# Syslog code can depend on syslog.
syslog_visibility_allowlist += [ "//zircon/system/ulib/syslog:*" ]
syslog_visibility_allowlist += [ "//build/sdk:sdk_versioned_shared_libraries" ]
syslog_headers_visibility_allowlist = [
"//src/devices/lib/iommu:*",
"//src/lib/ddk:*",
]
syslog_headers_visibility_allowlist += [
"//third_party/*",
"//vendor/*",
]
# Syslog code can depend on syslog-headers.
syslog_headers_visibility_allowlist += [ "//zircon/system/ulib/syslog:*" ]
syslog_headers = [
"lib/syslog/global.h",
"lib/syslog/logger.h",
"lib/syslog/wire_format.h",
]
zx_library("syslog") {
sdk = "shared"
sdk_publishable = true
sdk_headers = syslog_headers
sources = [
"fx_logger.cc",
"global.cc",
"logger.cc",
]
deps = [
":helpers",
"//sdk/fidl/fuchsia.logger:fuchsia.logger_cpp",
"//sdk/lib/component/incoming/cpp",
"//sdk/lib/syslog:client_includes",
"//sdk/lib/syslog/cpp",
"//sdk/lib/syslog/cpp:backend_fuchsia_globals",
"//sdk/lib/syslog/structured_backend",
"//zircon/system/ulib/fbl",
"//zircon/system/ulib/zx",
]
runtime_deps = [
"//sdk/lib/fdio:fdio_sdk",
"//sdk/lib/syslog/cpp:backend_fuchsia_globals_sdk",
"//zircon/system/ulib/async-default:async-default_sdk",
"//zircon/system/ulib/trace-engine:trace-engine_sdk",
]
visibility = syslog_visibility_allowlist
}
zx_library("syslog-headers") {
sdk = "static"
sdk_publishable = true
sdk_headers = syslog_headers
visibility = syslog_headers_visibility_allowlist
}
source_set("helpers") {
sources = [
"helpers.cc",
"helpers.h",
]
deps = [ ":syslog-headers" ]
}
_test_sources = [
"syslog_socket_tests.cc",
"syslog_tests.cc",
]
_test_deps = [
":helpers",
"//sdk/fidl/fuchsia.logger:fuchsia.logger_cpp",
"//sdk/lib/syslog/cpp:cpp",
"//src/diagnostics/lib/cpp-log-tester:cpp-log-tester",
"//zircon/system/ulib/fbl",
"//zircon/system/ulib/zx",
"//zircon/system/ulib/zxtest",
]
test("syslog-test") {
sources = _test_sources
deps = _test_deps + [ ":syslog" ]
}
fuchsia_unittest_component("c-syslog-test") {
deps = [ ":syslog-test" ]
}
fuchsia_test_package("c-syslog-tests") {
test_components = [ ":c-syslog-test" ]
}
fuchsia_unittest_component("c-syslog-defaults-test") {
deps = [ ":syslog-defaults-test" ]
}
fuchsia_test_package("c-syslog-defaults-tests") {
test_components = [ ":c-syslog-defaults-test" ]
}
test("syslog-defaults-test") {
sources = [ "syslog_defaults_test.cc" ]
deps = [
":syslog",
"//zircon/system/ulib/zxtest",
]
}
group("tests") {
testonly = true
deps = [
":c-syslog-defaults-tests",
":c-syslog-tests",
]
}