diff --git a/.bazelrc b/.bazelrc index 532306c2..d445ff0c 100644 --- a/.bazelrc +++ b/.bazelrc @@ -4,13 +4,9 @@ # 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 +# 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. @@ -43,8 +39,10 @@ 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 +# 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/main.yml b/.github/workflows/main.yml index e05f15fa..c812c8f8 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,18 @@ jobs: path: | ~/.cache/bazel ~/.cache/bazel-repo - key: v4-bazel-repo-cache-${{ matrix.toolchain }}-${{ hashFiles('.bazelversion', 'examples/WORKSPACE', 'repositories/**', 'requirements_lock.txt', 'WORKSPACE') }} - restore-keys: v4-bazel-repo-cache-${{ matrix.toolchain }}- - - name: bazel test ${{ matrix.config_option }} //... + key: >- + v5-bazel-repo-cache-${{ matrix.external_dependency_system }}-${{ matrix.toolchain }} + -${{ hashFiles('.bazelversion', '**/WORKSPACE', '**/MODULE.bazel', 'repositories/**/*.bzl', 'requirements_lock.txt') }} + restore-keys: v5-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: /github/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/.gitignore b/.gitignore index 19a7d87c..f670dedf 100644 --- a/.gitignore +++ b/.gitignore @@ -2,4 +2,5 @@ bazel-* __pycache__ user.bazelrc +external/ MODULE.bazel* diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 9ded763b..5bdec7ba 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/BUILD.bazel b/BUILD.bazel index a89ad7df..ce3a90b9 100644 --- a/BUILD.bazel +++ b/BUILD.bazel @@ -1,4 +1,4 @@ -load("@rules_python//python:pip.bzl", "compile_pip_requirements") +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 new file mode 100644 index 00000000..f3cee767 --- /dev/null +++ b/MODULE.bazel @@ -0,0 +1,153 @@ +module(name = "com_github_mvukov_rules_ros2") + +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.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.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.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.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.1.bcr.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 = "//repositories:ros2_rust.BUILD.bazel", + patch_args = ["-p1"], + patches = [ + "//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", + urls = ["https://github.com/ros2-rust/ros2_rust/archive/9a845c17873cbdf49e8017d5f0af6d8f795589cc.zip"], +) + +_DEFAULT_PYTHON = "3.10" + +python = use_extension("@rules_python//python/extensions:python.bzl", "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") +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) +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") + +# Keep specs in sync with repositories/rust_setup_stage_3.bzl +crate = use_extension("@rules_rust//crate_universe:extension.bzl", "crate") +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", + # 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") + +non_module_deps = use_extension("//:extensions.bzl", "non_module_deps") +use_repo( + non_module_deps, + "cyclonedds", + "foxglove_bridge", + "iceoryx", + "osrf_pycommon", + "ros2", + "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_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", +) diff --git a/WORKSPACE b/WORKSPACE index 397f8224..0530c33d 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") pip_parse( name = "rules_ros2_pip_deps", 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..a13f0596 --- /dev/null +++ b/examples/MODULE.bazel @@ -0,0 +1,57 @@ +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_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_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.17") +bazel_dep(name = "rules_python", version = "0.35.0") diff --git a/examples/WORKSPACE b/examples/WORKSPACE index cff546cb..8a2c5dd5 100644 --- a/examples/WORKSPACE +++ b/examples/WORKSPACE @@ -26,17 +26,18 @@ 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("@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/extensions.bzl b/extensions.bzl new file mode 100644 index 00000000..4466f393 --- /dev/null +++ b/extensions.bzl @@ -0,0 +1,8 @@ +load("@com_github_mvukov_rules_ros2//repositories:repositories.bzl", "ros2_repositories") + +def _non_module_deps_impl(mctx): + ros2_repositories() + +non_module_deps = module_extension( + implementation = _non_module_deps_impl, +) 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/asio.BUILD.bazel b/repositories/asio.BUILD.bazel index 090476e7..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( diff --git a/repositories/foxglove_bridge.BUILD.bazel b/repositories/foxglove_bridge.BUILD.bazel index cf20f3e2..ca9face1 100644 --- a/repositories/foxglove_bridge.BUILD.bazel +++ b/repositories/foxglove_bridge.BUILD.bazel @@ -25,6 +25,7 @@ cc_library( copts = ["-std=c++17"], includes = ["foxglove_bridge_base/include"], deps = [ + "@boringssl//:ssl", "@nlohmann_json//:json", "@websocketpp", ], 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/repositories.bzl b/repositories/repositories.bzl index 59ee3ed8..a60e4c51 100644 --- a/repositories/repositories.bzl +++ b/repositories/repositories.bzl @@ -32,9 +32,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( @@ -155,12 +155,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( @@ -197,18 +194,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/repositories/rosidl.BUILD.bazel b/repositories/rosidl.BUILD.bazel index 83abf434..50eaf768 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/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 ) 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 94ef6863..05e89afe 100644 --- a/ros2/BUILD.bazel +++ b/ros2/BUILD.bazel @@ -3,8 +3,9 @@ load("@bazel_skylib//rules:common_settings.bzl", "string_flag") load("@rules_cc//cc:defs.bzl", "cc_library") -load("@rules_python//python:defs.bzl", "py_binary", "py_library") +load("@rules_python//python:defs.bzl", "py_library") load("@rules_python//python:pip.bzl", "whl_filegroup") +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/plugin_aspects.bzl b/ros2/plugin_aspects.bzl index e29f2795..f807c2f7 100644 --- a/ros2/plugin_aspects.bzl +++ b/ros2/plugin_aspects.bzl @@ -38,15 +38,16 @@ 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 + candidate = getattr(rule_attr, attr_name, []) + if type(candidate) == type([]): + return candidate + return [candidate] def _collect_deps(rule_attr, attr_name, provider_info): return [ diff --git a/ros2/py_defs.bzl b/ros2/py_defs.bzl index f6fc97c7..3ee2f473 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): is_test = target == py_test 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 538e1cbd..3acb261e 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. 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",