From 12dfe57b568c5a9fe473a7681850060689b1865c Mon Sep 17 00:00:00 2001 From: Laurenz Date: Thu, 1 Feb 2024 21:49:13 +0100 Subject: [PATCH 01/30] squash --- .bazelrc | 11 +-- .github/workflows/main.yml | 24 ++++- .pre-commit-config.yaml | 1 - MODULE.bazel | 111 +++++++++++++++++++++++ WORKSPACE.bzlmod | 0 examples/MODULE.bazel | 66 ++++++++++++++ examples/WORKSPACE | 2 +- extensions.bzl | 9 ++ repositories/asio.BUILD.bazel | 13 +-- repositories/foxglove_bridge.BUILD.bazel | 1 + repositories/pip_annotations.bzl | 1 + repositories/repositories.bzl | 73 +++++++-------- ros2/interfaces.bzl | 3 +- 13 files changed, 255 insertions(+), 60 deletions(-) create mode 100644 MODULE.bazel create mode 100644 WORKSPACE.bzlmod create mode 100644 examples/MODULE.bazel create mode 100644 extensions.bzl diff --git a/.bazelrc b/.bazelrc index 9e1354c3..b749130a 100644 --- a/.bazelrc +++ b/.bazelrc @@ -4,14 +4,6 @@ # Mandatory at the moment for Bazel 7.0.0. build --noincompatible_sandbox_hermetic_tmp -# This is mandatory if your build env doesn't have a proper Python 3 exe -# -- like the CI build image for this repo. -# The build image is using a fake python exe, see -# https://github.com/mvukov/bazel_builder/blob/main/Dockerfile. -# If blzmod is enabled, but not used as in this repo at the moment), -# then bazel for some reason tries to auto-detect a Python exe. -build --noenable_bzlmod - # Fix the wrong default to generate __init__.py to delimit a Python package. # This is a mandatory flag. build --incompatible_default_to_explicit_init_py @@ -37,6 +29,9 @@ build --noexperimental_check_output_files # Don't bother building targets which aren't dependencies of the tests. test --build_tests_only +# Show all the problems in CI +test --keep_going + # To use a clang compiler, invoke Bazel with `--config=clang`. build:clang --repo_env=CC=clang build:clang --repo_env=CXX=clang++ diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index a652a182..9edf0561 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -53,6 +53,7 @@ jobs: # Run bazel test with gcc and clang in each workspace strategy: + fail-fast: false matrix: folder: - "." @@ -60,11 +61,18 @@ jobs: toolchain: - "gcc" - "clang" + external_dependency_system: + - bzlmod + - workspace include: - toolchain: "gcc" config_option: "" - toolchain: "clang" config_option: "--config=clang" + - external_dependency_system: bzlmod + bzlmod_flags: --enable_bzlmod + - external_dependency_system: workspace + bzlmod_flags: --noenable_bzlmod steps: # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it @@ -89,13 +97,21 @@ jobs: path: | ~/.cache/bazel ~/.cache/bazel-repo - key: v3-bazel-repo-cache-${{ matrix.toolchain }}-${{ hashFiles('.bazelversion', 'examples/WORKSPACE', 'repositories/**', 'requirements_lock.txt', 'WORKSPACE') }} - restore-keys: v3-bazel-repo-cache-${{ matrix.toolchain }}- - - name: bazel test ${{ matrix.config_option }} //... + key: >- + v3-bazel-repo-cache + -${{ matrix.external_dependency_system }}-${{ matrix.toolchain }} + -${{ hashFiles('.bazelversion', '**/WORKSPACE', '**/MODULE.bazel', 'repositories/**/*.bzl', 'requirements_lock.txt') }} + restore-keys: >- + v3-bazel-repo-cache + -${{ matrix.external_dependency_system }}-${{ matrix.toolchain }} + - name: bazel test //... env: # Bazelisk will download bazel to here, ensure it is cached between runs. XDG_CACHE_HOME: ~/.cache/bazel-repo BUILDBUDDY_ORG_API_KEY: ${{ secrets.BUILDBUDDY_ORG_API_KEY }} USER: ${{ needs.configure.outputs.user_name }} working-directory: ${{ matrix.folder }} - run: ${GITHUB_WORKSPACE}/.github/workflows/test.sh ${{ matrix.config_option }} + run: > + ${GITHUB_WORKSPACE}/.github/workflows/test.sh + ${{ matrix.config_option }} + ${{ matrix.bzlmod_flags }} diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 891253fd..de3bbcba 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,5 +1,4 @@ default_language_version: - python: python3.10 node: 18.16.0 default_stages: [commit] diff --git a/MODULE.bazel b/MODULE.bazel new file mode 100644 index 00000000..bfb704c2 --- /dev/null +++ b/MODULE.bazel @@ -0,0 +1,111 @@ +module(name = "com_github_mvukov_rules_ros2") + +bazel_dep(name = "asio", version = "1.28.2") +bazel_dep(name = "bazel_skylib", version = "1.5.0") +bazel_dep(name = "boringssl", version = "0.0.0-20240126-22d349c") +bazel_dep(name = "eigen", version = "3.4.0") +bazel_dep(name = "fmt", version = "10.2.1") +bazel_dep(name = "googletest", version = "1.14.0.bcr.1") +bazel_dep(name = "libyaml", version = "0.2.5") +bazel_dep(name = "lz4", version = "1.9.4") +bazel_dep(name = "nlohmann_json", version = "3.11.3") +bazel_dep(name = "platforms", version = "0.0.8") +bazel_dep(name = "readerwriterqueue", version = "1.0.6") +bazel_dep(name = "rules_cc", version = "0.0.9") +bazel_dep(name = "rules_foreign_cc", version = "0.10.1") +bazel_dep(name = "rules_python", version = "0.29.0") +bazel_dep(name = "spdlog", version = "1.12.0") +bazel_dep(name = "sqlite3", version = "3.42.0.bcr.1") +bazel_dep(name = "tinyxml2", version = "10.0.0") +bazel_dep(name = "websocketpp", version = "0.8.2") +bazel_dep(name = "yaml-cpp", version = "0.8.0") +bazel_dep(name = "zlib", version = "1.3") +bazel_dep(name = "zstd", version = "1.5.5.bcr.1") + +python = use_extension("@rules_python//python:extensions.bzl", "python") +python.toolchain( + is_default = True, + python_version = "3.11", +) +use_repo(python, "python_versions") + +pip = use_extension("@rules_python//python/extensions:pip.bzl", "pip") +pip.whl_mods( + # Keep this in sync with repositories/pip_annotations.bzl + additive_build_content = """\ +cc_library( + name = "headers", + hdrs = glob(["site-packages/numpy/core/include/numpy/**/*.h"]), + includes = ["site-packages/numpy/core/include"], + deps = ["@rules_python//python/cc:current_py_cc_headers"], +) +""", + hub_name = "whl_mods_hub", + whl_name = "numpy", +) +use_repo(pip, "whl_mods_hub") +pip.parse( + hub_name = "rules_ros2_pip_deps", + python_version = "3.11", + requirements_lock = "//:requirements_lock.txt", + whl_modifications = {"@whl_mods_hub//:numpy.json": "numpy"}, +) +use_repo(pip, "rules_ros2_pip_deps") +use_repo(pip, "rules_ros2_pip_deps_311_numpy") +pip.parse( + hub_name = "rules_ros2_resolver_deps", + python_version = "3.11", + requirements_lock = "//repositories/private:resolver_requirements_lock.txt", +) +use_repo(pip, "rules_ros2_resolver_deps") + +non_module_deps = use_extension("@com_github_mvukov_rules_ros2//:extensions.bzl", "non_module_deps") +use_repo( + non_module_deps, + "cyclonedds", + "foxglove_bridge", + "iceoryx", + "osrf_pycommon", + "pybind11", + "ros2_ament_cmake_ros", + "ros2_ament_index", + "ros2_class_loader", + "ros2_common_interfaces", + "ros2_diagnostics", + "ros2_geometry2", + "ros2_image_common", + "ros2_kdl_parser", + "ros2_keyboard_handler", + "ros2_launch", + "ros2_launch_ros", + "ros2_libstatistics_collector", + "ros2_message_filters", + "ros2_pluginlib", + "ros2_rcl", + "ros2_rcl_interfaces", + "ros2_rcl_logging", + "ros2_rclcpp", + "ros2_rclpy", + "ros2_rcpputils", + "ros2_rcutils", + "ros2_resource_retriever", + "ros2_rmw", + "ros2_rmw_cyclonedds", + "ros2_rmw_dds_common", + "ros2_rmw_implementation", + "ros2_robot_state_publisher", + "ros2_ros_testing", + "ros2_rosbag2", + "ros2_rosidl", + "ros2_rosidl_python", + "ros2_rosidl_runtime_py", + "ros2_rosidl_typesupport", + "ros2_rpyutils", + "ros2_tracing", + "ros2_unique_identifier_msgs", + "ros2_urdfdom", + "ros2_urdfdom_headers", + "ros2_xacro", + "ros2cli", + "ros2", +) diff --git a/WORKSPACE.bzlmod b/WORKSPACE.bzlmod new file mode 100644 index 00000000..e69de29b diff --git a/examples/MODULE.bazel b/examples/MODULE.bazel new file mode 100644 index 00000000..09412cd6 --- /dev/null +++ b/examples/MODULE.bazel @@ -0,0 +1,66 @@ +module(name = "rules_ros2_examples") + +bazel_dep(name = "com_github_mvukov_rules_ros2") +local_path_override( + module_name = "com_github_mvukov_rules_ros2", + path = "..", +) + +non_module_deps = use_extension("@com_github_mvukov_rules_ros2//:extensions.bzl", "non_module_deps") +use_repo( + non_module_deps, + "cyclonedds", + "foxglove_bridge", + "iceoryx", + "osrf_pycommon", + "ros2_ament_cmake_ros", + "ros2_ament_index", + "ros2_class_loader", + "ros2_common_interfaces", + "ros2_diagnostics", + "ros2_geometry2", + "ros2_image_common", + "ros2_kdl_parser", + "ros2_keyboard_handler", + "ros2_launch", + "ros2_launch_ros", + "ros2_libstatistics_collector", + "ros2_message_filters", + "ros2_pluginlib", + "ros2_rcl", + "ros2_rcl_interfaces", + "ros2_rcl_logging", + "ros2_rclcpp", + "ros2_rclpy", + "ros2_rcpputils", + "ros2_rcutils", + "ros2_resource_retriever", + "ros2_rmw", + "ros2_rmw_cyclonedds", + "ros2_rmw_dds_common", + "ros2_rmw_implementation", + "ros2_robot_state_publisher", + "ros2_ros_testing", + "ros2_rosbag2", + "ros2_rosidl", + "ros2_rosidl_python", + "ros2_rosidl_runtime_py", + "ros2_rosidl_typesupport", + "ros2_rpyutils", + "ros2_tracing", + "ros2_unique_identifier_msgs", + "ros2_urdfdom", + "ros2_urdfdom_headers", + "ros2_xacro", + "ros2cli", +) + +bazel_dep(name = "rules_cc", version = "0.0.9") +bazel_dep(name = "rules_python", version = "0.29.0") + +python = use_extension("@rules_python//python:extensions.bzl", "python") +python.toolchain( + is_default = True, + python_version = "3.11", +) +use_repo(python, "python_versions") diff --git a/examples/WORKSPACE b/examples/WORKSPACE index b290b71e..fb13e6dc 100644 --- a/examples/WORKSPACE +++ b/examples/WORKSPACE @@ -16,7 +16,7 @@ local_repository( # url = "https://github.com/mvukov/rules_ros2/archive/.tar.gz", # ) -load("@com_github_mvukov_rules_ros2//repositories:repositories.bzl", "ros2_repositories", "ros2_workspace_repositories") +load("//repositories:repositories.bzl", "ros2_repositories", "ros2_workspace_repositories") ros2_workspace_repositories() diff --git a/extensions.bzl b/extensions.bzl new file mode 100644 index 00000000..48910434 --- /dev/null +++ b/extensions.bzl @@ -0,0 +1,9 @@ +load("@com_github_mvukov_rules_ros2//repositories:repositories.bzl", "ros2_repositories", "rules_ros2_workspace_and_bazelmod_common_deps") + +def _non_module_deps_impl(mctx): + rules_ros2_workspace_and_bazelmod_common_deps() + ros2_repositories() + +non_module_deps = module_extension( + implementation = _non_module_deps_impl, +) diff --git a/repositories/asio.BUILD.bazel b/repositories/asio.BUILD.bazel index 3d72fb60..9e273d70 100644 --- a/repositories/asio.BUILD.bazel +++ b/repositories/asio.BUILD.bazel @@ -5,15 +5,10 @@ load("@rules_cc//cc:defs.bzl", "cc_library") cc_library( name = "asio", - srcs = glob(["src/*.cpp"]), - hdrs = glob([ - "include/**/*.hpp", - "include/**/*.ipp", + srcs = glob([ + "**/*.hpp", + "**/*.ipp", ]), - defines = [ - "ASIO_SEPARATE_COMPILATION", - ], - includes = ["include"], + includes = ["."], visibility = ["//visibility:public"], - deps = ["@boringssl//:ssl"], ) diff --git a/repositories/foxglove_bridge.BUILD.bazel b/repositories/foxglove_bridge.BUILD.bazel index cf20f3e2..11482669 100644 --- a/repositories/foxglove_bridge.BUILD.bazel +++ b/repositories/foxglove_bridge.BUILD.bazel @@ -26,6 +26,7 @@ cc_library( includes = ["foxglove_bridge_base/include"], deps = [ "@nlohmann_json//:json", + "@boringssl//:ssl", "@websocketpp", ], ) diff --git a/repositories/pip_annotations.bzl b/repositories/pip_annotations.bzl index 980a3b1b..2691d95a 100644 --- a/repositories/pip_annotations.bzl +++ b/repositories/pip_annotations.bzl @@ -1,5 +1,6 @@ load("@rules_python//python:pip.bzl", "package_annotation") +# Keep this in sync with MODULE.bazel PIP_ANNOTATIONS = { "numpy": package_annotation( additive_build_content = """\ diff --git a/repositories/repositories.bzl b/repositories/repositories.bzl index 3b4b4700..3a14a695 100644 --- a/repositories/repositories.bzl +++ b/repositories/repositories.bzl @@ -8,11 +8,33 @@ load( "ros2_repositories_impl", ) +def rules_ros2_workspace_and_bazelmod_common_deps(): + """Import http_archive dependencies needed for both the WORKSPACE and MODULE.bazel version of rules_ros2.""" + maybe( + http_archive, + name = "pybind11", + build_file = "@com_github_mvukov_rules_ros2//repositories:pybind11.BUILD.bazel", + sha256 = "d475978da0cdc2d43b73f30910786759d593a9d8ee05b1b6846d1eb16c6d2e0c", + strip_prefix = "pybind11-2.11.1", + urls = ["https://github.com/pybind/pybind11/archive/refs/tags/v2.11.1.tar.gz"], + ) + + maybe( + http_archive, + name = "curl", + build_file = "@com_github_mvukov_rules_ros2//repositories:curl.BUILD.bazel", + sha256 = "230d61a4b1eb3346930f2d601cc8fe5237957163e16befbe15e0ef40c56767a2", + strip_prefix = "curl-curl-8_2_1", + urls = ["https://github.com/curl/curl/archive/refs/tags/curl-8_2_1.tar.gz"], + ) + def ros2_workspace_repositories(): """Imports dependent third-party repositories for the non-blzmod (hence, workspace-) version of the repository. In particular, imports third-party package repositories excluding ROS 2 packages. ROS 2-specific repositories are imported with `ros2_repositories()` macro. """ + rules_ros2_workspace_and_bazelmod_common_deps() + maybe( http_archive, name = "rules_python", @@ -32,9 +54,9 @@ def ros2_workspace_repositories(): http_archive, name = "fmt", build_file = "@com_github_mvukov_rules_ros2//repositories:fmt.BUILD.bazel", - sha256 = "5dea48d1fcddc3ec571ce2058e13910a0d4a6bab4cc09a809d8b1dd1c88ae6f2", - strip_prefix = "fmt-9.1.0", - url = "https://github.com/fmtlib/fmt/archive/9.1.0.tar.gz", + sha256 = "1250e4cc58bf06ee631567523f48848dc4596133e163f02615c97f78bab6c811", + strip_prefix = "fmt-10.2.1", + url = "https://github.com/fmtlib/fmt/archive/10.2.1.tar.gz", ) maybe( @@ -55,15 +77,6 @@ def ros2_workspace_repositories(): urls = ["https://github.com/yaml/libyaml/releases/download/0.2.5/yaml-0.2.5.tar.gz"], ) - maybe( - http_archive, - name = "pybind11", - build_file = "@com_github_mvukov_rules_ros2//repositories:pybind11.BUILD.bazel", - sha256 = "bf8f242abd1abcd375d516a7067490fb71abd79519a282d22b6e4d19282185a7", - strip_prefix = "pybind11-2.12.0", - urls = ["https://github.com/pybind/pybind11/archive/refs/tags/v2.12.0.tar.gz"], - ) - maybe( http_archive, name = "rules_foreign_cc", @@ -129,9 +142,9 @@ def ros2_workspace_repositories(): http_archive, name = "asio", build_file = "@com_github_mvukov_rules_ros2//repositories:asio.BUILD.bazel", - sha256 = "b31c63867daaba0e460ee2c85dc508a52c81db0a7318e0d2147f444b26f80ed7", - strip_prefix = "asio-asio-1-27-0/asio", - urls = ["https://github.com/chriskohlhoff/asio/archive/refs/tags/asio-1-27-0.tar.gz"], + sha256 = "5705a0e403017eba276625107160498518838064a6dd7fd8b00b2e30c0ffbdee", + strip_prefix = "asio-asio-1-28-2/asio/include", + urls = ["https://github.com/chriskohlhoff/asio/archive/refs/tags/asio-1-28-2.tar.gz"], ) # We're pointing at hedronvision's mirror of google/boringssl:main-with-bazel to get @@ -149,12 +162,9 @@ def ros2_workspace_repositories(): http_archive, name = "zlib", build_file = "@com_github_mvukov_rules_ros2//repositories:zlib.BUILD.bazel", - sha256 = "d14c38e313afc35a9a8760dadf26042f51ea0f5d154b0630a31da0540107fb98", - strip_prefix = "zlib-1.2.13", - urls = [ - "https://github.com/madler/zlib/releases/download/v1.2.13/zlib-1.2.13.tar.xz", - "https://zlib.net/zlib-1.2.13.tar.xz", - ], + sha256 = "8a9ba2898e1d0d774eca6ba5b4627a11e5588ba85c8851336eb38de4683050a7", + strip_prefix = "zlib-1.3", + urls = ["https://github.com/madler/zlib/releases/download/v1.3/zlib-1.3.tar.xz"], ) maybe( @@ -167,15 +177,6 @@ def ros2_workspace_repositories(): ], ) - maybe( - http_archive, - name = "curl", - build_file = "@com_github_mvukov_rules_ros2//repositories:curl.BUILD.bazel", - sha256 = "230d61a4b1eb3346930f2d601cc8fe5237957163e16befbe15e0ef40c56767a2", - strip_prefix = "curl-curl-8_2_1", - urls = ["https://github.com/curl/curl/archive/refs/tags/curl-8_2_1.tar.gz"], - ) - maybe( http_archive, name = "zstd", @@ -189,18 +190,18 @@ def ros2_workspace_repositories(): http_archive, name = "lz4", build_file = "@com_github_mvukov_rules_ros2//repositories:lz4.BUILD.bazel", - sha256 = "4ec935d99aa4950eadfefbd49c9fad863185ac24c32001162c44a683ef61b580", - strip_prefix = "lz4-1.9.3", - urls = ["https://github.com/lz4/lz4/archive/refs/tags/v1.9.3.zip"], + sha256 = "0b0e3aa07c8c063ddf40b082bdf7e37a1562bda40a0ff5272957f3e987e0e54b", + strip_prefix = "lz4-1.9.4", + urls = ["https://github.com/lz4/lz4/archive/refs/tags/v1.9.4.tar.gz"], ) maybe( http_archive, name = "yaml-cpp", build_file = "@com_github_mvukov_rules_ros2//repositories:yaml-cpp.BUILD.bazel", - sha256 = "43e6a9fcb146ad871515f0d0873947e5d497a1c9c60c58cb102a97b47208b7c3", - strip_prefix = "yaml-cpp-yaml-cpp-0.7.0", - urls = ["https://github.com/jbeder/yaml-cpp/archive/yaml-cpp-0.7.0.tar.gz"], + sha256 = "fbe74bbdcee21d656715688706da3c8becfd946d92cd44705cc6098bb23b3a16", + strip_prefix = "yaml-cpp-0.8.0", + urls = ["https://github.com/jbeder/yaml-cpp/archive/refs/tags/0.8.0.tar.gz"], ) maybe( diff --git a/ros2/interfaces.bzl b/ros2/interfaces.bzl index 571d9871..2477054d 100644 --- a/ros2/interfaces.bzl +++ b/ros2/interfaces.bzl @@ -18,6 +18,7 @@ load("@bazel_skylib//lib:paths.bzl", "paths") load("@com_github_mvukov_rules_ros2//ros2:cc_opts.bzl", "CPP_COPTS", "C_COPTS") load("@rules_cc//cc:toolchain_utils.bzl", "find_cpp_toolchain") load("@rules_python//python:defs.bzl", "py_library") +load("@rules_python//python/private:bzlmod_enabled.bzl", "BZLMOD_ENABLED") load("@rules_ros2_pip_deps//:requirements.bzl", "requirement") Ros2InterfaceInfo = provider( @@ -824,7 +825,7 @@ py_generator_aspect = aspect( "_py_ext_c_deps": attr.label_list( default = [ Label("@rules_python//python/cc:current_py_cc_headers"), - Label("@rules_ros2_pip_deps_numpy//:headers"), + Label("@rules_ros2_pip_deps" + ("_311" if BZLMOD_ENABLED else "") + "_numpy//:headers"), ], providers = [CcInfo], ), From 64ea98a77abcf18432fcdbd8b59a19303b24173f Mon Sep 17 00:00:00 2001 From: Laurenz Date: Tue, 2 Apr 2024 21:22:18 +0200 Subject: [PATCH 02/30] bzlmoded curl --- MODULE.bazel | 1 + repositories/repositories.bzl | 18 +++++++++--------- 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/MODULE.bazel b/MODULE.bazel index bfb704c2..8ef84033 100644 --- a/MODULE.bazel +++ b/MODULE.bazel @@ -3,6 +3,7 @@ module(name = "com_github_mvukov_rules_ros2") bazel_dep(name = "asio", version = "1.28.2") bazel_dep(name = "bazel_skylib", version = "1.5.0") bazel_dep(name = "boringssl", version = "0.0.0-20240126-22d349c") +bazel_dep(name = "curl", version = "8.4.0") bazel_dep(name = "eigen", version = "3.4.0") bazel_dep(name = "fmt", version = "10.2.1") bazel_dep(name = "googletest", version = "1.14.0.bcr.1") diff --git a/repositories/repositories.bzl b/repositories/repositories.bzl index 3a14a695..bbd3b696 100644 --- a/repositories/repositories.bzl +++ b/repositories/repositories.bzl @@ -19,15 +19,6 @@ def rules_ros2_workspace_and_bazelmod_common_deps(): urls = ["https://github.com/pybind/pybind11/archive/refs/tags/v2.11.1.tar.gz"], ) - maybe( - http_archive, - name = "curl", - build_file = "@com_github_mvukov_rules_ros2//repositories:curl.BUILD.bazel", - sha256 = "230d61a4b1eb3346930f2d601cc8fe5237957163e16befbe15e0ef40c56767a2", - strip_prefix = "curl-curl-8_2_1", - urls = ["https://github.com/curl/curl/archive/refs/tags/curl-8_2_1.tar.gz"], - ) - def ros2_workspace_repositories(): """Imports dependent third-party repositories for the non-blzmod (hence, workspace-) version of the repository. @@ -177,6 +168,15 @@ def ros2_workspace_repositories(): ], ) + maybe( + http_archive, + name = "curl", + build_file = "@com_github_mvukov_rules_ros2//repositories:curl.BUILD.bazel", + sha256 = "230d61a4b1eb3346930f2d601cc8fe5237957163e16befbe15e0ef40c56767a2", + strip_prefix = "curl-curl-8_2_1", + urls = ["https://github.com/curl/curl/archive/refs/tags/curl-8_2_1.tar.gz"], + ) + maybe( http_archive, name = "zstd", From b3d2b08b5d18349e0985eec85b4a8cb45f51ee2e Mon Sep 17 00:00:00 2001 From: Laurenz Date: Tue, 2 Apr 2024 21:31:24 +0200 Subject: [PATCH 03/30] pybind11 --- MODULE.bazel | 7 +++++-- examples/MODULE.bazel | 2 +- extensions.bzl | 3 +-- repositories/repositories.bzl | 22 +++++++++------------- 4 files changed, 16 insertions(+), 18 deletions(-) diff --git a/MODULE.bazel b/MODULE.bazel index 8ef84033..b9ccaca1 100644 --- a/MODULE.bazel +++ b/MODULE.bazel @@ -11,10 +11,11 @@ bazel_dep(name = "libyaml", version = "0.2.5") bazel_dep(name = "lz4", version = "1.9.4") bazel_dep(name = "nlohmann_json", version = "3.11.3") bazel_dep(name = "platforms", version = "0.0.8") +bazel_dep(name = "pybind11_bazel", version = "2.11.1.bzl.3") bazel_dep(name = "readerwriterqueue", version = "1.0.6") bazel_dep(name = "rules_cc", version = "0.0.9") bazel_dep(name = "rules_foreign_cc", version = "0.10.1") -bazel_dep(name = "rules_python", version = "0.29.0") +bazel_dep(name = "rules_python", version = "0.31.0") bazel_dep(name = "spdlog", version = "1.12.0") bazel_dep(name = "sqlite3", version = "3.42.0.bcr.1") bazel_dep(name = "tinyxml2", version = "10.0.0") @@ -60,6 +61,9 @@ pip.parse( ) use_repo(pip, "rules_ros2_resolver_deps") +pybind_configure = use_extension("@pybind11_bazel//:internal_configure.bzl", "internal_configure_extension") +use_repo(pybind_configure, "pybind11") + non_module_deps = use_extension("@com_github_mvukov_rules_ros2//:extensions.bzl", "non_module_deps") use_repo( non_module_deps, @@ -67,7 +71,6 @@ use_repo( "foxglove_bridge", "iceoryx", "osrf_pycommon", - "pybind11", "ros2_ament_cmake_ros", "ros2_ament_index", "ros2_class_loader", diff --git a/examples/MODULE.bazel b/examples/MODULE.bazel index 09412cd6..5863311f 100644 --- a/examples/MODULE.bazel +++ b/examples/MODULE.bazel @@ -56,7 +56,7 @@ use_repo( ) bazel_dep(name = "rules_cc", version = "0.0.9") -bazel_dep(name = "rules_python", version = "0.29.0") +bazel_dep(name = "rules_python", version = "0.31.0") python = use_extension("@rules_python//python:extensions.bzl", "python") python.toolchain( diff --git a/extensions.bzl b/extensions.bzl index 48910434..4466f393 100644 --- a/extensions.bzl +++ b/extensions.bzl @@ -1,7 +1,6 @@ -load("@com_github_mvukov_rules_ros2//repositories:repositories.bzl", "ros2_repositories", "rules_ros2_workspace_and_bazelmod_common_deps") +load("@com_github_mvukov_rules_ros2//repositories:repositories.bzl", "ros2_repositories") def _non_module_deps_impl(mctx): - rules_ros2_workspace_and_bazelmod_common_deps() ros2_repositories() non_module_deps = module_extension( diff --git a/repositories/repositories.bzl b/repositories/repositories.bzl index bbd3b696..7106c6b2 100644 --- a/repositories/repositories.bzl +++ b/repositories/repositories.bzl @@ -8,24 +8,11 @@ load( "ros2_repositories_impl", ) -def rules_ros2_workspace_and_bazelmod_common_deps(): - """Import http_archive dependencies needed for both the WORKSPACE and MODULE.bazel version of rules_ros2.""" - maybe( - http_archive, - name = "pybind11", - build_file = "@com_github_mvukov_rules_ros2//repositories:pybind11.BUILD.bazel", - sha256 = "d475978da0cdc2d43b73f30910786759d593a9d8ee05b1b6846d1eb16c6d2e0c", - strip_prefix = "pybind11-2.11.1", - urls = ["https://github.com/pybind/pybind11/archive/refs/tags/v2.11.1.tar.gz"], - ) - def ros2_workspace_repositories(): """Imports dependent third-party repositories for the non-blzmod (hence, workspace-) version of the repository. In particular, imports third-party package repositories excluding ROS 2 packages. ROS 2-specific repositories are imported with `ros2_repositories()` macro. """ - rules_ros2_workspace_and_bazelmod_common_deps() - maybe( http_archive, name = "rules_python", @@ -68,6 +55,15 @@ def ros2_workspace_repositories(): urls = ["https://github.com/yaml/libyaml/releases/download/0.2.5/yaml-0.2.5.tar.gz"], ) + maybe( + http_archive, + name = "pybind11", + build_file = "@com_github_mvukov_rules_ros2//repositories:pybind11.BUILD.bazel", + sha256 = "d475978da0cdc2d43b73f30910786759d593a9d8ee05b1b6846d1eb16c6d2e0c", + strip_prefix = "pybind11-2.11.1", + urls = ["https://github.com/pybind/pybind11/archive/refs/tags/v2.11.1.tar.gz"], + ) + maybe( http_archive, name = "rules_foreign_cc", From 4cc7d12c89748b785d759e058dbdb062b92986b6 Mon Sep 17 00:00:00 2001 From: Laurenz Date: Tue, 2 Apr 2024 21:34:10 +0200 Subject: [PATCH 04/30] pre-commit --- MODULE.bazel | 2 +- repositories/foxglove_bridge.BUILD.bazel | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/MODULE.bazel b/MODULE.bazel index b9ccaca1..00a7d6af 100644 --- a/MODULE.bazel +++ b/MODULE.bazel @@ -71,6 +71,7 @@ use_repo( "foxglove_bridge", "iceoryx", "osrf_pycommon", + "ros2", "ros2_ament_cmake_ros", "ros2_ament_index", "ros2_class_loader", @@ -111,5 +112,4 @@ use_repo( "ros2_urdfdom_headers", "ros2_xacro", "ros2cli", - "ros2", ) diff --git a/repositories/foxglove_bridge.BUILD.bazel b/repositories/foxglove_bridge.BUILD.bazel index 11482669..ca9face1 100644 --- a/repositories/foxglove_bridge.BUILD.bazel +++ b/repositories/foxglove_bridge.BUILD.bazel @@ -25,8 +25,8 @@ cc_library( copts = ["-std=c++17"], includes = ["foxglove_bridge_base/include"], deps = [ - "@nlohmann_json//:json", "@boringssl//:ssl", + "@nlohmann_json//:json", "@websocketpp", ], ) From 0217b58faed47b53fcbaa28270f9aa03a7fbdb0e Mon Sep 17 00:00:00 2001 From: Laurenz Date: Tue, 2 Apr 2024 21:44:02 +0200 Subject: [PATCH 05/30] fix examples WS load --- examples/WORKSPACE | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/WORKSPACE b/examples/WORKSPACE index fb13e6dc..b290b71e 100644 --- a/examples/WORKSPACE +++ b/examples/WORKSPACE @@ -16,7 +16,7 @@ local_repository( # url = "https://github.com/mvukov/rules_ros2/archive/.tar.gz", # ) -load("//repositories:repositories.bzl", "ros2_repositories", "ros2_workspace_repositories") +load("@com_github_mvukov_rules_ros2//repositories:repositories.bzl", "ros2_repositories", "ros2_workspace_repositories") ros2_workspace_repositories() From db3cad8fb66a9b53654823ec97083103094a0616 Mon Sep 17 00:00:00 2001 From: Laurenz Date: Tue, 2 Apr 2024 23:07:09 +0200 Subject: [PATCH 06/30] python version shenanigans --- BUILD.bazel | 9 +++++++++ MODULE.bazel | 41 ++++++++++++++++++++++------------------- examples/MODULE.bazel | 12 ++++++------ ros2/interfaces.bzl | 3 +-- 4 files changed, 38 insertions(+), 27 deletions(-) diff --git a/BUILD.bazel b/BUILD.bazel index a89ad7df..ef8e1d30 100644 --- a/BUILD.bazel +++ b/BUILD.bazel @@ -1,4 +1,5 @@ load("@rules_python//python:pip.bzl", "compile_pip_requirements") +load("@rules_python//python/private:bzlmod_enabled.bzl", "BZLMOD_ENABLED") compile_pip_requirements( name = "python_requirements", @@ -12,3 +13,11 @@ exports_files([ "requirements.txt", "requirements_lock.txt", ]) + +DEFAULT_PYTHON_VERSION = "3.10" # keep in sync with MODULE.bazel + +alias( + name = "rules_ros2_pip_deps_numpy_headers", + actual = ("@rules_ros2_pip_deps_%s_numpy//:headers" % DEFAULT_PYTHON_VERSION.replace(".", "")) if BZLMOD_ENABLED else "@rules_ros2_pip_deps_numpy//:headers", + visibility = ["//visibility:public"], +) diff --git a/MODULE.bazel b/MODULE.bazel index 00a7d6af..2f43020a 100644 --- a/MODULE.bazel +++ b/MODULE.bazel @@ -24,13 +24,6 @@ bazel_dep(name = "yaml-cpp", version = "0.8.0") bazel_dep(name = "zlib", version = "1.3") bazel_dep(name = "zstd", version = "1.5.5.bcr.1") -python = use_extension("@rules_python//python:extensions.bzl", "python") -python.toolchain( - is_default = True, - python_version = "3.11", -) -use_repo(python, "python_versions") - pip = use_extension("@rules_python//python/extensions:pip.bzl", "pip") pip.whl_mods( # Keep this in sync with repositories/pip_annotations.bzl @@ -46,19 +39,29 @@ cc_library( whl_name = "numpy", ) use_repo(pip, "whl_mods_hub") -pip.parse( - hub_name = "rules_ros2_pip_deps", - python_version = "3.11", - requirements_lock = "//:requirements_lock.txt", - whl_modifications = {"@whl_mods_hub//:numpy.json": "numpy"}, -) + +# If you change the DEFAULT_PYTHON_VERSION, make sure to update the `//:rules_ros2_pip_deps_numpy_headers` alias +DEFAULT_PYTHON_VERSION = "3.10" +python = use_extension("@rules_python//python/extensions:python.bzl", "python") +[ + ( + python.toolchain(python_version = python_version, is_default = python_version == DEFAULT_PYTHON_VERSION), + pip.parse( + hub_name = "rules_ros2_pip_deps", + python_version = python_version, + requirements_lock = "//:requirements_lock.txt", + whl_modifications = {"@whl_mods_hub//:numpy.json": "numpy"}, + ), + use_repo(pip, "rules_ros2_pip_deps_%s_numpy" % python_version.replace(".", "")), + pip.parse( + hub_name = "rules_ros2_resolver_deps", + python_version = python_version, + requirements_lock = "//repositories/private:resolver_requirements_lock.txt", + ), + ) + for python_version in ["3.8", "3.9", DEFAULT_PYTHON_VERSION, "3.11", "3.12"] +] use_repo(pip, "rules_ros2_pip_deps") -use_repo(pip, "rules_ros2_pip_deps_311_numpy") -pip.parse( - hub_name = "rules_ros2_resolver_deps", - python_version = "3.11", - requirements_lock = "//repositories/private:resolver_requirements_lock.txt", -) use_repo(pip, "rules_ros2_resolver_deps") pybind_configure = use_extension("@pybind11_bazel//:internal_configure.bzl", "internal_configure_extension") diff --git a/examples/MODULE.bazel b/examples/MODULE.bazel index 5863311f..85a84b12 100644 --- a/examples/MODULE.bazel +++ b/examples/MODULE.bazel @@ -58,9 +58,9 @@ use_repo( bazel_dep(name = "rules_cc", version = "0.0.9") bazel_dep(name = "rules_python", version = "0.31.0") -python = use_extension("@rules_python//python:extensions.bzl", "python") -python.toolchain( - is_default = True, - python_version = "3.11", -) -use_repo(python, "python_versions") +PYTHON_VERSIONS = ["3.8", "3.9", "3.10", "3.11", "3.12"] +python = use_extension("@rules_python//python/extensions:python.bzl", "python") +[ + python.toolchain(python_version = python_version, is_default = python_version == "3.10") + for python_version in PYTHON_VERSIONS +] diff --git a/ros2/interfaces.bzl b/ros2/interfaces.bzl index 2477054d..6cfef66b 100644 --- a/ros2/interfaces.bzl +++ b/ros2/interfaces.bzl @@ -18,7 +18,6 @@ load("@bazel_skylib//lib:paths.bzl", "paths") load("@com_github_mvukov_rules_ros2//ros2:cc_opts.bzl", "CPP_COPTS", "C_COPTS") load("@rules_cc//cc:toolchain_utils.bzl", "find_cpp_toolchain") load("@rules_python//python:defs.bzl", "py_library") -load("@rules_python//python/private:bzlmod_enabled.bzl", "BZLMOD_ENABLED") load("@rules_ros2_pip_deps//:requirements.bzl", "requirement") Ros2InterfaceInfo = provider( @@ -825,7 +824,7 @@ py_generator_aspect = aspect( "_py_ext_c_deps": attr.label_list( default = [ Label("@rules_python//python/cc:current_py_cc_headers"), - Label("@rules_ros2_pip_deps" + ("_311" if BZLMOD_ENABLED else "") + "_numpy//:headers"), + Label("@com_github_mvukov_rules_ros2//:rules_ros2_pip_deps_numpy_headers"), ], providers = [CcInfo], ), From cec3c761d2b2990121e9838e98b0533ea50701c3 Mon Sep 17 00:00:00 2001 From: Laurenz Date: Tue, 2 Apr 2024 23:10:48 +0200 Subject: [PATCH 07/30] pre-commit --- MODULE.bazel | 16 ++++++++++++++-- examples/MODULE.bazel | 15 +++++++++++++-- 2 files changed, 27 insertions(+), 4 deletions(-) diff --git a/MODULE.bazel b/MODULE.bazel index 2f43020a..53e074d6 100644 --- a/MODULE.bazel +++ b/MODULE.bazel @@ -42,10 +42,15 @@ use_repo(pip, "whl_mods_hub") # If you change the DEFAULT_PYTHON_VERSION, make sure to update the `//:rules_ros2_pip_deps_numpy_headers` alias DEFAULT_PYTHON_VERSION = "3.10" + python = use_extension("@rules_python//python/extensions:python.bzl", "python") + [ ( - python.toolchain(python_version = python_version, is_default = python_version == DEFAULT_PYTHON_VERSION), + python.toolchain( + is_default = python_version == DEFAULT_PYTHON_VERSION, + python_version = python_version, + ), pip.parse( hub_name = "rules_ros2_pip_deps", python_version = python_version, @@ -59,8 +64,15 @@ python = use_extension("@rules_python//python/extensions:python.bzl", "python") requirements_lock = "//repositories/private:resolver_requirements_lock.txt", ), ) - for python_version in ["3.8", "3.9", DEFAULT_PYTHON_VERSION, "3.11", "3.12"] + for python_version in [ + "3.8", + "3.9", + DEFAULT_PYTHON_VERSION, + "3.11", + "3.12", + ] ] + use_repo(pip, "rules_ros2_pip_deps") use_repo(pip, "rules_ros2_resolver_deps") diff --git a/examples/MODULE.bazel b/examples/MODULE.bazel index 85a84b12..96e8e23f 100644 --- a/examples/MODULE.bazel +++ b/examples/MODULE.bazel @@ -58,9 +58,20 @@ use_repo( bazel_dep(name = "rules_cc", version = "0.0.9") bazel_dep(name = "rules_python", version = "0.31.0") -PYTHON_VERSIONS = ["3.8", "3.9", "3.10", "3.11", "3.12"] +PYTHON_VERSIONS = [ + "3.8", + "3.9", + "3.10", + "3.11", + "3.12", +] + python = use_extension("@rules_python//python/extensions:python.bzl", "python") + [ - python.toolchain(python_version = python_version, is_default = python_version == "3.10") + python.toolchain( + is_default = python_version == "3.10", + python_version = python_version, + ) for python_version in PYTHON_VERSIONS ] From e2b926c03075913754a8d8175e356a5637b0f5c7 Mon Sep 17 00:00:00 2001 From: Laurenz Date: Thu, 16 May 2024 01:10:11 +0200 Subject: [PATCH 08/30] POC: extra_targets alias in rules_python to make numpy headers available --- BUILD.bazel | 4 +--- MODULE.bazel | 7 +++++++ 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/BUILD.bazel b/BUILD.bazel index ef8e1d30..63fac2f4 100644 --- a/BUILD.bazel +++ b/BUILD.bazel @@ -14,10 +14,8 @@ exports_files([ "requirements_lock.txt", ]) -DEFAULT_PYTHON_VERSION = "3.10" # keep in sync with MODULE.bazel - alias( name = "rules_ros2_pip_deps_numpy_headers", - actual = ("@rules_ros2_pip_deps_%s_numpy//:headers" % DEFAULT_PYTHON_VERSION.replace(".", "")) if BZLMOD_ENABLED else "@rules_ros2_pip_deps_numpy//:headers", + actual = "@rules_ros2_pip_deps//numpy:headers" if BZLMOD_ENABLED else "@rules_ros2_pip_deps_numpy//:headers", visibility = ["//visibility:public"], ) diff --git a/MODULE.bazel b/MODULE.bazel index 53e074d6..4772c90a 100644 --- a/MODULE.bazel +++ b/MODULE.bazel @@ -16,6 +16,12 @@ bazel_dep(name = "readerwriterqueue", version = "1.0.6") bazel_dep(name = "rules_cc", version = "0.0.9") bazel_dep(name = "rules_foreign_cc", version = "0.10.1") bazel_dep(name = "rules_python", version = "0.31.0") +git_override( + module_name = "rules_python", + commit = "96fa4a9d7e21ea5e0588b3f7dfee48eeba0279a8", + remote = "https://github.com/lalten/rules_python", +) + bazel_dep(name = "spdlog", version = "1.12.0") bazel_dep(name = "sqlite3", version = "3.42.0.bcr.1") bazel_dep(name = "tinyxml2", version = "10.0.0") @@ -35,6 +41,7 @@ cc_library( deps = ["@rules_python//python/cc:current_py_cc_headers"], ) """, + extra_targets = ["headers"], hub_name = "whl_mods_hub", whl_name = "numpy", ) From 1e16de8c3797d94b54ea589524fa7be0e45481d9 Mon Sep 17 00:00:00 2001 From: Laurenz Date: Thu, 16 May 2024 13:05:26 +0200 Subject: [PATCH 09/30] POC: use whl_filegroup --- BUILD.bazel | 16 ++++++++++++---- MODULE.bazel | 25 ++++--------------------- repositories/repositories.bzl | 9 ++++++--- 3 files changed, 22 insertions(+), 28 deletions(-) diff --git a/BUILD.bazel b/BUILD.bazel index 63fac2f4..efcdf964 100644 --- a/BUILD.bazel +++ b/BUILD.bazel @@ -1,5 +1,5 @@ -load("@rules_python//python:pip.bzl", "compile_pip_requirements") -load("@rules_python//python/private:bzlmod_enabled.bzl", "BZLMOD_ENABLED") +load("@rules_cc//cc:defs.bzl", "cc_library") +load("@rules_python//python:pip.bzl", "compile_pip_requirements", "whl_filegroup") compile_pip_requirements( name = "python_requirements", @@ -14,8 +14,16 @@ exports_files([ "requirements_lock.txt", ]) -alias( +whl_filegroup( + name = "numpy_includes", + pattern = "numpy/core/include/numpy", + whl = "@rules_ros2_pip_deps//numpy:whl", +) + +cc_library( name = "rules_ros2_pip_deps_numpy_headers", - actual = "@rules_ros2_pip_deps//numpy:headers" if BZLMOD_ENABLED else "@rules_ros2_pip_deps_numpy//:headers", + hdrs = [":numpy_includes"], + includes = ["numpy_includes/numpy/core/include"], visibility = ["//visibility:public"], + deps = ["@rules_python//python/cc:current_py_cc_headers"], ) diff --git a/MODULE.bazel b/MODULE.bazel index 4772c90a..64621cd4 100644 --- a/MODULE.bazel +++ b/MODULE.bazel @@ -16,10 +16,11 @@ bazel_dep(name = "readerwriterqueue", version = "1.0.6") bazel_dep(name = "rules_cc", version = "0.0.9") bazel_dep(name = "rules_foreign_cc", version = "0.10.1") bazel_dep(name = "rules_python", version = "0.31.0") -git_override( +archive_override( module_name = "rules_python", - commit = "96fa4a9d7e21ea5e0588b3f7dfee48eeba0279a8", - remote = "https://github.com/lalten/rules_python", + integrity = "sha256-6g8/iJ3RKHBLTh5l1n/oXOAD2XT3A4ifylrCUqPFXsE=", + strip_prefix = "rules_python-4b1e05b5cfbdcd3bd2152f484bb19e098edf7a01", + urls = ["https://github.com/bazelbuild/rules_python/archive/4b1e05b5cfbdcd3bd2152f484bb19e098edf7a01.tar.gz"], ) bazel_dep(name = "spdlog", version = "1.12.0") @@ -31,23 +32,7 @@ bazel_dep(name = "zlib", version = "1.3") bazel_dep(name = "zstd", version = "1.5.5.bcr.1") pip = use_extension("@rules_python//python/extensions:pip.bzl", "pip") -pip.whl_mods( - # Keep this in sync with repositories/pip_annotations.bzl - additive_build_content = """\ -cc_library( - name = "headers", - hdrs = glob(["site-packages/numpy/core/include/numpy/**/*.h"]), - includes = ["site-packages/numpy/core/include"], - deps = ["@rules_python//python/cc:current_py_cc_headers"], -) -""", - extra_targets = ["headers"], - hub_name = "whl_mods_hub", - whl_name = "numpy", -) -use_repo(pip, "whl_mods_hub") -# If you change the DEFAULT_PYTHON_VERSION, make sure to update the `//:rules_ros2_pip_deps_numpy_headers` alias DEFAULT_PYTHON_VERSION = "3.10" python = use_extension("@rules_python//python/extensions:python.bzl", "python") @@ -62,9 +47,7 @@ python = use_extension("@rules_python//python/extensions:python.bzl", "python") hub_name = "rules_ros2_pip_deps", python_version = python_version, requirements_lock = "//:requirements_lock.txt", - whl_modifications = {"@whl_mods_hub//:numpy.json": "numpy"}, ), - use_repo(pip, "rules_ros2_pip_deps_%s_numpy" % python_version.replace(".", "")), pip.parse( hub_name = "rules_ros2_resolver_deps", python_version = python_version, diff --git a/repositories/repositories.bzl b/repositories/repositories.bzl index 7106c6b2..38fa4c95 100644 --- a/repositories/repositories.bzl +++ b/repositories/repositories.bzl @@ -16,9 +16,12 @@ def ros2_workspace_repositories(): maybe( http_archive, name = "rules_python", - sha256 = "c68bdc4fbec25de5b5493b8819cfc877c4ea299c0dcb15c244c5a00208cde311", - strip_prefix = "rules_python-0.31.0", - url = "https://github.com/bazelbuild/rules_python/archive/refs/tags/0.31.0.tar.gz", + # sha256 = "c68bdc4fbec25de5b5493b8819cfc877c4ea299c0dcb15c244c5a00208cde311", + # strip_prefix = "rules_python-0.31.0", + # url = "https://github.com/bazelbuild/rules_python/archive/refs/tags/0.31.0.tar.gz", + sha256 = "ea0f3f889dd128704b4e1e65d67fe85ce003d974f703889fca5ac252a3c55ec1", + strip_prefix = "rules_python-4b1e05b5cfbdcd3bd2152f484bb19e098edf7a01", + url = "https://github.com/bazelbuild/rules_python/archive/4b1e05b5cfbdcd3bd2152f484bb19e098edf7a01.tar.gz", ) maybe( From 01af1e404878dbd484bb7fbf6eedd61c39e18ba9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Laurenz=20Altenm=C3=BCller?= Date: Tue, 21 May 2024 14:14:41 +0200 Subject: [PATCH 10/30] split off dev_pip, fix issue with six not being found due to escaping the build sandbox --- .bazelrc | 4 ++++ MODULE.bazel | 37 +++++++++++++++++++++---------------- 2 files changed, 25 insertions(+), 16 deletions(-) diff --git a/.bazelrc b/.bazelrc index b749130a..81998d4b 100644 --- a/.bazelrc +++ b/.bazelrc @@ -4,6 +4,10 @@ # Mandatory at the moment for Bazel 7.0.0. build --noincompatible_sandbox_hermetic_tmp +# Don't let local Python site packages leak into the build and cause problems +common --incompatible_strict_action_env +common --action_env=PYTHONNOUSERSITE=1 + # Fix the wrong default to generate __init__.py to delimit a Python package. # This is a mandatory flag. build --incompatible_default_to_explicit_init_py diff --git a/MODULE.bazel b/MODULE.bazel index 64621cd4..5dfd5c2b 100644 --- a/MODULE.bazel +++ b/MODULE.bazel @@ -1,12 +1,11 @@ module(name = "com_github_mvukov_rules_ros2") bazel_dep(name = "asio", version = "1.28.2") -bazel_dep(name = "bazel_skylib", version = "1.5.0") +bazel_dep(name = "bazel_skylib", version = "1.6.1") bazel_dep(name = "boringssl", version = "0.0.0-20240126-22d349c") bazel_dep(name = "curl", version = "8.4.0") bazel_dep(name = "eigen", version = "3.4.0") bazel_dep(name = "fmt", version = "10.2.1") -bazel_dep(name = "googletest", version = "1.14.0.bcr.1") bazel_dep(name = "libyaml", version = "0.2.5") bazel_dep(name = "lz4", version = "1.9.4") bazel_dep(name = "nlohmann_json", version = "3.11.3") @@ -16,11 +15,15 @@ bazel_dep(name = "readerwriterqueue", version = "1.0.6") bazel_dep(name = "rules_cc", version = "0.0.9") bazel_dep(name = "rules_foreign_cc", version = "0.10.1") bazel_dep(name = "rules_python", version = "0.31.0") + +bazel_dep(name = "googletest", version = "1.14.0.bcr.1", dev_dependency = True) + +# TODO: remove with the next rules_python release archive_override( module_name = "rules_python", - integrity = "sha256-6g8/iJ3RKHBLTh5l1n/oXOAD2XT3A4ifylrCUqPFXsE=", - strip_prefix = "rules_python-4b1e05b5cfbdcd3bd2152f484bb19e098edf7a01", - urls = ["https://github.com/bazelbuild/rules_python/archive/4b1e05b5cfbdcd3bd2152f484bb19e098edf7a01.tar.gz"], + integrity = "sha256-jfE/hVujIeVhYFYP2bNf38/Wnli07gAjcHi8vNxUrr4=", + strip_prefix = "rules_python-730a2e39bd2702910f28629d4583b3ec49f4ee5e", + urls = ["https://github.com/bazelbuild/rules_python/archive/730a2e39bd2702910f28629d4583b3ec49f4ee5e.tar.gz"], ) bazel_dep(name = "spdlog", version = "1.12.0") @@ -31,16 +34,16 @@ bazel_dep(name = "yaml-cpp", version = "0.8.0") bazel_dep(name = "zlib", version = "1.3") bazel_dep(name = "zstd", version = "1.5.5.bcr.1") -pip = use_extension("@rules_python//python/extensions:pip.bzl", "pip") - -DEFAULT_PYTHON_VERSION = "3.10" +_DEFAULT_PYTHON = "3.10" python = use_extension("@rules_python//python/extensions:python.bzl", "python") +pip = use_extension("@rules_python//python/extensions:pip.bzl", "pip") + [ ( python.toolchain( - is_default = python_version == DEFAULT_PYTHON_VERSION, + is_default = python_version == _DEFAULT_PYTHON, python_version = python_version, ), pip.parse( @@ -48,23 +51,25 @@ python = use_extension("@rules_python//python/extensions:python.bzl", "python") python_version = python_version, requirements_lock = "//:requirements_lock.txt", ), - pip.parse( - hub_name = "rules_ros2_resolver_deps", - python_version = python_version, - requirements_lock = "//repositories/private:resolver_requirements_lock.txt", - ), ) for python_version in [ "3.8", "3.9", - DEFAULT_PYTHON_VERSION, + "3.10", "3.11", "3.12", ] ] use_repo(pip, "rules_ros2_pip_deps") -use_repo(pip, "rules_ros2_resolver_deps") + +dev_pip = use_extension("@rules_python//python/extensions:pip.bzl", "pip", dev_dependency = True) +dev_pip.parse( + hub_name = "rules_ros2_resolver_deps", + python_version = _DEFAULT_PYTHON, + requirements_lock = "//repositories/private:resolver_requirements_lock.txt", +) +use_repo(dev_pip, "rules_ros2_resolver_deps") pybind_configure = use_extension("@pybind11_bazel//:internal_configure.bzl", "internal_configure_extension") use_repo(pybind_configure, "pybind11") From 7c59bad7a943b68b116a84d1d1831349f7096cc1 Mon Sep 17 00:00:00 2001 From: Laurenz Date: Sat, 29 Jun 2024 13:47:54 +0200 Subject: [PATCH 11/30] upgrade rules_python --- MODULE.bazel | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/MODULE.bazel b/MODULE.bazel index 5dfd5c2b..bfcd9485 100644 --- a/MODULE.bazel +++ b/MODULE.bazel @@ -14,18 +14,10 @@ bazel_dep(name = "pybind11_bazel", version = "2.11.1.bzl.3") bazel_dep(name = "readerwriterqueue", version = "1.0.6") bazel_dep(name = "rules_cc", version = "0.0.9") bazel_dep(name = "rules_foreign_cc", version = "0.10.1") -bazel_dep(name = "rules_python", version = "0.31.0") +bazel_dep(name = "rules_python", version = "0.33.2") bazel_dep(name = "googletest", version = "1.14.0.bcr.1", dev_dependency = True) -# TODO: remove with the next rules_python release -archive_override( - module_name = "rules_python", - integrity = "sha256-jfE/hVujIeVhYFYP2bNf38/Wnli07gAjcHi8vNxUrr4=", - strip_prefix = "rules_python-730a2e39bd2702910f28629d4583b3ec49f4ee5e", - urls = ["https://github.com/bazelbuild/rules_python/archive/730a2e39bd2702910f28629d4583b3ec49f4ee5e.tar.gz"], -) - bazel_dep(name = "spdlog", version = "1.12.0") bazel_dep(name = "sqlite3", version = "3.42.0.bcr.1") bazel_dep(name = "tinyxml2", version = "10.0.0") From 25bbe0e29b391e1e073ab013e233c6f514af0716 Mon Sep 17 00:00:00 2001 From: Laurenz Date: Sat, 29 Jun 2024 16:16:45 +0200 Subject: [PATCH 12/30] follow https://rules-python.readthedocs.io/en/latest/toolchains.html#pinning-to-a-python-version --- BUILD.bazel | 3 ++- MODULE.bazel | 29 +++++---------------- WORKSPACE | 11 ++++---- examples/MODULE.bazel | 18 ++----------- examples/WORKSPACE | 11 ++++---- examples/actions/BUILD.bazel | 2 +- examples/chatter/BUILD.bazel | 2 +- external | 1 + repositories/BUILD.bazel | 2 +- repositories/rclcpp.BUILD.bazel | 2 +- repositories/rcutils.BUILD.bazel | 3 ++- repositories/rosidl.BUILD.bazel | 3 ++- repositories/rosidl_python.BUILD.bazel | 3 ++- repositories/rosidl_typesupport.BUILD.bazel | 3 ++- repositories/xacro.BUILD.bazel | 3 ++- ros2/BUILD.bazel | 3 ++- ros2/bag.bzl | 2 +- ros2/launch.bzl | 2 +- ros2/py_defs.bzl | 2 +- ros2/service.bzl | 2 +- ros2/test.bzl | 2 +- ros2/topic.bzl | 2 +- 22 files changed, 46 insertions(+), 65 deletions(-) create mode 120000 external diff --git a/BUILD.bazel b/BUILD.bazel index efcdf964..3cc19865 100644 --- a/BUILD.bazel +++ b/BUILD.bazel @@ -1,5 +1,6 @@ load("@rules_cc//cc:defs.bzl", "cc_library") -load("@rules_python//python:pip.bzl", "compile_pip_requirements", "whl_filegroup") +load("@rules_python//python:pip.bzl", "whl_filegroup") +load("@rules_ros2_pythons//3.10:defs.bzl", "compile_pip_requirements") compile_pip_requirements( name = "python_requirements", diff --git a/MODULE.bazel b/MODULE.bazel index bfcd9485..6fcca5a5 100644 --- a/MODULE.bazel +++ b/MODULE.bazel @@ -29,30 +29,15 @@ bazel_dep(name = "zstd", version = "1.5.5.bcr.1") _DEFAULT_PYTHON = "3.10" python = use_extension("@rules_python//python/extensions:python.bzl", "python") +python.toolchain(python_version = _DEFAULT_PYTHON) +use_repo(python, rules_ros2_pythons = "python_versions") pip = use_extension("@rules_python//python/extensions:pip.bzl", "pip") - -[ - ( - python.toolchain( - is_default = python_version == _DEFAULT_PYTHON, - python_version = python_version, - ), - pip.parse( - hub_name = "rules_ros2_pip_deps", - python_version = python_version, - requirements_lock = "//:requirements_lock.txt", - ), - ) - for python_version in [ - "3.8", - "3.9", - "3.10", - "3.11", - "3.12", - ] -] - +pip.parse( + hub_name = "rules_ros2_pip_deps", + python_version = _DEFAULT_PYTHON, + requirements_lock = "//:requirements_lock.txt", +) use_repo(pip, "rules_ros2_pip_deps") dev_pip = use_extension("@rules_python//python/extensions:pip.bzl", "pip", dev_dependency = True) diff --git a/WORKSPACE b/WORKSPACE index 1493b660..0c5f1012 100644 --- a/WORKSPACE +++ b/WORKSPACE @@ -10,17 +10,18 @@ load("//repositories:deps.bzl", "ros2_deps") ros2_deps() -load("@rules_python//python:repositories.bzl", "py_repositories", "python_register_toolchains") +load("@rules_python//python:repositories.bzl", "py_repositories", "python_register_multi_toolchains") py_repositories() -python_register_toolchains( - name = "rules_ros2_python", - python_version = "3.10", +python_register_multi_toolchains( + name = "rules_ros2_pythons", + default_version = "3.10", + python_versions = ["3.10"], ) load("@rules_python//python:pip.bzl", "pip_parse") -load("@rules_ros2_python//:defs.bzl", python_interpreter_target = "interpreter") +load("@rules_ros2_pythons//3.10:defs.bzl", python_interpreter_target = "interpreter") load("//repositories:pip_annotations.bzl", "PIP_ANNOTATIONS") pip_parse( diff --git a/examples/MODULE.bazel b/examples/MODULE.bazel index 96e8e23f..cc1c19ed 100644 --- a/examples/MODULE.bazel +++ b/examples/MODULE.bazel @@ -58,20 +58,6 @@ use_repo( bazel_dep(name = "rules_cc", version = "0.0.9") bazel_dep(name = "rules_python", version = "0.31.0") -PYTHON_VERSIONS = [ - "3.8", - "3.9", - "3.10", - "3.11", - "3.12", -] - python = use_extension("@rules_python//python/extensions:python.bzl", "python") - -[ - python.toolchain( - is_default = python_version == "3.10", - python_version = python_version, - ) - for python_version in PYTHON_VERSIONS -] +python.toolchain(python_version = "3.10") +use_repo(python, rules_ros2_pythons = "python_versions") diff --git a/examples/WORKSPACE b/examples/WORKSPACE index b290b71e..9d62ab7f 100644 --- a/examples/WORKSPACE +++ b/examples/WORKSPACE @@ -26,18 +26,19 @@ load("@com_github_mvukov_rules_ros2//repositories:deps.bzl", "ros2_deps") ros2_deps() -load("@rules_python//python:repositories.bzl", "py_repositories", "python_register_toolchains") +load("@rules_python//python:repositories.bzl", "py_repositories", "python_register_multi_toolchains") py_repositories() -python_register_toolchains( - name = "rules_ros2_python", - python_version = "3.10", +python_register_multi_toolchains( + name = "rules_ros2_pythons", + default_version = "3.10", + python_versions = ["3.10"], ) load("@com_github_mvukov_rules_ros2//repositories:pip_annotations.bzl", "PIP_ANNOTATIONS") load("@rules_python//python:pip.bzl", "pip_parse") -load("@rules_ros2_python//:defs.bzl", python_interpreter_target = "interpreter") +load("@rules_ros2_pythons//3.10:defs.bzl", python_interpreter_target = "interpreter") pip_parse( name = "rules_ros2_pip_deps", diff --git a/examples/actions/BUILD.bazel b/examples/actions/BUILD.bazel index 061a3442..8dfbf182 100644 --- a/examples/actions/BUILD.bazel +++ b/examples/actions/BUILD.bazel @@ -6,7 +6,7 @@ load( "ros2_interface_library", ) load("@com_github_mvukov_rules_ros2//ros2:launch.bzl", "ros2_launch") -load("@rules_python//python:defs.bzl", "py_binary") +load("@rules_ros2_pythons//3.10:defs.bzl", "py_binary") ros2_interface_library( name = "fibonacci_msgs", diff --git a/examples/chatter/BUILD.bazel b/examples/chatter/BUILD.bazel index 4ca03cd6..5c8cd5c5 100644 --- a/examples/chatter/BUILD.bazel +++ b/examples/chatter/BUILD.bazel @@ -3,7 +3,7 @@ load("@com_github_mvukov_rules_ros2//ros2:cc_defs.bzl", "ros2_cpp_binary") load("@com_github_mvukov_rules_ros2//ros2:launch.bzl", "ros2_launch") load("@com_github_mvukov_rules_ros2//ros2:test.bzl", "ros2_test") load("@com_github_mvukov_rules_ros2//ros2:topic.bzl", "ros2_topic") -load("@rules_python//python:defs.bzl", "py_binary") +load("@rules_ros2_pythons//3.10:defs.bzl", "py_binary") ros2_cpp_binary( name = "talker", diff --git a/external b/external new file mode 120000 index 00000000..3ee3af63 --- /dev/null +++ b/external @@ -0,0 +1 @@ +bazel-out/../../../external \ No newline at end of file diff --git a/repositories/BUILD.bazel b/repositories/BUILD.bazel index 8605492b..e406aa57 100644 --- a/repositories/BUILD.bazel +++ b/repositories/BUILD.bazel @@ -1,4 +1,4 @@ -load("@rules_python//python:defs.bzl", "py_binary") +load("@rules_ros2_pythons//3.10:defs.bzl", "py_binary") exports_files([ "deps.bzl", diff --git a/repositories/rclcpp.BUILD.bazel b/repositories/rclcpp.BUILD.bazel index ae7c3083..5deb13ec 100644 --- a/repositories/rclcpp.BUILD.bazel +++ b/repositories/rclcpp.BUILD.bazel @@ -10,8 +10,8 @@ load( "rclcpp_interfaces", ) load("@com_github_mvukov_rules_ros2//ros2:cc_defs.bzl", "ros2_cpp_library") -load("@rules_python//python:defs.bzl", "py_binary") load("@rules_ros2_pip_deps//:requirements.bzl", "requirement") +load("@rules_ros2_pythons//3.10:defs.bzl", "py_binary") _GENERATE_LOGGING_MACROS_PY = "@com_github_mvukov_rules_ros2//repositories:generate_rclcpp_logging_macros.py" diff --git a/repositories/rcutils.BUILD.bazel b/repositories/rcutils.BUILD.bazel index b8358f00..0e3ba292 100644 --- a/repositories/rcutils.BUILD.bazel +++ b/repositories/rcutils.BUILD.bazel @@ -7,8 +7,9 @@ load( "logging_macros", ) load("@com_github_mvukov_rules_ros2//ros2:cc_defs.bzl", "ros2_c_library") -load("@rules_python//python:defs.bzl", "py_binary", "py_library") +load("@rules_python//python:defs.bzl", "py_library") load("@rules_ros2_pip_deps//:requirements.bzl", "requirement") +load("@rules_ros2_pythons//3.10:defs.bzl", "py_binary") _GENERATE_LOGGING_MACROS_PY = "@com_github_mvukov_rules_ros2//repositories:generate_rcutils_logging_macros.py" diff --git a/repositories/rosidl.BUILD.bazel b/repositories/rosidl.BUILD.bazel index 45c8ff74..d1be4bf0 100644 --- a/repositories/rosidl.BUILD.bazel +++ b/repositories/rosidl.BUILD.bazel @@ -9,8 +9,9 @@ load( "ros2_cpp_binary", "ros2_cpp_library", ) -load("@rules_python//python:defs.bzl", "py_binary", "py_library") +load("@rules_python//python:defs.bzl", "py_library") load("@rules_ros2_pip_deps//:requirements.bzl", "requirement") +load("@rules_ros2_pythons//3.10:defs.bzl", "py_binary") ros2_c_library( name = "rosidl_typesupport_interface", diff --git a/repositories/rosidl_python.BUILD.bazel b/repositories/rosidl_python.BUILD.bazel index ef4ae4fc..7bf60857 100644 --- a/repositories/rosidl_python.BUILD.bazel +++ b/repositories/rosidl_python.BUILD.bazel @@ -2,8 +2,9 @@ """ load("@bazel_skylib//rules:copy_file.bzl", "copy_file") -load("@rules_python//python:defs.bzl", "py_binary", "py_library") +load("@rules_python//python:defs.bzl", "py_library") load("@rules_ros2_pip_deps//:requirements.bzl", "requirement") +load("@rules_ros2_pythons//3.10:defs.bzl", "py_binary") py_library( name = "rosidl_generator_py_lib", diff --git a/repositories/rosidl_typesupport.BUILD.bazel b/repositories/rosidl_typesupport.BUILD.bazel index c06b233c..a517ecab 100644 --- a/repositories/rosidl_typesupport.BUILD.bazel +++ b/repositories/rosidl_typesupport.BUILD.bazel @@ -7,7 +7,8 @@ load( "ros2_c_library", "ros2_cpp_library", ) -load("@rules_python//python:defs.bzl", "py_binary", "py_library") +load("@rules_python//python:defs.bzl", "py_library") +load("@rules_ros2_pythons//3.10:defs.bzl", "py_binary") ros2_c_library( name = "rosidl_typesupport_c_c", diff --git a/repositories/xacro.BUILD.bazel b/repositories/xacro.BUILD.bazel index 4fb1e309..66d4f9bb 100644 --- a/repositories/xacro.BUILD.bazel +++ b/repositories/xacro.BUILD.bazel @@ -1,8 +1,9 @@ """ Builds xacro. """ -load("@rules_python//python:defs.bzl", "py_binary", "py_library") +load("@rules_python//python:defs.bzl", "py_library") load("@rules_ros2_pip_deps//:requirements.bzl", "requirement") +load("@rules_ros2_pythons//3.10:defs.bzl", "py_binary") py_library( name = "xacro", diff --git a/ros2/BUILD.bazel b/ros2/BUILD.bazel index 59a136f2..3cf1d6a9 100644 --- a/ros2/BUILD.bazel +++ b/ros2/BUILD.bazel @@ -1,7 +1,8 @@ """ ROS 2 common definitions. """ -load("@rules_python//python:defs.bzl", "py_binary", "py_library") +load("@rules_python//python:defs.bzl", "py_library") +load("@rules_ros2_pythons//3.10:defs.bzl", "py_binary") exports_files([ "ament.bzl", diff --git a/ros2/bag.bzl b/ros2/bag.bzl index 4a6f6ed1..3948352b 100644 --- a/ros2/bag.bzl +++ b/ros2/bag.bzl @@ -3,7 +3,7 @@ load("@bazel_skylib//lib:paths.bzl", "paths") load("@com_github_mvukov_rules_ros2//ros2:ament.bzl", "py_launcher") -load("@rules_python//python:defs.bzl", "py_binary") +load("@rules_ros2_pythons//3.10:defs.bzl", "py_binary") def ros2_bag(name, idl_deps = None, **kwargs): """ Defines a binary target for a bag app. diff --git a/ros2/launch.bzl b/ros2/launch.bzl index 37d27724..297ad795 100644 --- a/ros2/launch.bzl +++ b/ros2/launch.bzl @@ -2,7 +2,7 @@ """ load("@com_github_mvukov_rules_ros2//ros2:ament.bzl", "py_launcher") -load("@rules_python//python:defs.bzl", "py_binary") +load("@rules_ros2_pythons//3.10:defs.bzl", "py_binary") def ros2_launch(name, launch_file, nodes = None, deps = None, data = None, idl_deps = None, **kwargs): """ Defines a ROS 2 deployment. diff --git a/ros2/py_defs.bzl b/ros2/py_defs.bzl index e0f7901a..24a44b1e 100644 --- a/ros2/py_defs.bzl +++ b/ros2/py_defs.bzl @@ -3,7 +3,7 @@ load("@com_github_mvukov_rules_ros2//ros2:ament.bzl", "sh_launcher", "split_kwargs") load("@com_github_mvukov_rules_ros2//third_party:symlink.bzl", "symlink") -load("@rules_python//python:defs.bzl", "py_binary", "py_test") +load("@rules_ros2_pythons//3.10:defs.bzl", "py_binary", "py_test") def _ros2_py_exec(target, name, srcs, main, set_up_ament, **kwargs): if set_up_ament == False: diff --git a/ros2/service.bzl b/ros2/service.bzl index 10fcf77b..9d5924b6 100644 --- a/ros2/service.bzl +++ b/ros2/service.bzl @@ -1,7 +1,7 @@ """ Implements a macro for setting up a ROS 2 service app. """ -load("@rules_python//python:defs.bzl", "py_binary") +load("@rules_ros2_pythons//3.10:defs.bzl", "py_binary") def ros2_service(name, deps, **kwargs): """ Defines a ROS 2 service app for a set of deps. diff --git a/ros2/test.bzl b/ros2/test.bzl index df964399..ebea8c63 100644 --- a/ros2/test.bzl +++ b/ros2/test.bzl @@ -2,8 +2,8 @@ """ load("@com_github_mvukov_rules_ros2//ros2:ament.bzl", "py_launcher") -load("@rules_python//python:defs.bzl", "py_test") load("@rules_ros2_pip_deps//:requirements.bzl", "requirement") +load("@rules_ros2_pythons//3.10:defs.bzl", "py_test") def ros2_test(name, launch_file, nodes = None, deps = None, data = None, idl_deps = None, use_pytest = False, **kwargs): """ Defines a ROS 2 test. diff --git a/ros2/topic.bzl b/ros2/topic.bzl index 75c2b0c1..1e11f5a4 100644 --- a/ros2/topic.bzl +++ b/ros2/topic.bzl @@ -1,7 +1,7 @@ """ Implements a macro for setting up a ROS 2 topic app. """ -load("@rules_python//python:defs.bzl", "py_binary") +load("@rules_ros2_pythons//3.10:defs.bzl", "py_binary") def ros2_topic(name, deps, **kwargs): """ Defines a ROS 2 topic app for a set of deps. From ebdf5d8b97ec48183799701bacf6469d8e3ce83d Mon Sep 17 00:00:00 2001 From: Laurenz Date: Sat, 29 Jun 2024 16:26:32 +0200 Subject: [PATCH 13/30] examples rules_python version --- examples/MODULE.bazel | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/MODULE.bazel b/examples/MODULE.bazel index cc1c19ed..6e1e1833 100644 --- a/examples/MODULE.bazel +++ b/examples/MODULE.bazel @@ -56,7 +56,7 @@ use_repo( ) bazel_dep(name = "rules_cc", version = "0.0.9") -bazel_dep(name = "rules_python", version = "0.31.0") +bazel_dep(name = "rules_python", version = "0.33.2") python = use_extension("@rules_python//python/extensions:python.bzl", "python") python.toolchain(python_version = "3.10") From 7cd23658a0b33cf72e49fe554d98e07be32a77d8 Mon Sep 17 00:00:00 2001 From: Laurenz Date: Sat, 29 Jun 2024 16:27:30 +0200 Subject: [PATCH 14/30] rm pip annotations (using whl_filegroup now) --- WORKSPACE | 2 -- examples/WORKSPACE | 2 -- repositories/BUILD.bazel | 3 --- repositories/pip_annotations.bzl | 15 --------------- 4 files changed, 22 deletions(-) delete mode 100644 repositories/pip_annotations.bzl diff --git a/WORKSPACE b/WORKSPACE index 0c5f1012..92d43786 100644 --- a/WORKSPACE +++ b/WORKSPACE @@ -22,11 +22,9 @@ python_register_multi_toolchains( load("@rules_python//python:pip.bzl", "pip_parse") load("@rules_ros2_pythons//3.10:defs.bzl", python_interpreter_target = "interpreter") -load("//repositories:pip_annotations.bzl", "PIP_ANNOTATIONS") pip_parse( name = "rules_ros2_pip_deps", - annotations = PIP_ANNOTATIONS, python_interpreter_target = python_interpreter_target, requirements_lock = "@com_github_mvukov_rules_ros2//:requirements_lock.txt", ) diff --git a/examples/WORKSPACE b/examples/WORKSPACE index 9d62ab7f..8aabb41c 100644 --- a/examples/WORKSPACE +++ b/examples/WORKSPACE @@ -36,13 +36,11 @@ python_register_multi_toolchains( python_versions = ["3.10"], ) -load("@com_github_mvukov_rules_ros2//repositories:pip_annotations.bzl", "PIP_ANNOTATIONS") load("@rules_python//python:pip.bzl", "pip_parse") load("@rules_ros2_pythons//3.10:defs.bzl", python_interpreter_target = "interpreter") pip_parse( name = "rules_ros2_pip_deps", - annotations = PIP_ANNOTATIONS, python_interpreter_target = python_interpreter_target, requirements_lock = "@com_github_mvukov_rules_ros2//:requirements_lock.txt", ) diff --git a/repositories/BUILD.bazel b/repositories/BUILD.bazel index e406aa57..43f7e0a8 100644 --- a/repositories/BUILD.bazel +++ b/repositories/BUILD.bazel @@ -1,12 +1,9 @@ -load("@rules_ros2_pythons//3.10:defs.bzl", "py_binary") - exports_files([ "deps.bzl", "logging_macros.bzl", "generate_rclcpp_interface.py", "generate_rclcpp_logging_macros.py", "generate_rcutils_logging_macros.py", - "pip_annotations.bzl", "rclcpp_interfaces.bzl", "repositories.bzl", "ros2_repo_mappings.yaml", diff --git a/repositories/pip_annotations.bzl b/repositories/pip_annotations.bzl deleted file mode 100644 index 2691d95a..00000000 --- a/repositories/pip_annotations.bzl +++ /dev/null @@ -1,15 +0,0 @@ -load("@rules_python//python:pip.bzl", "package_annotation") - -# Keep this in sync with MODULE.bazel -PIP_ANNOTATIONS = { - "numpy": package_annotation( - additive_build_content = """\ -cc_library( - name = "headers", - hdrs = glob(["site-packages/numpy/core/include/numpy/**/*.h"]), - includes = ["site-packages/numpy/core/include"], - deps = ["@rules_python//python/cc:current_py_cc_headers"], -) -""", - ), -} From 3a1779e774ab182119dc9f550aaeed29bbc4d479 Mon Sep 17 00:00:00 2001 From: Laurenz Date: Sat, 29 Jun 2024 16:29:44 +0200 Subject: [PATCH 15/30] bazelrc --- .bazelrc | 2 ++ .github/workflows/ci.bazelrc | 3 --- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/.bazelrc b/.bazelrc index 81998d4b..fa5084bf 100644 --- a/.bazelrc +++ b/.bazelrc @@ -35,6 +35,8 @@ test --build_tests_only # Show all the problems in CI test --keep_going +test --test_output=errors +build --verbose_failures # To use a clang compiler, invoke Bazel with `--config=clang`. build:clang --repo_env=CC=clang diff --git a/.github/workflows/ci.bazelrc b/.github/workflows/ci.bazelrc index 6599c77c..383cce73 100644 --- a/.github/workflows/ci.bazelrc +++ b/.github/workflows/ci.bazelrc @@ -23,8 +23,5 @@ build:remote --noslim_profile # Don't spam CI logs. build --show_progress_rate_limit=60 -# Don't rely on test logs being easily accessible from the test runner, -# though it makes the log noisier. -test --test_output=errors # Allows tests to run bazelisk-in-bazel, since this is the cache folder used test --test_env=XDG_CACHE_HOME From c8e9ef4a2cbe03165b1fbeb37e37a6f8a0b56cb5 Mon Sep 17 00:00:00 2001 From: Laurenz Date: Sat, 29 Jun 2024 16:42:13 +0200 Subject: [PATCH 16/30] fix examples? --- .github/workflows/ci.bazelrc | 1 + examples/MODULE.bazel | 4 ---- examples/actions/BUILD.bazel | 2 +- examples/chatter/BUILD.bazel | 2 +- 4 files changed, 3 insertions(+), 6 deletions(-) diff --git a/.github/workflows/ci.bazelrc b/.github/workflows/ci.bazelrc index 383cce73..796cafd5 100644 --- a/.github/workflows/ci.bazelrc +++ b/.github/workflows/ci.bazelrc @@ -22,6 +22,7 @@ build:remote --noslim_profile # Don't spam CI logs. build --show_progress_rate_limit=60 +common --color=yes # Allows tests to run bazelisk-in-bazel, since this is the cache folder used test --test_env=XDG_CACHE_HOME diff --git a/examples/MODULE.bazel b/examples/MODULE.bazel index 6e1e1833..1ae5aee6 100644 --- a/examples/MODULE.bazel +++ b/examples/MODULE.bazel @@ -57,7 +57,3 @@ use_repo( bazel_dep(name = "rules_cc", version = "0.0.9") bazel_dep(name = "rules_python", version = "0.33.2") - -python = use_extension("@rules_python//python/extensions:python.bzl", "python") -python.toolchain(python_version = "3.10") -use_repo(python, rules_ros2_pythons = "python_versions") diff --git a/examples/actions/BUILD.bazel b/examples/actions/BUILD.bazel index 8dfbf182..061a3442 100644 --- a/examples/actions/BUILD.bazel +++ b/examples/actions/BUILD.bazel @@ -6,7 +6,7 @@ load( "ros2_interface_library", ) load("@com_github_mvukov_rules_ros2//ros2:launch.bzl", "ros2_launch") -load("@rules_ros2_pythons//3.10:defs.bzl", "py_binary") +load("@rules_python//python:defs.bzl", "py_binary") ros2_interface_library( name = "fibonacci_msgs", diff --git a/examples/chatter/BUILD.bazel b/examples/chatter/BUILD.bazel index 5c8cd5c5..4ca03cd6 100644 --- a/examples/chatter/BUILD.bazel +++ b/examples/chatter/BUILD.bazel @@ -3,7 +3,7 @@ load("@com_github_mvukov_rules_ros2//ros2:cc_defs.bzl", "ros2_cpp_binary") load("@com_github_mvukov_rules_ros2//ros2:launch.bzl", "ros2_launch") load("@com_github_mvukov_rules_ros2//ros2:test.bzl", "ros2_test") load("@com_github_mvukov_rules_ros2//ros2:topic.bzl", "ros2_topic") -load("@rules_ros2_pythons//3.10:defs.bzl", "py_binary") +load("@rules_python//python:defs.bzl", "py_binary") ros2_cpp_binary( name = "talker", From 7243f76113d83086d7a894f2feafe99b0584b2f1 Mon Sep 17 00:00:00 2001 From: Laurenz Date: Sat, 29 Jun 2024 18:03:01 +0200 Subject: [PATCH 17/30] gitignore --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 32436ac2..3253e30c 100644 --- a/.gitignore +++ b/.gitignore @@ -2,3 +2,4 @@ bazel-* __pycache__ user.bazelrc +external/ From 435e95af9280a4cf584ac81a52118d0c9d5ababe Mon Sep 17 00:00:00 2001 From: Laurenz Date: Sat, 29 Jun 2024 20:56:16 +0200 Subject: [PATCH 18/30] Fix plugin aspect for py version transition --- ros2/plugin_aspects.bzl | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/ros2/plugin_aspects.bzl b/ros2/plugin_aspects.bzl index e29f2795..2c4da410 100644 --- a/ros2/plugin_aspects.bzl +++ b/ros2/plugin_aspects.bzl @@ -38,15 +38,18 @@ Ros2PluginCollectorAspectInfo = provider( ], ) -_ROS2_COLLECTOR_ATTR_ASPECTS = ["data", "deps"] +# From https://github.com/bazelbuild/rules_python/blob/0.33.2/python/config_settings/transition.bzl#L121-L140 +_py_transition_attrs = ["target", "tools"] + +_ROS2_COLLECTOR_ATTR_ASPECTS = ["data", "deps"] + _py_transition_attrs def _get_list_attr(rule_attr, attr_name): if not hasattr(rule_attr, attr_name): return [] candidate = getattr(rule_attr, attr_name) - if type(candidate) != "list": - fail("Expected a list for attribute `{}`!".format(attr_name)) - return candidate + if type(candidate) == type([]): + return candidate + return [candidate] def _collect_deps(rule_attr, attr_name, provider_info): return [ From fa2c658af3e82604075ee339efe48996f37439ad Mon Sep 17 00:00:00 2001 From: Laurenz Date: Sat, 29 Jun 2024 20:58:38 +0200 Subject: [PATCH 19/30] simplify --- ros2/plugin_aspects.bzl | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/ros2/plugin_aspects.bzl b/ros2/plugin_aspects.bzl index 2c4da410..f807c2f7 100644 --- a/ros2/plugin_aspects.bzl +++ b/ros2/plugin_aspects.bzl @@ -44,9 +44,7 @@ _py_transition_attrs = ["target", "tools"] _ROS2_COLLECTOR_ATTR_ASPECTS = ["data", "deps"] + _py_transition_attrs def _get_list_attr(rule_attr, attr_name): - if not hasattr(rule_attr, attr_name): - return [] - candidate = getattr(rule_attr, attr_name) + candidate = getattr(rule_attr, attr_name, []) if type(candidate) == type([]): return candidate return [candidate] From 8ae403826e7fc139bbe2d9964cbaa0092e17555e Mon Sep 17 00:00:00 2001 From: Laurenz Date: Sat, 29 Jun 2024 21:18:29 +0200 Subject: [PATCH 20/30] empty commit to retrigger CI on potentially flaky `//third_party/foxglove_bridge:tests` From 77d2a3c376cef8e2a06ebba7399474195fe85443 Mon Sep 17 00:00:00 2001 From: Laurenz Date: Sat, 29 Jun 2024 21:31:56 +0200 Subject: [PATCH 21/30] mark test as flaky --- third_party/foxglove_bridge/BUILD.bazel | 1 + 1 file changed, 1 insertion(+) diff --git a/third_party/foxglove_bridge/BUILD.bazel b/third_party/foxglove_bridge/BUILD.bazel index 5d7a03b2..e4a5a934 100644 --- a/third_party/foxglove_bridge/BUILD.bazel +++ b/third_party/foxglove_bridge/BUILD.bazel @@ -42,6 +42,7 @@ ros2_cpp_test( size = "small", srcs = ["foxglove_bridge_tests.cc"], env = {"ROS_DISTRO": "humble"}, + flaky = True, idl_deps = [ "@ros2_rcl_interfaces//:rcl_interfaces", "@ros2_common_interfaces//:std_msgs", From 4d492f346105a86b81bb95604daddcb1ee9ae98b Mon Sep 17 00:00:00 2001 From: Laurenz Date: Sat, 29 Jun 2024 21:56:45 +0200 Subject: [PATCH 22/30] allow flaky tests... --- ros2/ament.bzl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ros2/ament.bzl b/ros2/ament.bzl index 2c0f0020..6d658a85 100644 --- a/ros2/ament.bzl +++ b/ros2/ament.bzl @@ -329,7 +329,7 @@ def py_launcher(name, deps, idl_deps = None, **kwargs): def split_kwargs(**kwargs): """Split kwargs into those to be forwarded to the actual binary target and launcher target respectively.""" - launcher_attrs = ["args", "env", "size", "tags", "timeout", "visibility"] + launcher_attrs = ["args", "env", "flaky", "size", "tags", "timeout", "visibility"] launcher_target_kwargs = {attr: kwargs.pop(attr) for attr in launcher_attrs if attr in kwargs} return launcher_target_kwargs, kwargs From c57a5c920e63a2d8b42286018b11971d5ebbde19 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Laurenz=20Altenm=C3=BCller?= Date: Thu, 29 Aug 2024 21:32:30 +0200 Subject: [PATCH 23/30] sync versions --- MODULE.bazel | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/MODULE.bazel b/MODULE.bazel index 6fcca5a5..132f2f3d 100644 --- a/MODULE.bazel +++ b/MODULE.bazel @@ -1,30 +1,31 @@ module(name = "com_github_mvukov_rules_ros2") -bazel_dep(name = "asio", version = "1.28.2") -bazel_dep(name = "bazel_skylib", version = "1.6.1") -bazel_dep(name = "boringssl", version = "0.0.0-20240126-22d349c") -bazel_dep(name = "curl", version = "8.4.0") +bazel_dep(name = "asio", version = "1.31.0") +bazel_dep(name = "bazel_skylib", version = "1.7.1") +bazel_dep(name = "boringssl", version = "0.0.0-20240530-2db0eb3") +bazel_dep(name = "curl", version = "8.8.0.bcr.1") bazel_dep(name = "eigen", version = "3.4.0") -bazel_dep(name = "fmt", version = "10.2.1") +bazel_dep(name = "fmt", version = "10.2.1.bcr.1") bazel_dep(name = "libyaml", version = "0.2.5") bazel_dep(name = "lz4", version = "1.9.4") bazel_dep(name = "nlohmann_json", version = "3.11.3") -bazel_dep(name = "platforms", version = "0.0.8") -bazel_dep(name = "pybind11_bazel", version = "2.11.1.bzl.3") +bazel_dep(name = "platforms", version = "0.0.10") +bazel_dep(name = "pybind11_bazel", version = "2.12.0") +bazel_dep(name = "re2", version = "2024-07-02") # this is only here to force graph to resolve to higher res2 version compatible with pybind11_bazel above. Remove once no longer needed. bazel_dep(name = "readerwriterqueue", version = "1.0.6") bazel_dep(name = "rules_cc", version = "0.0.9") -bazel_dep(name = "rules_foreign_cc", version = "0.10.1") -bazel_dep(name = "rules_python", version = "0.33.2") +bazel_dep(name = "rules_foreign_cc", version = "0.11.1") +bazel_dep(name = "rules_python", version = "0.35.0") bazel_dep(name = "googletest", version = "1.14.0.bcr.1", dev_dependency = True) -bazel_dep(name = "spdlog", version = "1.12.0") +bazel_dep(name = "spdlog", version = "1.14.1") bazel_dep(name = "sqlite3", version = "3.42.0.bcr.1") bazel_dep(name = "tinyxml2", version = "10.0.0") bazel_dep(name = "websocketpp", version = "0.8.2") bazel_dep(name = "yaml-cpp", version = "0.8.0") bazel_dep(name = "zlib", version = "1.3") -bazel_dep(name = "zstd", version = "1.5.5.bcr.1") +bazel_dep(name = "zstd", version = "1.5.6") _DEFAULT_PYTHON = "3.10" From e662ac5f60f421e47445a230a21fd757689790de Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Laurenz=20Altenm=C3=BCller?= Date: Thu, 29 Aug 2024 21:33:57 +0200 Subject: [PATCH 24/30] is_default=True --- MODULE.bazel | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/MODULE.bazel b/MODULE.bazel index 132f2f3d..b72cb52d 100644 --- a/MODULE.bazel +++ b/MODULE.bazel @@ -30,7 +30,10 @@ bazel_dep(name = "zstd", version = "1.5.6") _DEFAULT_PYTHON = "3.10" python = use_extension("@rules_python//python/extensions:python.bzl", "python") -python.toolchain(python_version = _DEFAULT_PYTHON) +python.toolchain( + is_default = True, + python_version = _DEFAULT_PYTHON, +) use_repo(python, rules_ros2_pythons = "python_versions") pip = use_extension("@rules_python//python/extensions:pip.bzl", "pip") From 2b06741b470c72151d1b821818edf5df85faf426 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Laurenz=20Altenm=C3=BCller?= Date: Thu, 29 Aug 2024 22:14:58 +0200 Subject: [PATCH 25/30] Add rules_rust --- MODULE.bazel | 37 ++++++++++++++++++++++++++++++++++--- 1 file changed, 34 insertions(+), 3 deletions(-) diff --git a/MODULE.bazel b/MODULE.bazel index b72cb52d..3612c534 100644 --- a/MODULE.bazel +++ b/MODULE.bazel @@ -16,9 +16,7 @@ bazel_dep(name = "readerwriterqueue", version = "1.0.6") bazel_dep(name = "rules_cc", version = "0.0.9") bazel_dep(name = "rules_foreign_cc", version = "0.11.1") bazel_dep(name = "rules_python", version = "0.35.0") - -bazel_dep(name = "googletest", version = "1.14.0.bcr.1", dev_dependency = True) - +bazel_dep(name = "rules_rust", version = "0.49.3") bazel_dep(name = "spdlog", version = "1.14.1") bazel_dep(name = "sqlite3", version = "3.42.0.bcr.1") bazel_dep(name = "tinyxml2", version = "10.0.0") @@ -27,6 +25,32 @@ bazel_dep(name = "yaml-cpp", version = "0.8.0") bazel_dep(name = "zlib", version = "1.3") bazel_dep(name = "zstd", version = "1.5.6") +bazel_dep(name = "googletest", version = "1.14.0.bcr.1", dev_dependency = True) + +http_archive = use_repo_rule("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") + +http_archive( + name = "ros2_rust", + build_file = "@com_github_mvukov_rules_ros2//repositories:ros2_rust.BUILD.bazel", + patch_args = ["-p1"], + patches = [ + "@com_github_mvukov_rules_ros2//repositories/patches:ros2_rust_fix_rcl_bindings.patch", + "@com_github_mvukov_rules_ros2//repositories/patches:ros2_rust_fix_rosidl_generator.patch", + "@com_github_mvukov_rules_ros2//repositories/patches:ros2_rust_no_msg_vendoring.patch", + ], + sha256 = "ec3ebfb177f0ecfc2c6ecb47f2fffe701f6ebeb2b29ab482b57b53dd2c260da2", + strip_prefix = "ros2_rust-2e746d6e0d2cbeed811132310c3a8dc2da4f9975", + urls = ["https://github.com/ros2-rust/ros2_rust/archive/2e746d6e0d2cbeed811132310c3a8dc2da4f9975.zip"], +) + +# https://github.com/bazelbuild/rules_rust/pull/2698 +http_archive( + name = "com_github_mvukov_rules_ros2_cargo_bazel", + build_file_content = 'exports_files(["cargo-bazel"])', + sha256 = "6d6d68b898b38cb58d3c29e2e54d5795e2f652ebcac1ecf3bb0ac99fc86480e7", + url = "https://github.com/mvukov/rules_rust/releases/download/0.46.0-mvukov-cargo-bazel/cargo-bazel.zip", +) + _DEFAULT_PYTHON = "3.10" python = use_extension("@rules_python//python/extensions:python.bzl", "python") @@ -55,6 +79,13 @@ use_repo(dev_pip, "rules_ros2_resolver_deps") pybind_configure = use_extension("@pybind11_bazel//:internal_configure.bzl", "internal_configure_extension") use_repo(pybind_configure, "pybind11") +crate = use_extension("@rules_rust//crate_universe:extension.bzl", "crate") +crate.from_cargo( + name = "rules_ros2_crate_index", + cargo_lockfile = "@com_github_mvukov_rules_ros2//repositories/rust:Cargo.lock", +) +use_repo(crate, "rules_ros2_crate_index") + non_module_deps = use_extension("@com_github_mvukov_rules_ros2//:extensions.bzl", "non_module_deps") use_repo( non_module_deps, From 008616ad5203ec867671e9608212111e6c3f0a7f Mon Sep 17 00:00:00 2001 From: Laurenz Date: Fri, 3 Jan 2025 11:08:27 +0100 Subject: [PATCH 26/30] Update MODULE.bazel Co-authored-by: Kevin Greene --- MODULE.bazel | 1 + 1 file changed, 1 insertion(+) diff --git a/MODULE.bazel b/MODULE.bazel index 3612c534..72363aea 100644 --- a/MODULE.bazel +++ b/MODULE.bazel @@ -19,6 +19,7 @@ bazel_dep(name = "rules_python", version = "0.35.0") bazel_dep(name = "rules_rust", version = "0.49.3") bazel_dep(name = "spdlog", version = "1.14.1") bazel_dep(name = "sqlite3", version = "3.42.0.bcr.1") +bazel_dep(name = "tinyxml", version = "2.6.2") bazel_dep(name = "tinyxml2", version = "10.0.0") bazel_dep(name = "websocketpp", version = "0.8.2") bazel_dep(name = "yaml-cpp", version = "0.8.0") From 5fa543e1a7b19c77519964149b13c14a0d3995cf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Laurenz=20Altenm=C3=BCller?= Date: Fri, 10 Jan 2025 18:03:34 +0100 Subject: [PATCH 27/30] update things --- BUILD.bazel | 16 ---------------- MODULE.bazel | 29 ++++++++++------------------- examples/MODULE.bazel | 6 ++---- 3 files changed, 12 insertions(+), 39 deletions(-) diff --git a/BUILD.bazel b/BUILD.bazel index 3cc19865..ce3a90b9 100644 --- a/BUILD.bazel +++ b/BUILD.bazel @@ -1,5 +1,3 @@ -load("@rules_cc//cc:defs.bzl", "cc_library") -load("@rules_python//python:pip.bzl", "whl_filegroup") load("@rules_ros2_pythons//3.10:defs.bzl", "compile_pip_requirements") compile_pip_requirements( @@ -14,17 +12,3 @@ exports_files([ "requirements.txt", "requirements_lock.txt", ]) - -whl_filegroup( - name = "numpy_includes", - pattern = "numpy/core/include/numpy", - whl = "@rules_ros2_pip_deps//numpy:whl", -) - -cc_library( - name = "rules_ros2_pip_deps_numpy_headers", - hdrs = [":numpy_includes"], - includes = ["numpy_includes/numpy/core/include"], - visibility = ["//visibility:public"], - deps = ["@rules_python//python/cc:current_py_cc_headers"], -) diff --git a/MODULE.bazel b/MODULE.bazel index 72363aea..e0c6ed09 100644 --- a/MODULE.bazel +++ b/MODULE.bazel @@ -13,17 +13,18 @@ bazel_dep(name = "platforms", version = "0.0.10") bazel_dep(name = "pybind11_bazel", version = "2.12.0") bazel_dep(name = "re2", version = "2024-07-02") # this is only here to force graph to resolve to higher res2 version compatible with pybind11_bazel above. Remove once no longer needed. bazel_dep(name = "readerwriterqueue", version = "1.0.6") -bazel_dep(name = "rules_cc", version = "0.0.9") +bazel_dep(name = "rules_cc", version = "0.0.17") bazel_dep(name = "rules_foreign_cc", version = "0.11.1") bazel_dep(name = "rules_python", version = "0.35.0") -bazel_dep(name = "rules_rust", version = "0.49.3") +bazel_dep(name = "rules_rust", version = "0.56.0") +bazel_dep(name = "rules_rust_bindgen", version = "0.56.0") bazel_dep(name = "spdlog", version = "1.14.1") bazel_dep(name = "sqlite3", version = "3.42.0.bcr.1") bazel_dep(name = "tinyxml", version = "2.6.2") bazel_dep(name = "tinyxml2", version = "10.0.0") bazel_dep(name = "websocketpp", version = "0.8.2") bazel_dep(name = "yaml-cpp", version = "0.8.0") -bazel_dep(name = "zlib", version = "1.3") +bazel_dep(name = "zlib", version = "1.3.1.bcr.3") bazel_dep(name = "zstd", version = "1.5.6") bazel_dep(name = "googletest", version = "1.14.0.bcr.1", dev_dependency = True) @@ -35,21 +36,13 @@ http_archive( build_file = "@com_github_mvukov_rules_ros2//repositories:ros2_rust.BUILD.bazel", patch_args = ["-p1"], patches = [ - "@com_github_mvukov_rules_ros2//repositories/patches:ros2_rust_fix_rcl_bindings.patch", + "@com_github_mvukov_rules_ros2//repositories/patches:ros2_rust_fix_rclrs.patch", "@com_github_mvukov_rules_ros2//repositories/patches:ros2_rust_fix_rosidl_generator.patch", - "@com_github_mvukov_rules_ros2//repositories/patches:ros2_rust_no_msg_vendoring.patch", + "@com_github_mvukov_rules_ros2//repositories/patches:ros2_rust_fix_rosidl_runtime.patch", ], - sha256 = "ec3ebfb177f0ecfc2c6ecb47f2fffe701f6ebeb2b29ab482b57b53dd2c260da2", - strip_prefix = "ros2_rust-2e746d6e0d2cbeed811132310c3a8dc2da4f9975", - urls = ["https://github.com/ros2-rust/ros2_rust/archive/2e746d6e0d2cbeed811132310c3a8dc2da4f9975.zip"], -) - -# https://github.com/bazelbuild/rules_rust/pull/2698 -http_archive( - name = "com_github_mvukov_rules_ros2_cargo_bazel", - build_file_content = 'exports_files(["cargo-bazel"])', - sha256 = "6d6d68b898b38cb58d3c29e2e54d5795e2f652ebcac1ecf3bb0ac99fc86480e7", - url = "https://github.com/mvukov/rules_rust/releases/download/0.46.0-mvukov-cargo-bazel/cargo-bazel.zip", + sha256 = "6ef8722c2dde10e5c2fc1b9aef6ec3cc397f8cda40d58743045584aa59a6b0c8", + strip_prefix = "ros2_rust-9a845c17873cbdf49e8017d5f0af6d8f795589cc", + urls = ["https://github.com/ros2-rust/ros2_rust/archive/9a845c17873cbdf49e8017d5f0af6d8f795589cc.zip"], ) _DEFAULT_PYTHON = "3.10" @@ -83,7 +76,7 @@ use_repo(pybind_configure, "pybind11") crate = use_extension("@rules_rust//crate_universe:extension.bzl", "crate") crate.from_cargo( name = "rules_ros2_crate_index", - cargo_lockfile = "@com_github_mvukov_rules_ros2//repositories/rust:Cargo.lock", + cargo_lockfile = "repositories/rust/Cargo.lock", ) use_repo(crate, "rules_ros2_crate_index") @@ -95,7 +88,6 @@ use_repo( "iceoryx", "osrf_pycommon", "ros2", - "ros2_ament_cmake_ros", "ros2_ament_index", "ros2_class_loader", "ros2_common_interfaces", @@ -122,7 +114,6 @@ use_repo( "ros2_rmw_dds_common", "ros2_rmw_implementation", "ros2_robot_state_publisher", - "ros2_ros_testing", "ros2_rosbag2", "ros2_rosidl", "ros2_rosidl_python", diff --git a/examples/MODULE.bazel b/examples/MODULE.bazel index 1ae5aee6..a13f0596 100644 --- a/examples/MODULE.bazel +++ b/examples/MODULE.bazel @@ -13,7 +13,6 @@ use_repo( "foxglove_bridge", "iceoryx", "osrf_pycommon", - "ros2_ament_cmake_ros", "ros2_ament_index", "ros2_class_loader", "ros2_common_interfaces", @@ -40,7 +39,6 @@ use_repo( "ros2_rmw_dds_common", "ros2_rmw_implementation", "ros2_robot_state_publisher", - "ros2_ros_testing", "ros2_rosbag2", "ros2_rosidl", "ros2_rosidl_python", @@ -55,5 +53,5 @@ use_repo( "ros2cli", ) -bazel_dep(name = "rules_cc", version = "0.0.9") -bazel_dep(name = "rules_python", version = "0.33.2") +bazel_dep(name = "rules_cc", version = "0.0.17") +bazel_dep(name = "rules_python", version = "0.35.0") From 1449f69c44afdcbd4b7cc6991928d3cdb147b9c3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Laurenz=20Altenm=C3=BCller?= Date: Fri, 10 Jan 2025 18:17:22 +0100 Subject: [PATCH 28/30] missing asio ssl dep --- repositories/asio.BUILD.bazel | 3 +++ 1 file changed, 3 insertions(+) diff --git a/repositories/asio.BUILD.bazel b/repositories/asio.BUILD.bazel index 0170a735..56854d01 100644 --- a/repositories/asio.BUILD.bazel +++ b/repositories/asio.BUILD.bazel @@ -1,3 +1,5 @@ +# Same as https://github.com/bazelbuild/bazel-central-registry/blob/dcff901/modules/asio/1.31.0/overlay/BUILD.bazel + load("@rules_cc//cc:defs.bzl", "cc_library") cc_library( @@ -13,4 +15,5 @@ cc_library( includes = ["asio/include"], local_defines = ["ASIO_SEPARATE_COMPILATION"], visibility = ["//visibility:public"], + deps = ["@boringssl//:ssl"], ) From ab84bc5b66aaddf75b69fa85d4c9728f147f2d83 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Laurenz=20Altenm=C3=BCller?= Date: Fri, 10 Jan 2025 19:00:02 +0100 Subject: [PATCH 29/30] Fix rust cargo specs --- MODULE.bazel | 37 +++++++++++++++++++++++------ repositories/rust_setup_stage_3.bzl | 22 +++++------------ 2 files changed, 36 insertions(+), 23 deletions(-) diff --git a/MODULE.bazel b/MODULE.bazel index e0c6ed09..eda5abbd 100644 --- a/MODULE.bazel +++ b/MODULE.bazel @@ -33,12 +33,12 @@ http_archive = use_repo_rule("@bazel_tools//tools/build_defs/repo:http.bzl", "ht http_archive( name = "ros2_rust", - build_file = "@com_github_mvukov_rules_ros2//repositories:ros2_rust.BUILD.bazel", + build_file = "//repositories:ros2_rust.BUILD.bazel", patch_args = ["-p1"], patches = [ - "@com_github_mvukov_rules_ros2//repositories/patches:ros2_rust_fix_rclrs.patch", - "@com_github_mvukov_rules_ros2//repositories/patches:ros2_rust_fix_rosidl_generator.patch", - "@com_github_mvukov_rules_ros2//repositories/patches:ros2_rust_fix_rosidl_runtime.patch", + "//repositories/patches:ros2_rust_fix_rclrs.patch", + "//repositories/patches:ros2_rust_fix_rosidl_generator.patch", + "//repositories/patches:ros2_rust_fix_rosidl_runtime.patch", ], sha256 = "6ef8722c2dde10e5c2fc1b9aef6ec3cc397f8cda40d58743045584aa59a6b0c8", strip_prefix = "ros2_rust-9a845c17873cbdf49e8017d5f0af6d8f795589cc", @@ -73,14 +73,37 @@ use_repo(dev_pip, "rules_ros2_resolver_deps") pybind_configure = use_extension("@pybind11_bazel//:internal_configure.bzl", "internal_configure_extension") use_repo(pybind_configure, "pybind11") +# Keep specs in sync with repositories/rust_setup_stage_3.bzl crate = use_extension("@rules_rust//crate_universe:extension.bzl", "crate") -crate.from_cargo( +crate.spec( + package = "futures", + version = "0.3", +) +crate.spec( + features = ["derive"], + package = "serde", + version = "1", +) +crate.spec( + package = "serde-big-array", + version = "0.5", +) +crate.spec( + package = "serde_json", + version = "1", +) +crate.spec( + package = "signal-hook", + version = "0.3", +) +crate.from_specs( name = "rules_ros2_crate_index", - cargo_lockfile = "repositories/rust/Cargo.lock", + cargo_lockfile = "//repositories/rust:Cargo.lock", + lockfile = "//repositories/rust:Cargo.Bazel.lock", ) use_repo(crate, "rules_ros2_crate_index") -non_module_deps = use_extension("@com_github_mvukov_rules_ros2//:extensions.bzl", "non_module_deps") +non_module_deps = use_extension("//:extensions.bzl", "non_module_deps") use_repo( non_module_deps, "cyclonedds", diff --git a/repositories/rust_setup_stage_3.bzl b/repositories/rust_setup_stage_3.bzl index f2707ca0..caa17ac0 100644 --- a/repositories/rust_setup_stage_3.bzl +++ b/repositories/rust_setup_stage_3.bzl @@ -5,25 +5,15 @@ def rust_setup_stage_3(**kwargs): name = "rules_ros2_crate_index", cargo_lockfile = "@com_github_mvukov_rules_ros2//repositories/rust:Cargo.lock", lockfile = "@com_github_mvukov_rules_ros2//repositories/rust:Cargo.Bazel.lock", + # Keep specs in sync with MODULE.bazel packages = { - "futures": crate.spec( - version = "0.3", - ), - "serde": crate.spec( - features = ["derive"], - version = "1", - ), - "serde-big-array": crate.spec( - version = "0.5", - ), + "futures": crate.spec(version = "0.3"), + "serde": crate.spec(features = ["derive"], version = "1"), + "serde-big-array": crate.spec(version = "0.5"), # Not used by rclrs, used for testing. - "serde_json": crate.spec( - version = "1", - ), + "serde_json": crate.spec(version = "1"), # Not used by rclrs, but handy to have. - "signal-hook": crate.spec( - version = "0.3", - ), + "signal-hook": crate.spec(version = "0.3"), }, **kwargs ) From cbffd75d1aae1748be6a723d863908c9eb378d80 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Laurenz=20Altenm=C3=BCller?= Date: Fri, 10 Jan 2025 19:13:45 +0100 Subject: [PATCH 30/30] comment out too new attrs --- MODULE.bazel | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/MODULE.bazel b/MODULE.bazel index eda5abbd..f3cee767 100644 --- a/MODULE.bazel +++ b/MODULE.bazel @@ -98,8 +98,9 @@ crate.spec( ) crate.from_specs( name = "rules_ros2_crate_index", - cargo_lockfile = "//repositories/rust:Cargo.lock", - lockfile = "//repositories/rust:Cargo.Bazel.lock", + # Add these attrs when crate.from_specs supports them (rules_rust 0.57.0) + # cargo_lockfile = "//repositories/rust:Cargo.lock", + # lockfile = "//repositories/rust:Cargo.Bazel.lock", ) use_repo(crate, "rules_ros2_crate_index")