Skip to content

Commit

Permalink
Support Bazel 6 and 7 (#2)
Browse files Browse the repository at this point in the history
Signed-off-by: Michael Carroll <mjcarroll@intrinsic.ai>
mjcarroll authored Oct 1, 2024
1 parent 037c33f commit 9c23c94
Showing 12 changed files with 96 additions and 13 deletions.
3 changes: 0 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -17,10 +17,7 @@ jobs:
".",
"test/smoke",
]
# we only support Bazel 7, and only with bzlmod enabled
exclude: |
[
{"bzlmodEnabled": false},
{"bazelversion": "5.4.0"},
{"bazelversion": "6.4.0"},
]
22 changes: 20 additions & 2 deletions .github/workflows/release_prep.sh
Original file line number Diff line number Diff line change
@@ -11,11 +11,29 @@ TAG=${GITHUB_REF_NAME}
PREFIX="rules_gazebo-${TAG}"
ARCHIVE="rules_gazebo-$TAG.tar.gz"
git archive --format=tar --prefix=${PREFIX}/ ${TAG} | gzip > $ARCHIVE
SHA=$(shasum -a 256 $ARCHIVE | awk '{print $1}')

cat > release_notes.txt << EOF
## Using Bzlmod
cat << EOF
Add to your \`MODULE.bazel\` file:
\`\`\`starlark
bazel_dep(name = "rules_gazebo", version = "${TAG}")
\`\`\`
EOF
## Using WORKSPACE
Paste this snippet into your \`WORKSPACE\` file:
\`\`\`starlark
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
http_archive(
name = "rules_gazebo",
sha256 = "${SHA}",
strip_prefix = "${PREFIX}",
url = "https://github.com/gazebosim/rules_gazebo/releases/download/${TAG}/rules_gazebo-${TAG}.tar.gz",
)
\`\`\`
EOF
6 changes: 5 additions & 1 deletion BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
load("@rules_license//rules:license.bzl", "license")
load("@buildifier_prebuilt//:rules.bzl", "buildifier", "buildifier_test")
load("@rules_license//rules:license.bzl", "license")

package(
default_applicable_licenses = [":license"],
@@ -8,6 +8,10 @@ package(
license(
name = "license",
package_name = "rules_gazebo",
license_kinds = [
"@rules_license//licenses/spdx:Apache-2.0",
],
license_text = "LICENSE",
)

exports_files([
7 changes: 5 additions & 2 deletions MODULE.bazel
Original file line number Diff line number Diff line change
@@ -7,6 +7,9 @@ module(
)

bazel_dep(name = "bazel_skylib", version = "1.7.1")
bazel_dep(name = "buildifier_prebuilt", version = "6.1.2")
bazel_dep(name = "rules_cc", version = "0.0.10")
bazel_dep(name = "rules_cc", version = "0.0.9")
bazel_dep(name = "rules_license", version = "1.0.0")
bazel_dep(name = "rules_python", version = "0.31.0")

# ===== DEV ONLY DEPS AND SETUP BELOW HERE =====
bazel_dep(name = "buildifier_prebuilt", version = "6.1.2", dev_dependency = True)
Empty file removed WORKSPACE
Empty file.
35 changes: 35 additions & 0 deletions WORKSPACE.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
workspace(name = "rules_gazebo")

load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")

http_archive(
name = "buildifier_prebuilt",
sha256 = "7f85b688a4b558e2d9099340cfb510ba7179f829454fba842370bccffb67d6cc",
strip_prefix = "buildifier-prebuilt-7.3.1",
urls = [
"http://github.com/keith/buildifier-prebuilt/archive/7.3.1.tar.gz",
],
)

load("@buildifier_prebuilt//:deps.bzl", "buildifier_prebuilt_deps")

buildifier_prebuilt_deps()

load("@bazel_skylib//:workspace.bzl", "bazel_skylib_workspace")

bazel_skylib_workspace()

load("@buildifier_prebuilt//:defs.bzl", "buildifier_prebuilt_register_toolchains")

buildifier_prebuilt_register_toolchains()

http_archive(
name = "rules_python",
sha256 = "ca77768989a7f311186a29747e3e95c936a41dffac779aff6b443db22290d913",
strip_prefix = "rules_python-0.36.0",
url = "https://github.com/bazelbuild/rules_python/releases/download/0.36.0/rules_python-0.36.0.tar.gz",
)

load("@rules_python//python:repositories.bzl", "py_repositories")

py_repositories()
1 change: 1 addition & 0 deletions WORKSPACE.bzlmod
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# This file replaces WORKSPACE.bazel when --enable_bzlmod is set
2 changes: 1 addition & 1 deletion gazebo/private/gz_configure_file.bzl
Original file line number Diff line number Diff line change
@@ -37,7 +37,7 @@ _gz_configure_file_gen = rule(
"gz_configure_file_py": attr.label(
cfg = "exec",
executable = True,
default = Label("//gz/private:gz_configure_file"),
default = Label("//gazebo/private:gz_configure_file"),
),
"out": attr.output(mandatory = True),
"package_xml": attr.label(allow_single_file = True, mandatory = True),
2 changes: 0 additions & 2 deletions test/smoke/.bazelrc

This file was deleted.

1 change: 0 additions & 1 deletion test/smoke/.bazelversion

This file was deleted.

2 changes: 1 addition & 1 deletion test/smoke/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
load("@rules_gazebo//gazebo:headers.bzl", "gz_configure_header", "gz_export_header")
load("@bazel_skylib//rules:diff_test.bzl", "diff_test")
load("@rules_gazebo//gazebo:headers.bzl", "gz_configure_header", "gz_export_header")

gz_export_header(
name = "export",
28 changes: 28 additions & 0 deletions test/smoke/WORKSPACE.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
workspace(name = "smoke")

load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")

http_archive(
name = "bazel_skylib",
sha256 = "bc283cdfcd526a52c3201279cda4bc298652efa898b10b4db0837dc51652756f",
urls = [
"https://mirror.bazel.build/github.com/bazelbuild/bazel-skylib/releases/download/1.7.1/bazel-skylib-1.7.1.tar.gz",
"https://github.com/bazelbuild/bazel-skylib/releases/download/1.7.1/bazel-skylib-1.7.1.tar.gz",
],
)

http_archive(
name = "rules_python",
sha256 = "ca77768989a7f311186a29747e3e95c936a41dffac779aff6b443db22290d913",
strip_prefix = "rules_python-0.36.0",
url = "https://github.com/bazelbuild/rules_python/releases/download/0.36.0/rules_python-0.36.0.tar.gz",
)

load("@rules_python//python:repositories.bzl", "py_repositories")

py_repositories()

local_repository(
name = "rules_gazebo",
path = "../..",
)

0 comments on commit 9c23c94

Please sign in to comment.