| # 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/components.gni") |
| import("//build/cpp/sdk_shared_library.gni") |
| import("//build/cpp/sdk_source_set.gni") |
| import("//build/cpp/sdk_static_library.gni") |
| import("//build/test.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", |
| ] |
| if (is_fuchsia) { |
| public_deps = [ |
| "//sdk/lib/fit-promise", |
| "//zircon/system/ulib/zx", |
| ] |
| } else { |
| public_deps = [ "//sdk/lib/fit-promise" ] |
| } |
| public_configs = [ "//sdk/config" ] |
| } |
| |
| # Needed to export macros without relying on a specific backend |
| # otherwise libraries can't include macros.h |
| sdk_source_set("cpp-macros") { |
| # 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.h", |
| "logging_backend.h", |
| "macros.h", |
| ] |
| |
| public_deps = [ "//sdk/lib/fit-promise" ] |
| |
| 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 = [ |
| # TODO(https://fxbug.dev/124673): Move these to a host directory. |
| "host/encoder.cc", |
| "host/encoder.h", |
| "host/logging_backend.cc", |
| ] |
| |
| deps = [ ":cpp" ] |
| |
| public_configs = [ "//sdk/config" ] |
| } |
| |
| sdk_shared_library("backend_fuchsia_globals") { |
| category = "internal" |
| |
| libcxx_linkage = "static" |
| |
| 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 = [ |
| "fx_log_api.cc", |
| "logging_backend_fuchsia.cc", |
| "logging_backend_fuchsia_globals.h", |
| "macros.h", |
| ] |
| |
| deps = [ |
| ":backend_fuchsia_globals", |
| ":cpp", |
| "//sdk/fidl/fuchsia.diagnostics.stream:fuchsia.diagnostics.stream_hlcpp", |
| "//sdk/fidl/fuchsia.logger:fuchsia.logger_hlcpp", |
| "//sdk/lib/fdio", |
| "//sdk/lib/stdcompat", |
| "//sdk/lib/syslog/structured_backend", |
| "//zircon/system/ulib/async:async-cpp", |
| "//zircon/system/ulib/async-loop:async-loop-cpp", |
| "//zircon/system/ulib/sync", |
| ] |
| |
| data_deps = [ "//sdk/lib/syslog:client_includes" ] |
| |
| public_configs = [ "//sdk/config" ] |
| |
| # TODO(fxbug.dev/92670): Remove this when no longer needed. |
| public_configs += [ "//build/config/rust:output_dir_sensitive" ] |
| } |
| |
| sdk_source_set("backend_fuchsia_compat") { |
| # Keep internal for now until the API stabilizes. |
| category = "internal" |
| |
| sdk_name = "syslog_cpp_backend_fuchsia_compat_lib" |
| |
| include_base = "//sdk" |
| |
| sources = [ |
| "fx_log_api_null.cc", |
| "logging_backend_fuchsia.cc", |
| "logging_backend_fuchsia_globals.h", |
| ] |
| |
| deps = [ |
| ":backend_fuchsia_globals", |
| ":cpp-macros", |
| "//sdk/fidl/fuchsia.diagnostics.stream:fuchsia.diagnostics.stream_hlcpp", |
| "//sdk/fidl/fuchsia.logger:fuchsia.logger_hlcpp", |
| "//sdk/lib/fdio", |
| "//sdk/lib/fit-promise", |
| "//sdk/lib/stdcompat", |
| "//sdk/lib/syslog/structured_backend", |
| "//zircon/system/ulib/async:async-cpp", |
| "//zircon/system/ulib/async-loop:async-loop-cpp", |
| "//zircon/system/ulib/sync", |
| ] |
| |
| data_deps = [ "//sdk/lib/syslog:client_includes" ] |
| |
| configs += [ "//build/config/fuchsia:static_cpp_standard_library" ] |
| |
| public_configs = [ "//sdk/config" ] |
| |
| visibility = [ |
| "//sdk/lib/syslog/cpp:*", |
| "//src/devices/bin/driver_host:driver_host", |
| ] |
| } |
| |
| 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" ] |
| } |
| } |
| |
| test("logging_cpp_unittests") { |
| sources = [ |
| "host/encoder.h", |
| "log_settings_unittest.cc", |
| "logging_unittest.cc", |
| ] |
| deps = [ |
| ":backend", |
| ":cpp", |
| "//src/lib/fxl", |
| "//src/lib/fxl/test:gtest_main", |
| "//src/lib/uuid", |
| "//third_party/googletest:gmock", |
| "//third_party/googletest:gtest", |
| ] |
| if (is_fuchsia) { |
| deps += [ |
| "//sdk/fidl/fuchsia.diagnostics:fuchsia.diagnostics_hlcpp", |
| "//sdk/fidl/fuchsia.logger:fuchsia.logger_hlcpp", |
| "//src/diagnostics/lib/cpp-log-tester:cpp_log_tester", |
| "//src/lib/diagnostics/accessor2logger", |
| "//src/lib/fsl", |
| "//third_party/rapidjson", |
| "//zircon/system/ulib/async", |
| "//zircon/system/ulib/async:async-cpp", |
| "//zircon/system/ulib/async-loop:async-loop-cpp", |
| ] |
| } |
| } |
| |
| test("logging_cpp_unittests_structured") { |
| sources = [ "log_structure_unittest.cc" ] |
| |
| deps = [ |
| ":backend", |
| ":cpp", |
| "//src/lib/files", |
| "//src/lib/fxl/test:gtest_main", |
| "//third_party/googletest:gtest", |
| ] |
| } |
| |
| fuchsia_unittest_component("logging-cpp-unittests") { |
| manifest = "meta/logging_cpp_unittests.cml" |
| deps = [ ":logging_cpp_unittests" ] |
| } |
| |
| fuchsia_unittest_component("logging-cpp-unittests-structured") { |
| deps = [ ":logging_cpp_unittests_structured" ] |
| } |
| |
| fuchsia_test_package("logging-cpp-tests") { |
| test_components = [ |
| ":logging-cpp-unittests", |
| ":logging-cpp-unittests-structured", |
| ] |
| test_specs = { |
| log_settings = { |
| max_severity = "FATAL" |
| } |
| } |
| } |
| |
| group("tests") { |
| testonly = true |
| public_deps = [ |
| ":logging-cpp-tests", |
| ":logging_cpp_unittests($host_toolchain)", |
| ] |
| } |