diff --git a/.lint/.bazeliskrc b/.lint/.bazeliskrc index ef1c6a25..62c7ea01 100644 --- a/.lint/.bazeliskrc +++ b/.lint/.bazeliskrc @@ -1,3 +1,3 @@ # When bazelisk in use, this dotfile specifies which version of Bazel should be # used to build and test. -USE_BAZEL_VERSION=6.4.0 +USE_BAZEL_VERSION=7.1.2 diff --git a/.lint/.bazelrc b/.lint/.bazelrc new file mode 100644 index 00000000..08dd0fe7 --- /dev/null +++ b/.lint/.bazelrc @@ -0,0 +1,2 @@ +# Import base-level build configuration. +import %workspace%/../default.bazelrc diff --git a/bazel_ros2_rules/.bazeliskrc b/bazel_ros2_rules/.bazeliskrc index ef1c6a25..62c7ea01 100644 --- a/bazel_ros2_rules/.bazeliskrc +++ b/bazel_ros2_rules/.bazeliskrc @@ -1,3 +1,3 @@ # When bazelisk in use, this dotfile specifies which version of Bazel should be # used to build and test. -USE_BAZEL_VERSION=6.4.0 +USE_BAZEL_VERSION=7.1.2 diff --git a/bazel_ros2_rules/setup/install_prereqs.sh b/bazel_ros2_rules/setup/install_prereqs.sh index 477568be..4a5e6916 100755 --- a/bazel_ros2_rules/setup/install_prereqs.sh +++ b/bazel_ros2_rules/setup/install_prereqs.sh @@ -50,10 +50,12 @@ function dpkg_install_from_curl() { apt install g++ unzip zlib1g-dev +# TODO(eric.cousineau) Once there's a bazelisk 1.20 that incorporates pr563, we +# should switch to using that here. dpkg_install_from_curl \ - bazel 6.4.0 \ - https://github.com/bazelbuild/bazel/releases/download/6.4.0/bazel_6.4.0-linux-x86_64.deb \ - 9276a1e11f03e9f7492f009803c95bddc307993c9ab3c463721c9f6cdaa2ccc1 + bazelisk 1.19.0 \ + https://drake-mirror.csail.mit.edu/github/bazelbuild/bazelisk/pr563/bazelisk_1.19.0-9-g58a850f_amd64.deb \ + c2bfd15d6c3422ae540cda9facc0ac395005e2701c09dbb15d40447b53e831d4 # Install Python dependencies apt install python3 python3-toposort python3-dev python-is-python3 diff --git a/default.bazelrc b/default.bazelrc index 0d526964..ac2e563f 100644 --- a/default.bazelrc +++ b/default.bazelrc @@ -1,3 +1,6 @@ +# Don't use bzlmod (yet); eventually we'll want to enable this. +common --enable_bzlmod=false + # Use C++20. build --cxxopt=-std=c++20 build --host_cxxopt=-std=c++20 diff --git a/drake_ros/.bazeliskrc b/drake_ros/.bazeliskrc index ef1c6a25..62c7ea01 100644 --- a/drake_ros/.bazeliskrc +++ b/drake_ros/.bazeliskrc @@ -1,3 +1,3 @@ # When bazelisk in use, this dotfile specifies which version of Bazel should be # used to build and test. -USE_BAZEL_VERSION=6.4.0 +USE_BAZEL_VERSION=7.1.2 diff --git a/drake_ros_examples/.bazeliskrc b/drake_ros_examples/.bazeliskrc index ef1c6a25..62c7ea01 100644 --- a/drake_ros_examples/.bazeliskrc +++ b/drake_ros_examples/.bazeliskrc @@ -1,3 +1,3 @@ # When bazelisk in use, this dotfile specifies which version of Bazel should be # used to build and test. -USE_BAZEL_VERSION=6.4.0 +USE_BAZEL_VERSION=7.1.2 diff --git a/ros2_example_bazel_installed/.bazeliskrc b/ros2_example_bazel_installed/.bazeliskrc index ef1c6a25..62c7ea01 100644 --- a/ros2_example_bazel_installed/.bazeliskrc +++ b/ros2_example_bazel_installed/.bazeliskrc @@ -1,3 +1,3 @@ # When bazelisk in use, this dotfile specifies which version of Bazel should be # used to build and test. -USE_BAZEL_VERSION=6.4.0 +USE_BAZEL_VERSION=7.1.2 diff --git a/ros2_example_bazel_installed/setup/install_prereqs.sh b/ros2_example_bazel_installed/setup/install_prereqs.sh index 2ab1b9d3..85a9f87a 100755 --- a/ros2_example_bazel_installed/setup/install_prereqs.sh +++ b/ros2_example_bazel_installed/setup/install_prereqs.sh @@ -58,11 +58,12 @@ function dpkg_install_from_curl() { apt install g++ unzip zlib1g-dev -# TODO(sloretz) Make sure the version of bazel is exactly the same as the one used by Drake +# TODO(eric.cousineau) Once there's a bazelisk 1.20 that incorporates pr563, we +# should switch to using that here. dpkg_install_from_curl \ - bazel 6.4.0 \ - https://github.com/bazelbuild/bazel/releases/download/6.4.0/bazel_6.4.0-linux-x86_64.deb \ - 9276a1e11f03e9f7492f009803c95bddc307993c9ab3c463721c9f6cdaa2ccc1 + bazelisk 1.19.0 \ + https://drake-mirror.csail.mit.edu/github/bazelbuild/bazelisk/pr563/bazelisk_1.19.0-9-g58a850f_amd64.deb \ + c2bfd15d6c3422ae540cda9facc0ac395005e2701c09dbb15d40447b53e831d4 # If the user did not explicitly specify their installation prefix, install # ROS 2 Humble. diff --git a/ros2_example_bazel_installed/tools/environ.bzl b/ros2_example_bazel_installed/tools/environ.bzl index 3cbf0394..88af02d3 100644 --- a/ros2_example_bazel_installed/tools/environ.bzl +++ b/ros2_example_bazel_installed/tools/environ.bzl @@ -1,31 +1,46 @@ -# -*- python -*- +# -*- mode: python -*- +# vi: set ft=python : -def _environment_repository_impl(repo_ctx): - environ = { - envvar: repo_ctx.os.environ.get(envvar, "") - for envvar in repo_ctx.attr._envvars - } - repo_ctx.file( +# Write out a repository that contains: +# - An empty BUILD file, to define a package. +# - An environ.bzl file with variable assignments for each ENV_NAMES item. +def _impl(repository_ctx): + envvars = repository_ctx.attr.envvars + bzl_content = [] + for key in envvars: + value = repository_ctx.os.environ.get(key, "") + bzl_content.append("{}='{}'\n".format(key, value)) + repository_ctx.file( "BUILD.bazel", - content = "# Empty build file to mark repository root.\n", + content = "\n", executable = False, ) - repo_ctx.file( + repository_ctx.file( "environ.bzl", - content = "\n".join([ - "{}=\"{}\"".format(name, value) - for name, value in environ.items() - ]), + content = "".join(bzl_content), executable = False, ) -def environment_repository(name, envvars): +_string_list = attr.string_list() + +def environment_repository(name = None, envvars = []): + """Provide specific environment variables for use in a WORKSPACE file. + The `envvars` are the environment variables to provide. + + Example: + environ_repository(name = "foo", envvars = ["BAR", "BAZ"]) + load("@foo//:environ.bzl", "BAR", "BAZ") + print(BAR) + """ rule = repository_rule( + implementation = _impl, attrs = { - "_envvars": attr.string_list(default = envvars), + "envvars": _string_list, }, - implementation = _environment_repository_impl, - environ = envvars, local = True, + environ = envvars, + ) + rule( + name = name, + envvars = envvars, ) - rule(name = name)