Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Garden bazel support #523

Merged
merged 1 commit into from
Feb 15, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
58 changes: 24 additions & 34 deletions BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,37 +1,31 @@
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(
default_visibility = GZ_VISIBILITY,
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(
Expand All @@ -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 + [
Expand All @@ -70,34 +64,30 @@ 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",
],
)

[cc_test(
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()
27 changes: 14 additions & 13 deletions eigen3/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -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",
])
Expand All @@ -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",
],
)

Expand All @@ -33,8 +38,4 @@ cc_library(
"@gtest",
"@gtest//:gtest_main",
],
) for src in glob(
[
"src/*_TEST.cc",
],
)]
) for src in test_sources]
23 changes: 23 additions & 0 deletions examples/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -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()
13 changes: 13 additions & 0 deletions test/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -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()