From 445775df778f0bbe73800f0aeec1371098925173 Mon Sep 17 00:00:00 2001 From: Michael Carroll Date: Thu, 2 Feb 2023 15:24:43 -0600 Subject: [PATCH] Garden bazel support Signed-off-by: Michael Carroll --- BUILD.bazel | 58 ++++++++++++++++++-------------------------- eigen3/BUILD.bazel | 27 +++++++++++---------- examples/BUILD.bazel | 23 ++++++++++++++++++ test/BUILD.bazel | 13 ++++++++++ 4 files changed, 74 insertions(+), 47 deletions(-) create mode 100644 examples/BUILD.bazel create mode 100644 test/BUILD.bazel diff --git a/BUILD.bazel b/BUILD.bazel index 016f40329..b89cd10a1 100644 --- a/BUILD.bazel +++ b/BUILD.bazel @@ -1,11 +1,15 @@ load( - "//gz_bazel:build_defs.bzl", + "@gz//bazel/skylark:build_defs.bzl", "GZ_FEATURES", + "GZ_ROOT", "GZ_VISIBILITY", - "cmake_configure_file", - "generate_include_header", - "gz_config_header", + "gz_configure_header", "gz_export_header", + "gz_include_header", +) +load( + "@gz//bazel/lint:lint.bzl", + "add_lint_tests", ) package( @@ -13,25 +17,15 @@ package( features = GZ_FEATURES, ) -licenses(["notice"]) +licenses(["notice"]) # Apache-2.0 exports_files(["LICENSE"]) -PROJECT_NAME = "gz-math" - -PROJECT_MAJOR = 7 - -PROJECT_MINOR = 0 - -PROJECT_PATCH = 0 - -# Generates config.hh based on the version numbers in CMake code. -gz_config_header( +gz_configure_header( name = "config", src = "include/gz/math/config.hh.in", cmakelists = ["CMakeLists.txt"], - project_name = PROJECT_NAME, - project_version = (PROJECT_MAJOR, PROJECT_MINOR, PROJECT_PATCH), + package = "math", ) gz_export_header( @@ -54,7 +48,7 @@ sources = glob( exclude = ["src/*_TEST.cc"], ) -generate_include_header( +gz_include_header( name = "mathhh_genrule", out = "include/gz/math.hh", hdrs = public_headers_no_gen + [ @@ -70,20 +64,19 @@ public_headers = public_headers_no_gen + [ ] cc_library( - name = "gz_math", + name = "math", srcs = sources + private_headers, hdrs = public_headers, includes = ["include"], + deps = [ + GZ_ROOT + "utils", + ], ) -# use shared library only when absolutely needd -cc_binary( - name = "libgz-math7.so", - includes = ["include"], - linkopts = ["-Wl,-soname,libgz-math7.so"], - linkshared = True, - deps = [ - ":gz_math", +test_sources = glob( + [ + "src/*_TEST.cc", + "src/graph/*_TEST.cc", ], ) @@ -91,13 +84,10 @@ cc_binary( name = src.replace("/", "_").replace(".cc", "").replace("src_", ""), srcs = [src], deps = [ - ":gz_math", + ":math", "@gtest", "@gtest//:gtest_main", ], -) for src in glob( - [ - "src/*_TEST.cc", - "src/graph/*_TEST.cc", - ], -)] +) for src in test_sources] + +add_lint_tests() diff --git a/eigen3/BUILD.bazel b/eigen3/BUILD.bazel index 508cb3138..2b3ba9537 100644 --- a/eigen3/BUILD.bazel +++ b/eigen3/BUILD.bazel @@ -1,15 +1,13 @@ load( - "//gz_bazel:build_defs.bzl", + "@gz//bazel/skylark:build_defs.bzl", + "GZ_FEATURES", "GZ_ROOT", "GZ_VISIBILITY", + "gz_configure_header", + "gz_export_header", + "gz_include_header", ) -package( - default_visibility = GZ_VISIBILITY, -) - -licenses(["notice"]) - public_headers = glob([ "include/gz/math/eigen3/*.hh", ]) @@ -19,9 +17,16 @@ cc_library( srcs = public_headers, hdrs = public_headers, includes = ["include"], + visibility = GZ_VISIBILITY, deps = [ + GZ_ROOT + "math", "@eigen3", - GZ_ROOT + "gz_math", + ], +) + +test_sources = glob( + [ + "src/*_TEST.cc", ], ) @@ -33,8 +38,4 @@ cc_library( "@gtest", "@gtest//:gtest_main", ], -) for src in glob( - [ - "src/*_TEST.cc", - ], -)] +) for src in test_sources] diff --git a/examples/BUILD.bazel b/examples/BUILD.bazel new file mode 100644 index 000000000..c3902e6a3 --- /dev/null +++ b/examples/BUILD.bazel @@ -0,0 +1,23 @@ +load( + "@gz//bazel/skylark:build_defs.bzl", + "GZ_ROOT", + "GZ_VISIBILITY", +) +load( + "@gz//bazel/lint:lint.bzl", + "add_lint_tests", +) + +sources = glob( + ["*.cc"], +) + +[cc_binary( + name = src.replace(".cc", ""), + srcs = [src], + deps = [ + GZ_ROOT + "math", + ], +) for src in sources] + +add_lint_tests() diff --git a/test/BUILD.bazel b/test/BUILD.bazel new file mode 100644 index 000000000..9000f4abc --- /dev/null +++ b/test/BUILD.bazel @@ -0,0 +1,13 @@ +load( + "@gz//bazel/skylark:build_defs.bzl", + "GZ_FEATURES", + "GZ_VISIBILITY", +) +load( + "@gz//bazel/lint:lint.bzl", + "add_lint_tests", +) + +# Currently test directory only applies to CMake builds + +add_lint_tests()