Skip to content

Commit

Permalink
Attempt at building gz-utils with bzlmod
Browse files Browse the repository at this point in the history
Signed-off-by: Michael Carroll <[email protected]>
  • Loading branch information
mjcarroll committed Apr 23, 2024
1 parent 3838ce6 commit 6be3849
Show file tree
Hide file tree
Showing 7 changed files with 91 additions and 36 deletions.
2 changes: 2 additions & 0 deletions .bazeliskrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# See https://github.com/bazelbuild/bazelisk
USE_BAZEL_VERSION=latest
3 changes: 3 additions & 0 deletions .bazelrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
common --enable_bzlmod

common --lockfile_mode=off
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,9 @@ build_*
# OS generated files
.DS_Store
*.swp

# Bazel generated files
bazel-bin/
bazel-out/
bazel-testlogs/
bazel-*
77 changes: 52 additions & 25 deletions BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,28 +1,20 @@
load(
"@gz//bazel/skylark:build_defs.bzl",
"GZ_FEATURES",
"GZ_ROOT",
"GZ_VISIBILITY",
"gz_configure_header",
"gz_export_header",
"gz_include_header",
)
load("@buildifier_prebuilt//:rules.bzl", "buildifier", "buildifier_test")
load("@rules_gz//gz:headers.bzl", "gz_configure_header", "gz_export_header", "gz_include_header")
load("@rules_license//rules:license.bzl", "license")

package(
default_applicable_licenses = [GZ_ROOT + "utils:license"],
default_visibility = GZ_VISIBILITY,
features = GZ_FEATURES,
default_applicable_licenses = [":license"],
)

license(
name = "license",
package_name = "gz-utils",
)

licenses(["notice"])

exports_files(["LICENSE"])
exports_files([
"LICENSE",
"MODULE.bazel",
])

gz_configure_header(
name = "config",
Expand All @@ -41,6 +33,7 @@ gz_export_header(
public_headers_no_gen = glob([
"include/gz/utils/*.hh",
"include/gz/utils/detail/*.hh",
"include/gz/utils/detail/*.h",
])

gz_include_header(
Expand All @@ -59,11 +52,12 @@ public_headers = public_headers_no_gen + [
]

cc_library(
name = "utils",
name = "gz-utils",
srcs = ["src/Environment.cc"],
hdrs = public_headers,
copts = ["-fexceptions"],
includes = ["include"],
visibility = ["//visibility:public"],
)

# Tests
Expand All @@ -76,7 +70,7 @@ cc_library(
"test/integration/implptr/implptr_test_classes.hh",
],
includes = ["test/integration/implptr"],
deps = [":utils"],
deps = [":gz-utils"],
)

cc_test(
Expand All @@ -85,18 +79,16 @@ cc_test(
srcs = ["test/integration/implptr/ImplPtr_TEST.cc"],
deps = [
":implptr_test_classes",
"@gtest",
"@gtest//:gtest_main",
"@googletest//:gtest_main",
],
)

cc_test(
name = "Environment_TEST",
srcs = ["src/Environment_TEST.cc"],
deps = [
":utils",
"@gtest",
"@gtest//:gtest_main",
":gz-utils",
"@googletest//:gtest_main",
],
)

Expand All @@ -105,8 +97,43 @@ cc_test(
srcs = ["src/NeverDestroyed_TEST.cc"],
copts = ["-fexceptions"],
deps = [
":utils",
"@gtest",
"@gtest//:gtest_main",
":gz-utils",
"@googletest//:gtest_main",
],
)

cc_binary(
name = "subprocess_main",
srcs = ["test/integration/subprocess/subprocess_main.cc"],
deps = [
":gz-utils",
"//cli",
],
)

cc_test(
name = "subprocess_TEST",
srcs = ["test/integration/subprocess_TEST.cc"],
local_defines = ['SUBPROCESS_EXECUTABLE_PATH=\\"subprocess_main\\"'],
deps = [
":gz-utils",
":subprocess_main",
"@googletest//:gtest_main",
],
)

buildifier(
name = "buildifier.fix",
exclude_patterns = ["./.git/*"],
lint_mode = "fix",
mode = "fix",
)

buildifier_test(
name = "buildifier.test",
exclude_patterns = ["./.git/*"],
lint_mode = "warn",
mode = "diff",
no_sandbox = True,
workspace = "//:MODULE.bazel",
)
14 changes: 14 additions & 0 deletions MODULE.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
## MODULE.bazel
module(
name = "gz-utils",
repo_name = "org_gazebosim_gz-utils",
)

bazel_dep(name = "buildifier_prebuilt", version = "6.1.2")
bazel_dep(name = "googletest", version = "1.14.0")
bazel_dep(name = "rules_license", version = "0.0.8")
bazel_dep(name = "rules_gz")
local_path_override(
module_name = "rules_gz",
path = "/usr/local/google/home/mjcarroll/workspaces/gz_ionic_bazel/rules_gz",
)
Empty file added WORKSPACE
Empty file.
25 changes: 14 additions & 11 deletions cli/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,12 +1,7 @@
load(
"@gz//bazel/skylark:build_defs.bzl",
"GZ_ROOT",
"GZ_VISIBILITY",
)
load("@rules_license//rules:license.bzl", "license")

package(
default_applicable_licenses = [GZ_ROOT + "utils/cli:license"],
default_applicable_licenses = ["//cli:license"],
)

license(
Expand All @@ -17,7 +12,7 @@ license(
public_headers = [
"include/gz/utils/cli/GzFormatter.hpp",
] + glob([
"include/external-cli/gz/utils/cli/*.hpp",
"include/vendored-cli/gz/utils/cli/*.hpp",
])

cc_library(
Expand All @@ -26,11 +21,19 @@ cc_library(
copts = ["-fexceptions"],
includes = [
"include",
"include/external-cli",
"include/vendored-cli",
],
visibility = ["//visibility:public"],
deps = [
"//:gz-utils",
],
visibility = GZ_VISIBILITY,
)

cc_test(
name = "cli_TEST",
srcs = ["src/cli_TEST.cc"],
deps = [
GZ_ROOT + "utils:utils",
"@cli11"
":cli",
"@googletest//:gtest_main",
],
)

0 comments on commit 6be3849

Please sign in to comment.