From e5ebd745ba96337960f4faadf9894c4cd4ff5e20 Mon Sep 17 00:00:00 2001 From: Michael Carroll Date: Tue, 5 Nov 2024 09:29:24 -0600 Subject: [PATCH] Build Utils examples in Bazel (#157) Signed-off-by: Michael Carroll --- BUILD.bazel | 1 + cli/BUILD.bazel | 9 ++------- examples/BUILD.bazel | 21 +++++++++++++++++++++ log/BUILD.bazel | 10 ++++------ 4 files changed, 28 insertions(+), 13 deletions(-) create mode 100644 examples/BUILD.bazel diff --git a/BUILD.bazel b/BUILD.bazel index 395826f..857793b 100644 --- a/BUILD.bazel +++ b/BUILD.bazel @@ -36,6 +36,7 @@ cc_library( srcs = ["src/Environment.cc"], hdrs = ["include/gz/utils/Environment.hh"], includes = ["include"], + visibility = ["//visibility:public"], deps = [ ":Config", ":Export", diff --git a/cli/BUILD.bazel b/cli/BUILD.bazel index f1d18fa..2850623 100644 --- a/cli/BUILD.bazel +++ b/cli/BUILD.bazel @@ -1,12 +1,6 @@ -load("@rules_license//rules:license.bzl", "license") - package( default_applicable_licenses = ["//:license"], -) - -license( - name = "license", - package_name = "gz-utils-cli", + default_visibility = ["__subpackages__"], ) cc_library( @@ -23,6 +17,7 @@ cc_library( "include/gz/utils/cli/GzFormatter.hpp", ], includes = ["include"], + visibility = ["//visibility:public"], deps = [ "//:Export", ], diff --git a/examples/BUILD.bazel b/examples/BUILD.bazel new file mode 100644 index 0000000..7f4da34 --- /dev/null +++ b/examples/BUILD.bazel @@ -0,0 +1,21 @@ +package( + default_applicable_licenses = ["//:license"], + default_visibility = ["//visibility:private"], +) + +cc_binary( + name = "log", + srcs = ["log/main.cc"], + deps = [ + "//log:Logger", + ], +) + +cc_binary( + name = "using_cli", + srcs = ["using_cli/main.cc"], + deps = [ + "//:Config", + "//cli", + ], +) diff --git a/log/BUILD.bazel b/log/BUILD.bazel index 6e314c7..1f2948c 100644 --- a/log/BUILD.bazel +++ b/log/BUILD.bazel @@ -1,13 +1,8 @@ load("@rules_gazebo//gazebo:headers.bzl", "gz_export_header") -load("@rules_license//rules:license.bzl", "license") package( default_applicable_licenses = ["//:license"], -) - -license( - name = "license", - package_name = "gz-utils-log", + default_visibility = ["__subpackages__"], ) gz_export_header( @@ -26,6 +21,7 @@ cc_library( "include/gz/utils/log/SplitSink.hh", ], includes = ["include"], + visibility = ["//visibility:public"], deps = [ ":Export", "//:Config", @@ -43,6 +39,7 @@ cc_library( "include/gz/utils/log/Logger.hh", ], includes = ["include"], + visibility = ["//visibility:public"], deps = [":SplitSink"], ) @@ -58,6 +55,7 @@ cc_library( cc_test( name = "SplitSink_TEST", srcs = ["src/SplitSink_TEST.cc"], + visibility = ["//visibility:public"], deps = [ ":log", "@googletest//:gtest_main",