├── .bazelrc ├── .bazelversion ├── .github └── workflows │ └── build_test.yml ├── .gitignore ├── BUILD.bazel ├── LICENSE ├── README.md ├── WORKSPACE ├── examples ├── BUILD.bazel ├── bazel_simple_example │ ├── BUILD │ ├── publisher.cpp │ └── subscriber.cpp └── hello_world │ ├── BUILD.bazel │ └── main.cpp ├── pkg ├── BUILD ├── defs.bzl ├── detail │ ├── BUILD │ ├── executable_wrapper_generator.py │ ├── package_xml_generator.py │ ├── ros_archive.bzl │ ├── ros_pkg.bzl │ ├── setup_bash_generator.py │ ├── templates │ │ └── install.template │ └── utils.bzl └── providers.bzl ├── repos ├── BUILD.bazel ├── ament.ament_index │ ├── ament_index_cpp.BUILD │ └── ament_index_python.BUILD ├── config │ ├── BUILD.bazel │ ├── bazel.repos │ ├── defs.bzl │ ├── detail │ │ ├── BUILD.bazel │ │ ├── generate_repos_lock.bzl │ │ ├── generate_ros2_config.py │ │ ├── git_repository.bzl │ │ ├── http_archive.bzl │ │ ├── lock_repos.py │ │ ├── new_local_repository.bzl │ │ ├── ros2_config.bzl │ │ └── test │ │ │ └── test_repos_index_sha256.sh │ ├── distros.bzl │ ├── setup_dashing.lock.bzl │ ├── setup_eloquent.lock.bzl │ ├── setup_foxy.lock.bzl │ ├── setup_humble.lock.bzl │ └── setup_iron.lock.bzl ├── default.BUILD ├── ros-tooling.libstatistics_collector │ └── root.BUILD ├── ros2.common_interfaces │ └── std_msgs.BUILD ├── ros2.rcl │ ├── rcl.BUILD │ └── rcl_yaml_param_parser.BUILD ├── ros2.rcl_interfaces │ ├── builtin_interfaces.BUILD │ ├── rcl_interfaces.BUILD │ ├── rosgraph_msgs.BUILD │ └── statistics_msgs.BUILD ├── ros2.rcl_logging │ └── rcl_logging_interface.BUILD ├── ros2.rclcpp │ ├── build_interfaces.py │ └── rclcpp.BUILD ├── ros2.rcpputils │ └── rcpputils.BUILD ├── ros2.rcutils │ ├── build_logging_macros.py │ └── root.BUILD ├── ros2.rmw │ └── rmw.BUILD ├── ros2.ros2_tracing │ └── tracetools.BUILD ├── ros2.ros2cli │ ├── ros2cli.BUILD │ ├── ros2pkg.BUILD │ └── ros2run.BUILD ├── ros2.rosidl │ ├── rosidl_adapter.BUILD │ ├── rosidl_cli.BUILD │ ├── rosidl_cmake.BUILD │ ├── rosidl_generator_c.BUILD │ ├── rosidl_generator_cpp.BUILD │ ├── rosidl_parser.BUILD │ ├── rosidl_runtime_c.BUILD │ ├── rosidl_runtime_cpp.BUILD │ └── rosidl_typesupport_interface.BUILD ├── ros2.rosidl_dds │ └── rosidl_generator_dds_idl.BUILD └── ros2.rosidl_typesupport │ └── rosidl_typesupport_c.BUILD ├── rosidl ├── BUILD.bazel ├── defs.bzl ├── detail │ ├── cc_library_with_hdrs_extracted_from_srcs.bzl │ ├── cc_library_with_msgs_provider.bzl │ ├── common_config.bzl │ ├── misc_support.bzl │ ├── rosidl_adapter.bzl │ ├── rosidl_generator_c.bzl │ ├── rosidl_generator_cpp.bzl │ ├── rosidl_generator_dds_idl.bzl │ ├── rosidl_typesupport_c.bzl │ └── visiability_control.bzl └── providers.bzl ├── thirdparty ├── BUILD.bazel ├── bazel_skylib │ ├── BUILD │ ├── repositories.bzl │ └── setup.bzl ├── libyaml │ ├── BUILD.bazel │ ├── libyaml.BUILD.bazel │ └── repositories.bzl ├── python │ ├── BUILD.bazel │ ├── install_deps.bzl │ ├── pip_parse.bzl │ ├── repositories.bzl │ ├── requirements_lock.in │ ├── requirements_lock.txt │ └── setup_toolchain.bzl ├── rules_pkg │ ├── BUILD │ ├── repositories.bzl │ └── setup.bzl ├── setup_01.bzl ├── setup_02.bzl ├── setup_03.bzl └── setup_04.bzl └── utils ├── BUILD.bazel └── template_expansion.bzl /.bazelrc: -------------------------------------------------------------------------------- 1 | # enable incompatible python init mode 2 | build --incompatible_default_to_explicit_init_py 3 | 4 | # enable implementation_deps on cc_library targets 5 | build --experimental_cc_implementation_deps 6 | 7 | # set c++17 for all builds 8 | build --cxxopt="-std=c++17" 9 | build --host_cxxopt="-std=c++17" 10 | 11 | # try to import a user-specific bazelrc (gitignored) 12 | try-import %workspace%/user.bazelrc 13 | -------------------------------------------------------------------------------- /.bazelversion: -------------------------------------------------------------------------------- 1 | 6.5.0 -------------------------------------------------------------------------------- /.github/workflows/build_test.yml: -------------------------------------------------------------------------------- 1 | name: Build/Test 2 | 3 | on: 4 | push: 5 | branches: 6 | - main 7 | tags: 8 | - "**" 9 | pull_request: 10 | branches: 11 | - main 12 | workflow_dispatch: 13 | 14 | # only run one build doc workflow at a time, cancel any running ones 15 | concurrency: 16 | group: ${{ github.workflow }}-${{ github.ref }} 17 | cancel-in-progress: true 18 | 19 | jobs: 20 | build_test: 21 | strategy: 22 | matrix: 23 | os: 24 | - ubuntu 25 | version: 26 | - 22.04 27 | runs-on: ${{ matrix.os }}-${{ matrix.version }} 28 | steps: 29 | - uses: actions/checkout@v3 30 | - name: Specify the Bazel cache 31 | uses: actions/cache@v3 32 | with: 33 | path: "/home/runner/.cache/bazel" 34 | key: ${{ hashFiles('.bazelrc', '.bazelversion', 'WORKSPACE', 'WORKSPACE.bazel', 'MODULE.bazel') }} 35 | - name: Install buildifier 36 | run: | 37 | curl -f -s -L -o /usr/local/bin/buildifier https://github.com/bazelbuild/buildtools/releases/download/v7.3.1/buildifier-linux-$(arch | sed 's/aarch64/arm64/;s/x86_64/amd64/') 38 | chmod a+x /usr/local/bin/buildifier 39 | - name: Run buildifier 40 | run: buildifier -mode check -r . 41 | - name: Build 42 | # TODO(evan.flynn): uncomment once the rules are properly fixed 43 | # run: bazel build //... 44 | run: bazel build --keep_going -- $(cat repos/config/bazel.repos | sed -e '/^[#r]/d' -e '/^ /d' -e 's%/%.%' -e 's% \(.*\):%@\1//...%' -e '/@ros2.rosidl/d' -e '/@ros2.rcl_interfaces/d' -e '/@ros2.common_interfaces/d') 45 | - name: Test 46 | run: bazel test --keep_going -- //repos/config/detail/... //thirdparty/... $(cat repos/config/bazel.repos | sed -e '/^[#r]/d' -e '/^ /d' -e 's%/%.%' -e 's% \(.*\):%@\1//...%' -e '/@ros2.rosidl/d' -e '/@ros2.rcl_interfaces/d' -e '/@ros2.common_interfaces/d') 47 | - name: Store the bazel-testlogs 48 | uses: actions/upload-artifact@v4 49 | if: always() 50 | with: 51 | name: ${{ matrix.os }}-${{ matrix.version }}-bazel-testlogs 52 | path: bazel-testlogs 53 | retention-days: 5 54 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .clwb/* 2 | bazel-* 3 | 4 | # Python caches 5 | /**/__pycache__/ 6 | -------------------------------------------------------------------------------- /BUILD.bazel: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ApexAI/rules_ros/5d2d81bc7779cbdada626be299354a3b5544ba2f/BUILD.bazel -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # ROS 2 Rules for Bazel 2 | 3 | ## Overview 4 | 5 | This repository contains all the setup, rules and build configuration to use 6 | [Bazel](http://bazel.build) with ROS 2. As recommended by Bazel, all ROS 2 packages 7 | are built from source. They are loaded as needed, so no a priori loading or manual version 8 | management of ROS 2 repos (e.g., via vcs tool) is required. 9 | 10 | The neccessary BUILD files for ROS 2 repos are injected while loading. In case Bazel gains 11 | some traction within the ROS community, Bazel BUILD files should ideally be provided 12 | directly by the ROS 2 repositories. 13 | 14 | Specific rules for message generation and packaging are provided in this repository (see 15 | [rosidl/defs.bzl](rosidl/defs.bzl) and [pkg/defs.bzl](pkg/defs.bzl)). 16 | 17 | ## ! Current Restrictions ! 18 | 19 | This is still work in progress. Some essential parts are not complete yet. 20 | Here is a short list of major restrictions: 21 | * Only tested on Ubunut 20.04 Linux (x86_64). Other Linux distributions may work. Windows 22 | will not be supported in the foreseeable future. 23 | * Only ROS 2 Humble is supported. Other distros may work after extending 24 | `@rules_ros//repos/config/defs.bzl` accordingly. 25 | * Message generation is still incomplete. Therefore even the simplest examples will not run 26 | due to not yet bazelized middleware. 27 | * Not all packages have been bazelized yet. Main focus currently lies on generating an 28 | install space and providing message generation support. Out of all the ROS 2 CLI commands, 29 | (`ros2cli`), only the `run` command is currently bazelized. 30 | * The streamlined integration of custom packages into the repo setup is not yet available. 31 | Same applies to adding additional Python packages. 32 | This will be added soon. 33 | 34 | ## Getting started 35 | 36 | ### Prerequisites 37 | 38 | Bazel needs to be available. It is recommended to use [bazelisk](https://github.com/bazelbuild/bazelisk) 39 | as the launch tool for Bazel. 40 | 41 | ### Workspace setup 42 | 43 | Create an empty folder and add the following files to it: 44 | * `WORKSPACE` file: 45 | 46 | ```python 47 | workspace(name = "my_first_bazel_ros_workspace") # choose a workspace name here 48 | # load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") 49 | load("@bazel_tools//tools/build_defs/repo:git.bzl", "git_repository") 50 | 51 | RULES_ROS_VERSION = "xxx" # TODO: where to find the right version 52 | RUIES_ROS_SHA = "xxx" 53 | 54 | # until there is an initial release, use the following: 55 | git_repository( 56 | name = "rules_ros", 57 | remote = "https://github.com/ApexAI/rules_ros.git", 58 | branch = "main", 59 | ) 60 | 61 | # after the first release, switch to this dependency 62 | #https_archive( 63 | # name = "rules_ros", 64 | # sha256 = RULES_ROS_SHA, 65 | # strip_prefix = "xxx", 66 | # url = "https://github.com/ApexAI/rules_ros/archive/{}.zip".format(RULES_ROS_VERSION), 67 | #) 68 | 69 | load("@rules_ros//repos/config:defs.bzl", "configure_ros2") 70 | configure_ros2(distro = "humble") # currently only Humble is supported 71 | 72 | load("@ros2_config//:setup.bzl", "setup") 73 | setup() 74 | 75 | load("@rules_ros//thirdparty:setup_01.bzl", "setup_01") 76 | setup_01() 77 | 78 | load("@rules_ros//thirdparty:setup_02.bzl", "setup_02") 79 | setup_02() 80 | 81 | load("@rules_ros//thirdparty:setup_03.bzl", "setup_03") 82 | setup_03() 83 | 84 | load("@rules_ros//thirdparty:setup_04.bzl", "setup_04") 85 | setup_04() 86 | ``` 87 | 88 | * `.bazelrc` file: 89 | 90 | ```shell 91 | # enable incompatible Python init mode 92 | build --incompatible_default_to_explicit_init_py 93 | 94 | # enable implementation_deps on cc_library targets 95 | build --experimental_cc_implementation_deps 96 | 97 | # set C++17 for all builds 98 | build --cxxopt="-std=c++17" 99 | build --host_cxxopt="-std=c++17" 100 | ``` 101 | 102 | * `.bazelversion` file (if `bazelisk` is being used): 103 | 104 | ```text 105 | 6.5.0 106 | ``` 107 | 108 | ### Run Bazel example 109 | 110 | To **build** an example delivered in the `rules_ros` repository run, e.g. 111 | 112 | ```shell 113 | bazel build @rules_ros//examples/hello_world 114 | ``` 115 | 116 | from anywhere within the workspace. 117 | 118 | **Executing** the example can be done by calling 119 | 120 | ```shell 121 | bazel run @rules_ros//examples/hello_world 122 | ``` 123 | Note that no sourcing is necessary. Bazel will take care of all the dependencies. 124 | 125 | **Deploying** a package archive to an install folder can be done by 126 | 127 | ```shell 128 | bazel run @rules_ros//examples:rules_ros_examples.install 129 | ``` 130 | 131 | Now the environment is ready to work with ROS as usual. Source the package as usual with: 132 | 133 | ```shell 134 | source /setup.bash 135 | ``` 136 | 137 | and run an executable with 138 | 139 | ```shell 140 | ros2 run hello_world hello_world 141 | ``` 142 | 143 | ## Features 144 | 145 | ### Python Interpreter 146 | 147 | In this setup, a hermetic Python interpreter is included. The version is specified in 148 | `thirdparty/python/repositories.bzl`. Python packages specified in 149 | `thirdparty/python/requirements_lock.in` are available for use. If a package needs to be added, run 150 | 151 | ```shell 152 | bazel run @rules_ros//thirdparty/python:requirements_lock.update 153 | ``` 154 | 155 | to pin specific versions of the dependencies. In the future there will be a possibility to 156 | inject a customization in the WORKSPACE file. 157 | 158 | ### ROS 2 Repositories 159 | 160 | ROS 2 repositories are made available as external dependencies with the name specified in 161 | the `ros2.repos` file known from the original ROS 2 repository, e.g., the `ros2/rclcpp` repo 162 | will be available as `@ros2.rclcpp` with all targets specified in the BUILD files in 163 | `repos/config/ros2.rclcpp.BUILD`. The precise location where the build files will be injected 164 | into the `rclcpp` repo is specified in the index file `repos/config/bazel.repos`. 165 | 166 | Therefore, if there is a dependency on `rclcpp`, `"@ros2.rclcpp//rclcpp"` needs to be added 167 | as a dependency in the `cc_binary` or `cc_library` target. 168 | 169 | The exact version of a ROS 2 repository is pinned in the file `repos/config/ros2_.lock`. 170 | This file can be updated for the configured distro by running: 171 | 172 | ```shell 173 | bazel run @rules_ros//repos/config:repos_lock.update 174 | ``` 175 | 176 | In the future there will be a possibility to inject any customization in the WORKSPACE file. 177 | 178 | ## Adding more ROS2 repositories using custom `.repos` file 179 | 180 | To use `rules_ros` in a workspace with a custom `.repos` file, follow these steps: 181 | 182 | 1. Create your custom `.repos` file with the desired ROS 2 repositories in your workspace. 183 | 2. Update the `WORKSPACE` file to use the `configure_repos` rule with the custom `.repos` file: 184 | 185 | ```python 186 | load("@rules_ros//repos/config:defs.bzl", "configure_repos") 187 | configure_repos( 188 | name = "", # Required 189 | repos_index = "", # Required 190 | setup_file = "", # Required 191 | repos_index_overlays = [ 192 | "", 193 | "" 194 | ] # Optional 195 | ) 196 | ``` 197 | 198 | #### A few things to note: 199 | 200 | a. The `setup_file` needs to have the following content: 201 | 202 | ```python 203 | load("@bazel_tools//tools/build_defs/repo:utils.bzl", _maybe = "maybe") 204 | load("@rules_ros//repos/config/detail:git_repository.bzl", "git_repository") 205 | load("@rules_ros//repos/config/detail:http_archive.bzl", "http_archive") 206 | load("@rules_ros//repos/config/detail:new_local_repository.bzl", "new_local_repository") 207 | 208 | def setup(): 209 | pass 210 | ``` 211 | 212 | b. The `repos_index_overlays` field is optional and can be used to pass additional `*.repos` files declaring BUILD.bazel files to be injected into the ROS2 repositories. 213 | 214 | 3. Generate the `setup.bzl` file by running the `repos_lock.update` command: 215 | 216 | ```shell 217 | bazel run @//:repos_lock.update 218 | ``` 219 | 4. Load the `setup.bzl` 220 | 221 | ```shell 222 | 223 | load("@//:setup.bzl", "setup") 224 | setup() 225 | 226 | ``` 227 | This will configure your workspace to use the specified additonal ROS2 repositories. 228 | -------------------------------------------------------------------------------- /WORKSPACE: -------------------------------------------------------------------------------- 1 | # Copyright 2024 Apex.AI, Inc. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | workspace(name = "rules_ros") 16 | 17 | load("//repos/config:defs.bzl", "configure_ros2") 18 | 19 | configure_ros2(distro = "humble") 20 | 21 | load("@ros2_config//:setup.bzl", "setup") 22 | 23 | setup() 24 | 25 | load("@rules_ros//thirdparty:setup_01.bzl", "setup_01") 26 | 27 | setup_01() 28 | 29 | load("@rules_ros//thirdparty:setup_02.bzl", "setup_02") 30 | 31 | setup_02() 32 | 33 | load("@rules_ros//thirdparty:setup_03.bzl", "setup_03") 34 | 35 | setup_03() 36 | 37 | load("@rules_ros//thirdparty:setup_04.bzl", "setup_04") 38 | 39 | setup_04() 40 | -------------------------------------------------------------------------------- /examples/BUILD.bazel: -------------------------------------------------------------------------------- 1 | # Copyright 2024 Apex.AI, Inc. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | load("@rules_ros//pkg:defs.bzl", "ros_archive", "ros_pkg_set") 15 | 16 | ros_pkg_set( 17 | name = "rules_ros_examples_pkgs", 18 | deps = [ 19 | "//examples/hello_world:hello_world_pkg", 20 | "@ros2.ros2cli//ros2cli", 21 | ], 22 | ) 23 | 24 | ros_archive( 25 | name = "rules_ros_examples", 26 | ros_pkgs = [":rules_ros_examples_pkgs"], 27 | ) 28 | -------------------------------------------------------------------------------- /examples/bazel_simple_example/BUILD: -------------------------------------------------------------------------------- 1 | # Copyright 2024 Apex.AI, Inc. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | load("@rules_ros//pkg:defs.bzl", "ros_pkg") 15 | 16 | cc_binary( 17 | name = "publisher", 18 | srcs = ["publisher.cpp"], 19 | deps = [ 20 | "@ros2.common_interfaces//std_msgs", 21 | "@ros2.rclcpp//rclcpp", 22 | ], 23 | ) 24 | 25 | cc_binary( 26 | name = "subscriber", 27 | srcs = ["subscriber.cpp"], 28 | deps = [ 29 | "@ros2.common_interfaces//std_msgs", 30 | "@ros2.rclcpp//rclcpp", 31 | ], 32 | ) 33 | 34 | ros_pkg( 35 | name = "bazel_simple_example_pkg", 36 | description = "Simple pub/sub example", 37 | lib_executables = [ 38 | "publisher", 39 | "subscriber", 40 | ], 41 | license = "Apex.AI License", 42 | maintainer_email = "kilian.funk@apex.ai", 43 | maintainer_name = "Kilian Funk", 44 | pkg_name = "bazel_simple_example", 45 | version = "1.0.0", 46 | visibility = ["//visibility:public"], 47 | ) 48 | -------------------------------------------------------------------------------- /examples/bazel_simple_example/publisher.cpp: -------------------------------------------------------------------------------- 1 | // Copyright 2024 Apex.AI, Inc. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | #include 16 | #include 17 | 18 | #include 19 | 20 | #include 21 | #include 22 | #include 23 | #include 24 | 25 | #include "rclcpp/rclcpp.hpp" 26 | #include "std_msgs/msg/string.hpp" 27 | 28 | using namespace std::chrono_literals; 29 | 30 | /* This example creates a subclass of Node and uses std::bind() to register a 31 | * member function as a callback from the timer. */ 32 | 33 | class MinimalPublisher : public rclcpp::Node { 34 | public: 35 | MinimalPublisher() : Node("minimal_publisher"), count_(0) { 36 | publisher_ = this->create_publisher("topic", 10); 37 | timer_ = this->create_wall_timer( 38 | 500ms, std::bind(&MinimalPublisher::timer_callback, this)); 39 | } 40 | 41 | private: 42 | void timer_callback() { 43 | auto message = std_msgs::msg::String(); 44 | message.data = "Hello, world! " + std::to_string(count_++); 45 | RCLCPP_INFO(this->get_logger(), "Publishing: '%s'", message.data.c_str()); 46 | publisher_->publish(message); 47 | } 48 | rclcpp::TimerBase::SharedPtr timer_; 49 | rclcpp::Publisher::SharedPtr publisher_; 50 | size_t count_; 51 | }; 52 | 53 | int main(int argc, char *argv[]) { 54 | rclcpp::init(argc, argv); 55 | rclcpp::spin(std::make_shared()); 56 | rclcpp::shutdown(); 57 | return 0; 58 | } 59 | -------------------------------------------------------------------------------- /examples/bazel_simple_example/subscriber.cpp: -------------------------------------------------------------------------------- 1 | // Copyright 2024 Apex.AI, Inc. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | #include 16 | 17 | #include "rclcpp/rclcpp.hpp" 18 | #include "std_msgs/msg/string.hpp" 19 | using std::placeholders::_1; 20 | 21 | class MinimalSubscriber : public rclcpp::Node { 22 | public: 23 | MinimalSubscriber() : Node("minimal_subscriber") { 24 | subscription_ = this->create_subscription( 25 | "topic", 10, std::bind(&MinimalSubscriber::topic_callback, this, _1)); 26 | } 27 | 28 | private: 29 | void topic_callback(const std_msgs::msg::String::SharedPtr msg) const { 30 | RCLCPP_INFO(this->get_logger(), "I heard: '%s'", msg->data.c_str()); 31 | } 32 | rclcpp::Subscription::SharedPtr subscription_; 33 | }; 34 | 35 | int main(int argc, char *argv[]) { 36 | rclcpp::init(argc, argv); 37 | rclcpp::spin(std::make_shared()); 38 | rclcpp::shutdown(); 39 | return 0; 40 | } 41 | -------------------------------------------------------------------------------- /examples/hello_world/BUILD.bazel: -------------------------------------------------------------------------------- 1 | # Copyright 2024 Apex.AI, Inc. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | load("@rules_ros//pkg:defs.bzl", "ros_pkg") 16 | 17 | cc_binary( 18 | name = "hello_world", 19 | srcs = ["main.cpp"], 20 | ) 21 | 22 | ros_pkg( 23 | name = "hello_world_pkg", 24 | description = "A simple hello world application.", 25 | lib_executables = [":hello_world"], 26 | license = "Apache 2.0", 27 | maintainer_email = "kilian.funk@apex.ai", 28 | maintainer_name = "Kilian Funk", 29 | pkg_name = "hello_world", 30 | version = "1.0.0", 31 | visibility = ["//visibility:public"], 32 | ) 33 | -------------------------------------------------------------------------------- /examples/hello_world/main.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main() { 4 | std::cout << "Hello world!" << std::endl; 5 | } 6 | -------------------------------------------------------------------------------- /pkg/BUILD: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ApexAI/rules_ros/5d2d81bc7779cbdada626be299354a3b5544ba2f/pkg/BUILD -------------------------------------------------------------------------------- /pkg/defs.bzl: -------------------------------------------------------------------------------- 1 | # Copyright 2024 Apex.AI, Inc. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | load("@rules_pkg//pkg:tar.bzl", _pkg_tar = "pkg_tar") 16 | load( 17 | "@rules_ros//pkg/detail:ros_archive.bzl", 18 | _ros_archive_install_command = "ros_archive_install_command", 19 | _ros_archive_pkg_files = "ros_archive_pkg_files", 20 | ) 21 | load( 22 | "@rules_ros//pkg/detail:ros_pkg.bzl", 23 | _ros_pkg = "ros_pkg", 24 | _ros_pkg_set = "ros_pkg_set", 25 | ) 26 | 27 | ros_pkg = _ros_pkg 28 | ros_pkg_set = _ros_pkg_set 29 | 30 | def ros_archive(*, name, ros_pkgs, **kwargs): 31 | """ Creates a ros install package 32 | 33 | A tar archive is created 34 | 35 | Keyword arguments: 36 | name -- target name 37 | deps -- label list of ros_pkg targets 38 | """ 39 | _ros_archive_pkg_files( 40 | name = "_{name}_pkg_files".format(name = name), 41 | ros_pkgs = ros_pkgs, 42 | ) 43 | _pkg_tar( 44 | name = name, 45 | package_dir = name, 46 | srcs = [":_{name}_pkg_files".format(name = name)], 47 | **kwargs 48 | ) 49 | _ros_archive_install_command( 50 | name = "{name}.install".format(name = name), 51 | pkg_archive = ":{name}".format(name = name), 52 | group_name = name, 53 | ) 54 | -------------------------------------------------------------------------------- /pkg/detail/BUILD: -------------------------------------------------------------------------------- 1 | # Copyright 2024 Apex.AI, Inc. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | load("@python_deps//:requirements.bzl", "requirement") 16 | load("@rules_python//python:defs.bzl", "py_binary") 17 | 18 | exports_files(["templates/install.template"]) 19 | 20 | py_binary( 21 | name = "package_xml.generate", 22 | srcs = ["package_xml_generator.py"], 23 | main = "package_xml_generator.py", 24 | visibility = ["//visibility:public"], 25 | deps = [ 26 | requirement("jinja2"), 27 | ], 28 | ) 29 | 30 | py_binary( 31 | name = "executable_wrapper.generate", 32 | srcs = ["executable_wrapper_generator.py"], 33 | main = "executable_wrapper_generator.py", 34 | visibility = ["//visibility:public"], 35 | ) 36 | 37 | py_binary( 38 | name = "setup_bash.generate", 39 | srcs = ["setup_bash_generator.py"], 40 | main = "setup_bash_generator.py", 41 | visibility = ["//visibility:public"], 42 | ) 43 | -------------------------------------------------------------------------------- /pkg/detail/executable_wrapper_generator.py: -------------------------------------------------------------------------------- 1 | # Copyright 2024 Apex.AI, Inc. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | import argparse 16 | 17 | TEMPLATE = """#!/bin/bash 18 | SCRIPT_DIR=$( cd -- "$( dirname -- "${{BASH_SOURCE[0]}}" )" &> /dev/null && pwd ) 19 | 20 | cd $SCRIPT_DIR/{relative_resource_path} 21 | {executable_path} $@ 22 | """ 23 | 24 | 25 | def main(): 26 | parser = argparse.ArgumentParser(description="Generate a wrapper for an executable.") 27 | parser.add_argument('output_path', type=str, help='Output path.') 28 | parser.add_argument('executable_path', type=str, help='Executable path.') 29 | parser.add_argument('relative_resource_path', type=str, help='Relative path to resource folder.') 30 | 31 | args = parser.parse_args() 32 | 33 | with open(args.output_path, "w") as out_file: 34 | out_file.write(TEMPLATE.format( 35 | executable_path = args.executable_path, 36 | relative_resource_path=args.relative_resource_path, 37 | )) 38 | 39 | 40 | if __name__ == "__main__": 41 | main() 42 | -------------------------------------------------------------------------------- /pkg/detail/package_xml_generator.py: -------------------------------------------------------------------------------- 1 | # Copyright 2024 Apex.AI, Inc. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | import argparse 16 | from jinja2 import Environment 17 | 18 | TEMPLATE = """ 19 | 20 | 21 | 22 | {{pkg_name}} 23 | {{version}} 24 | {{description}} 25 | 26 | {{maintainter_name}} 27 | {{license}} 28 | 29 | """ 30 | 31 | 32 | def main(): 33 | parser = argparse.ArgumentParser(description="Generate `package.xml` for a ros package.") 34 | parser.add_argument('output_path', type=str, help='Output path.') 35 | parser.add_argument("--pkg_name", type=str, help="Name of the ros package.") 36 | parser.add_argument("--version", type=str, help="Version of the ros package.") 37 | parser.add_argument("--maintainer_email", type=str, help="Email address of package maintainer.") 38 | parser.add_argument("--maintainer_name", type=str, help="Name of package maintainer.") 39 | parser.add_argument("--license", type=str, help="License of package.") 40 | parser.add_argument("--description", type=str, help="Description of ros package.") 41 | 42 | args = parser.parse_args() 43 | 44 | env = Environment() 45 | template = env.from_string(TEMPLATE) 46 | 47 | with open(args.output_path, "w") as out_file: 48 | out_file.write(template.render(args.__dict__)) 49 | 50 | 51 | if __name__ == "__main__": 52 | main() 53 | -------------------------------------------------------------------------------- /pkg/detail/ros_archive.bzl: -------------------------------------------------------------------------------- 1 | # Copyright 2024 Apex.AI, Inc. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | load("@rules_pkg//pkg:providers.bzl", "PackageFilegroupInfo", "PackageFilesInfo") 16 | load("@rules_ros//pkg:providers.bzl", _RosPkgInfo = "RosPkgInfo") 17 | load( 18 | ":utils.bzl", 19 | _add_filegroup = "add_filegroup", 20 | _add_files_to_filegroup_info = "add_files_to_filegroup_info", 21 | _build_attributes = "build_attributes", 22 | _create_ros_pkg_set_info = "create_ros_pkg_set_info", 23 | _unique_pkg_names_or_fail = "unique_pkg_names_or_fail", 24 | ) 25 | 26 | def _build_setup_bash(ctx): 27 | output = ctx.actions.declare_file("/".join([ctx.label.name, "setup.bash"])) 28 | ctx.actions.run( 29 | executable = ctx.executable._setup_bash_generator, 30 | arguments = [output.path], 31 | outputs = [output], 32 | ) 33 | return "setup.bash", output 34 | 35 | def is_unique(list_of_items): 36 | return len(list_of_items) == len({i: None for i in list_of_items}) 37 | 38 | def _add_setup_bash(ctx, pkg_files_info, outputs): 39 | path, file = _build_setup_bash(ctx) 40 | _add_files_to_filegroup_info( 41 | pkg_files_info, 42 | PackageFilesInfo( 43 | attributes = _build_attributes(), 44 | dest_src_map = {path: file}, 45 | ), 46 | ctx.label, 47 | ) 48 | outputs.append(file) 49 | 50 | def ros_archive_impl(ctx): 51 | outputs = [] 52 | transitive_outputs = [] 53 | 54 | pkg_files_info = PackageFilegroupInfo( 55 | pkg_files = [], 56 | pkg_dirs = [], 57 | pkg_symlinks = [], 58 | ) 59 | 60 | _unique_pkg_names_or_fail(_create_ros_pkg_set_info(ctx.attr.ros_pkgs)) 61 | 62 | _add_setup_bash(ctx, pkg_files_info, outputs) 63 | for ros_pkg_target in ctx.attr.ros_pkgs: 64 | _add_filegroup(ros_pkg_target, pkg_files_info, transitive_outputs) 65 | 66 | return [ 67 | pkg_files_info, 68 | DefaultInfo(files = depset(direct = outputs, transitive = transitive_outputs)), 69 | ] 70 | 71 | ros_archive_pkg_files = rule( 72 | attrs = { 73 | "ros_pkgs": attr.label_list( 74 | mandatory = True, 75 | providers = [PackageFilegroupInfo, _RosPkgInfo], 76 | ), 77 | "_setup_bash_generator": attr.label( 78 | default = ":setup_bash.generate", 79 | executable = True, 80 | cfg = "exec", 81 | ), 82 | }, 83 | implementation = ros_archive_impl, 84 | ) 85 | 86 | def _ros_archive_install_command_impl(ctx): 87 | output = ctx.actions.declare_file(ctx.attr.name) 88 | ctx.actions.expand_template( 89 | output = output, 90 | is_executable = True, 91 | template = ctx.file._install_bash_template, 92 | substitutions = { 93 | "{{file}}": ctx.file.pkg_archive.short_path, 94 | "{{name}}": ctx.attr.group_name, 95 | }, 96 | ) 97 | return [ 98 | DefaultInfo( 99 | files = depset([output]), 100 | executable = output, 101 | runfiles = ctx.runfiles([output, ctx.file.pkg_archive]), 102 | ), 103 | ] 104 | 105 | ros_archive_install_command = rule( 106 | implementation = _ros_archive_install_command_impl, 107 | executable = True, 108 | attrs = { 109 | "_install_bash_template": attr.label( 110 | default = "templates/install.template", 111 | allow_single_file = True, 112 | ), 113 | "pkg_archive": attr.label( 114 | allow_single_file = True, 115 | ), 116 | "group_name": attr.string( 117 | mandatory = True, 118 | ), 119 | }, 120 | ) 121 | -------------------------------------------------------------------------------- /pkg/detail/ros_pkg.bzl: -------------------------------------------------------------------------------- 1 | # Copyright 2024 Apex.AI, Inc. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | load("@rules_pkg//pkg:providers.bzl", "PackageFilegroupInfo", "PackageFilesInfo") 16 | load("@rules_python//python:packaging.bzl", "PyWheelInfo") 17 | load("@rules_ros//pkg:providers.bzl", _RosPkgInfo = "RosPkgInfo") 18 | load( 19 | ":utils.bzl", 20 | _add_filegroup = "add_filegroup", 21 | _add_files_to_filegroup_info = "add_files_to_filegroup_info", 22 | _build_attributes = "build_attributes", 23 | _create_ros_pkg_info = "create_ros_pkg_info", 24 | _create_ros_pkg_set_info = "create_ros_pkg_set_info", 25 | _unique_pkg_names_or_fail = "unique_pkg_names_or_fail", 26 | ) 27 | 28 | RESOURCE_PATH_PREFIX = "share/bazel-bin/" 29 | LIBRARY_PATH = "lib/{pkg_name}/" 30 | BIN_PATH = "bin/" 31 | WHEELS_PATH = "share/wheels/" 32 | 33 | def _build_pkg_name(ctx): 34 | name_parts = [ctx.workspace_name] 35 | name_parts.extend(ctx.label.package.split("/")) 36 | if ctx.label.name != name_parts[-1]: 37 | name_parts.append(ctx.label.name) 38 | 39 | return "_".join(name_parts) 40 | 41 | def _build_package_xml(ctx, pkg_name): 42 | output = ctx.actions.declare_file("/".join([ctx.label.name, "package.xml"])) 43 | ctx.actions.run( 44 | executable = ctx.executable._package_xml_generator, 45 | arguments = [ 46 | output.path, 47 | "--pkg_name", 48 | pkg_name, 49 | "--maintainer_email", 50 | ctx.attr.maintainer_email, 51 | "--maintainer_name", 52 | ctx.attr.maintainer_name, 53 | "--version", 54 | ctx.attr.version, 55 | "--license", 56 | ctx.attr.license, 57 | "--description", 58 | ctx.attr.description, 59 | ], 60 | outputs = [output], 61 | ) 62 | return "share/{}/package.xml".format(pkg_name), output 63 | 64 | def _build_ament_index(ctx, pkg_name): 65 | output = ctx.actions.declare_file("{}/ament_index/resource_index/packages/{}".format(ctx.label.name, pkg_name)) 66 | ctx.actions.write(output, "") 67 | return "share/ament_index/resource_index/packages/{}".format(pkg_name), output 68 | 69 | def _build_executable_wrapper(ctx, path, file): 70 | resource_path_list = [".."] * (len(path.split("/")) - 1) 71 | resource_path_list.append(RESOURCE_PATH_PREFIX) 72 | output = ctx.actions.declare_file("resource/{}".format(file.basename)) 73 | ctx.actions.run( 74 | executable = ctx.executable._executable_wrapper_generator, 75 | arguments = [ 76 | output.path, 77 | file.short_path, 78 | "/".join(resource_path_list), 79 | ], 80 | outputs = [output], 81 | ) 82 | return output 83 | 84 | def _create_package_files_info(files, *, executable = False, prefix, use_basename = False): 85 | attributes = _build_attributes(executable = executable) 86 | return PackageFilesInfo( 87 | dest_src_map = { 88 | "{}{}".format( 89 | prefix, 90 | f.basename if use_basename else f.short_path, 91 | ): f 92 | for f in files 93 | }, 94 | attributes = attributes, 95 | ) 96 | 97 | def _add_package_files(ctx, pkg_name, pkg_files_info, outputs): 98 | for factory_method in [_build_package_xml, _build_ament_index]: 99 | path, file = factory_method(ctx, pkg_name) 100 | _add_files_to_filegroup_info( 101 | pkg_files_info, 102 | PackageFilesInfo( 103 | attributes = _build_attributes(), 104 | dest_src_map = {path: file}, 105 | ), 106 | ctx.label, 107 | ) 108 | outputs.append(file) 109 | 110 | def _add_executable_runfiles(ctx, pkg_files_info, outputs): 111 | targets = ctx.attr.lib_executables + ctx.attr.bin_executables 112 | for target in targets: 113 | _add_files_to_filegroup_info( 114 | pkg_files_info, 115 | _create_package_files_info( 116 | target[DefaultInfo].default_runfiles.files.to_list(), 117 | prefix = RESOURCE_PATH_PREFIX, 118 | executable = True, 119 | ), 120 | target.label, 121 | ) 122 | outputs.append(target[DefaultInfo].default_runfiles.files) 123 | 124 | def _add_executable_wrappers(ctx, pkg_name, pkg_files_info, outputs): 125 | for executables, path in [ 126 | (ctx.files.lib_executables, LIBRARY_PATH.format(pkg_name = pkg_name)), 127 | (ctx.files.bin_executables, BIN_PATH), 128 | ]: 129 | executable_wrappers = [ 130 | _build_executable_wrapper(ctx, path, executable) 131 | for executable in executables 132 | ] 133 | outputs.extend(executable_wrappers) 134 | _add_files_to_filegroup_info( 135 | pkg_files_info, 136 | _create_package_files_info( 137 | executable_wrappers, 138 | prefix = path, 139 | executable = True, 140 | use_basename = True, 141 | ), 142 | ctx.label, 143 | ) 144 | 145 | def _add_py_wheels(ctx, pkg_files_info, transitive_outputs): 146 | for target in ctx.attr.py_packages: 147 | _add_files_to_filegroup_info( 148 | pkg_files_info, 149 | _create_package_files_info( 150 | [target[PyWheelInfo].wheel], 151 | prefix = WHEELS_PATH, 152 | use_basename = True, 153 | ), 154 | ctx.label, 155 | ) 156 | transitive_outputs.append(target[DefaultInfo].default_runfiles.files) 157 | 158 | def _ros_pkg_impl(ctx): 159 | outputs = [] 160 | transitive_outputs = [] 161 | pkg_files_info = PackageFilegroupInfo( 162 | pkg_files = [], 163 | pkg_dirs = [], 164 | pkg_symlinks = [], 165 | ) 166 | 167 | if ctx.attr._unnamed_pkg: 168 | ros_pkg_info = _create_ros_pkg_set_info(ctx.attr.deps) 169 | else: 170 | pkg_name = ctx.attr.pkg_name if ctx.attr.pkg_name != "" else _build_pkg_name(ctx) 171 | ros_pkg_info = _create_ros_pkg_info(ctx, pkg_name) 172 | 173 | _add_package_files(ctx, pkg_name, pkg_files_info, outputs) 174 | _add_executable_runfiles(ctx, pkg_files_info, transitive_outputs) 175 | _add_executable_wrappers(ctx, pkg_name, pkg_files_info, outputs) 176 | _add_py_wheels(ctx, pkg_files_info, transitive_outputs) 177 | 178 | for ros_pkg_target in ctx.attr.deps: 179 | _add_filegroup(ros_pkg_target, pkg_files_info, transitive_outputs) 180 | 181 | _unique_pkg_names_or_fail(ros_pkg_info) 182 | 183 | return [ 184 | ros_pkg_info, 185 | pkg_files_info, 186 | DefaultInfo(files = depset(direct = outputs, transitive = transitive_outputs)), 187 | ] 188 | 189 | ros_pkg_set = rule( 190 | implementation = _ros_pkg_impl, 191 | attrs = { 192 | "deps": attr.label_list( 193 | mandatory = False, 194 | providers = [_RosPkgInfo], 195 | ), 196 | "_unnamed_pkg": attr.bool( 197 | default = True, 198 | ), 199 | }, 200 | ) 201 | 202 | ros_pkg = rule( 203 | implementation = _ros_pkg_impl, 204 | attrs = { 205 | "pkg_name": attr.string( 206 | mandatory = False, 207 | ), 208 | "description": attr.string( 209 | mandatory = True, 210 | ), 211 | "version": attr.string( 212 | mandatory = True, 213 | ), 214 | "maintainer_name": attr.string( 215 | mandatory = True, 216 | ), 217 | "maintainer_email": attr.string( 218 | mandatory = False, 219 | ), 220 | "license": attr.string( 221 | mandatory = True, 222 | ), 223 | "lib_executables": attr.label_list( 224 | mandatory = False, 225 | ), 226 | "bin_executables": attr.label_list( 227 | mandatory = False, 228 | ), 229 | "py_packages": attr.label_list( 230 | mandatory = False, 231 | providers = [PyWheelInfo], 232 | ), 233 | "deps": attr.label_list( 234 | mandatory = False, 235 | providers = [_RosPkgInfo], 236 | ), 237 | "_package_xml_generator": attr.label( 238 | default = ":package_xml.generate", 239 | executable = True, 240 | cfg = "exec", 241 | ), 242 | "_executable_wrapper_generator": attr.label( 243 | default = ":executable_wrapper.generate", 244 | executable = True, 245 | cfg = "exec", 246 | ), 247 | "_unnamed_pkg": attr.bool( 248 | default = False, 249 | ), 250 | }, 251 | ) 252 | -------------------------------------------------------------------------------- /pkg/detail/setup_bash_generator.py: -------------------------------------------------------------------------------- 1 | # Copyright 2024 Apex.AI, Inc. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | import argparse 16 | 17 | TEMPLATE = """# !/usr/bash 18 | SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd ) 19 | 20 | export PATH=$SCRIPT_DIR/bin:$PATH 21 | export AMENT_PREFIX_PATH=$SCRIPT_DIR:$AMENT_PREFIX_PATH 22 | for pythonpath in $SCRIPT_DIR/lib/python*/site-packages; do 23 | if [ -d "$pythonpath" ]; then 24 | export PYTHONPATH=$pythonpath:$PYTHONPATH 25 | fi 26 | done 27 | """ 28 | 29 | 30 | def main(): 31 | parser = argparse.ArgumentParser(description="Generate `setup.bash`.") 32 | parser.add_argument('output_path', type=str, help='Output path.') 33 | 34 | args = parser.parse_args() 35 | 36 | with open(args.output_path, "w") as out_file: 37 | out_file.write(TEMPLATE) 38 | 39 | 40 | if __name__ == "__main__": 41 | main() 42 | -------------------------------------------------------------------------------- /pkg/detail/templates/install.template: -------------------------------------------------------------------------------- 1 | #! /bin/bash 2 | # Copyright 2024 Apex.AI, Inc. 3 | # 4 | # Licensed under the Apache License, Version 2.0 (the "License"); 5 | # you may not use this file except in compliance with the License. 6 | # You may obtain a copy of the License at 7 | # 8 | # http://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | # See the License for the specific language governing permissions and 14 | # limitations under the License. 15 | 16 | ARCHIVE={{file}} 17 | PREFIX=$1/{{name}} 18 | 19 | if [ $# -ne 1 ]; then 20 | echo "Please specify an install folder" && exit 1 21 | fi 22 | echo "Install dir: $1" 23 | mkdir -p $1 24 | 25 | if ls $PREFIX 2> /dev/null >/dev/null; then 26 | echo "Removing old installation." 27 | rm -rf $PREFIX 28 | fi 29 | 30 | echo "Installing $ARCHIVE" 31 | tar -xf $ARCHIVE --directory=$1 32 | 33 | 34 | if command -v pip > /dev/null; then 35 | if ls $PREFIX/share/*/*.whl 2> /dev/null >/dev/null; then 36 | echo "Installing Python wheels to $PREFIX" 37 | pip install --prefix $PREFIX --no-warn-script-location $PREFIX/share/*/*.whl 38 | fi 39 | fi 40 | -------------------------------------------------------------------------------- /pkg/detail/utils.bzl: -------------------------------------------------------------------------------- 1 | # Copyright 2024 Apex.AI, Inc. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | load("@rules_pkg//pkg:providers.bzl", _PackageFilegroupInfo = "PackageFilegroupInfo") 16 | load("@rules_ros//pkg:providers.bzl", _RosPkgInfo = "RosPkgInfo") 17 | 18 | def add_files_to_filegroup_info(filegroup_info, pkg_files_info, label): 19 | filegroup_info.pkg_files.append((pkg_files_info, label)) 20 | 21 | def build_attributes(*, executable = False): 22 | return {"mode": "0755"} if executable else {"mode": "0644"} 23 | 24 | def add_filegroup(ros_pkg_target, pkg_files_info, transitive_outputs): 25 | pfi = ros_pkg_target[_PackageFilegroupInfo] 26 | pkg_files_info.pkg_files.extend(pfi.pkg_files) 27 | pkg_files_info.pkg_dirs.extend(pfi.pkg_dirs) 28 | pkg_files_info.pkg_symlinks.extend(pfi.pkg_symlinks) 29 | transitive_outputs.append(ros_pkg_target[DefaultInfo].files) 30 | 31 | def create_ros_pkg_info(ctx, pkg_name): 32 | return _RosPkgInfo( 33 | name = pkg_name, 34 | description = ctx.attr.description, 35 | version = ctx.attr.version, 36 | maintainer_name = ctx.attr.maintainer_name, 37 | maintainer_email = ctx.attr.maintainer_email, 38 | license = ctx.attr.license, 39 | lib_executables = ctx.attr.lib_executables, 40 | bin_executables = ctx.attr.bin_executables, 41 | py_packages = ctx.attr.py_packages, 42 | deps = _build_ros_pkg_info_deps(ctx.attr.deps), 43 | ) 44 | 45 | def create_ros_pkg_set_info(ros_pkgs): 46 | return _RosPkgInfo( 47 | name = None, 48 | deps = _build_ros_pkg_info_deps(ros_pkgs), 49 | ) 50 | 51 | def _build_ros_pkg_info_deps(deps): 52 | direct_deps = [pkg for pkg in deps] 53 | return depset( 54 | direct = [pkg for pkg in direct_deps if pkg[_RosPkgInfo].name], 55 | transitive = [pkg[_RosPkgInfo].deps for pkg in direct_deps], 56 | ) 57 | 58 | def _are_unique(list_of_items): 59 | return len(list_of_items) == len({i: None for i in list_of_items}) 60 | 61 | def unique_pkg_names_or_fail(ros_pkg_info): 62 | pkg_names = [ros_pkg[_RosPkgInfo].name for ros_pkg in ros_pkg_info.deps.to_list()] 63 | if ros_pkg_info.name: 64 | pkg_names.append(ros_pkg_info.name) 65 | if not _are_unique(pkg_names): 66 | fail("ROS package names must be unique in a ros_archive.") 67 | -------------------------------------------------------------------------------- /pkg/providers.bzl: -------------------------------------------------------------------------------- 1 | # Copyright 2024 Apex.AI, Inc. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | RosPkgInfo = provider( 16 | fields = [ 17 | "name", 18 | "description", 19 | "version", 20 | "maintainer_name", 21 | "maintainer_email", 22 | "license", 23 | "lib_executables", 24 | "bin_executables", 25 | "py_packages", 26 | "deps", 27 | ], 28 | ) 29 | -------------------------------------------------------------------------------- /repos/BUILD.bazel: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ApexAI/rules_ros/5d2d81bc7779cbdada626be299354a3b5544ba2f/repos/BUILD.bazel -------------------------------------------------------------------------------- /repos/ament.ament_index/ament_index_cpp.BUILD: -------------------------------------------------------------------------------- 1 | # Copyright 2024 Apex.AI, Inc. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | cc_library( 16 | name = "ament_index_cpp", 17 | srcs = glob(["src/*"]), 18 | hdrs = glob(["include/**/*"]), 19 | strip_include_prefix = "include", 20 | visibility = ["//visibility:public"], 21 | deps = [ 22 | ], 23 | ) 24 | -------------------------------------------------------------------------------- /repos/ament.ament_index/ament_index_python.BUILD: -------------------------------------------------------------------------------- 1 | # Copyright 2024 Apex.AI, Inc. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | load("@rules_python//python:packaging.bzl", "py_wheel") 16 | load("@rules_python//python:python.bzl", "py_test") 17 | load("@rules_ros//pkg:defs.bzl", "ros_pkg") 18 | load("@python_deps//:requirements.bzl", "requirement") 19 | 20 | py_library( 21 | name = "ament_index_python_py", 22 | srcs = glob(["ament_index_python/**/*.py"]), 23 | ) 24 | 25 | py_test( 26 | name = "ament_index_python_py_test", 27 | srcs = ["test/test_ament_index_python.py"], 28 | imports = ["."], 29 | main = "test/test_ament_index_python.py", 30 | deps = [ 31 | ":ament_index_python_py", 32 | requirement("attrs"), 33 | requirement("pluggy"), 34 | requirement("pytest"), 35 | ], 36 | ) 37 | 38 | py_wheel( 39 | name = "ament_index_python_whl", 40 | # packages=find_packages(exclude=['test']), 41 | # data_files=[ 42 | # ('share/' + package_name, ['package.xml']), 43 | # ('share/ament_index/resource_index/packages', 44 | # ['resource/' + package_name]), 45 | # ], 46 | # install_requires=['ros2cli'], 47 | # zip_safe=True, 48 | author = "Dirk Thomas", 49 | author_email = "dthomas@osrfoundation.org", 50 | # maintainer='Dirk Thomas', 51 | # maintainer_email='dthomas@osrfoundation.org', 52 | # url='https://github.com/ros2/ros2cli/tree/master/ros2run', 53 | # download_url='https://github.com/ros2/ros2cli/releases', 54 | # keywords=[], 55 | classifiers = [ 56 | "Intended Audience :: Developers", 57 | "License :: OSI Approved :: Apache Software License", 58 | "Programming Language :: Python", 59 | "Topic :: Software Development", 60 | ], 61 | #description_file = "README.md", 62 | distribution = "ament_index_python", 63 | #tests_require=['pytest'], 64 | license = "Apache License, Version 2.0", 65 | strip_path_prefixes = ["ament_index_python"], 66 | version = "0.8.6", 67 | deps = [":ament_index_python_py"], 68 | entry_points = { 69 | "console_scripts": [ 70 | "ament_index = ament_index_python.cli:main", 71 | ], 72 | }, 73 | ) 74 | 75 | ros_pkg( 76 | name = "ament_index_python", 77 | description = "Python API to access the ament resource index.", 78 | license = "Apex.AI License", 79 | maintainer_name = "Dirk Thomas", 80 | maintainer_email = "dthomas@osrfoundation.org", 81 | pkg_name = "ament_index_python", 82 | py_packages = ["ament_index_python_whl"], 83 | version = "0.7.2", 84 | visibility = ["//visibility:public"], 85 | ) 86 | -------------------------------------------------------------------------------- /repos/config/BUILD.bazel: -------------------------------------------------------------------------------- 1 | # Copyright 2024 Apex.AI, Inc. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | exports_files(["bazel.repos"] + glob(["*.lock.bzl"])) 16 | 17 | alias( 18 | name = "repos_lock.update", 19 | actual = "@ros2_config//:repos_lock.update", 20 | ) 21 | -------------------------------------------------------------------------------- /repos/config/bazel.repos: -------------------------------------------------------------------------------- 1 | repositories: 2 | # ament/ament_cmake: 3 | # bazel: {} 4 | ament/ament_index: 5 | bazel: 6 | "@rules_ros//repos:ament.ament_index/ament_index_cpp.BUILD": "ament_index_cpp/BUILD.bazel" 7 | "@rules_ros//repos:ament.ament_index/ament_index_python.BUILD": "ament_index_python/BUILD.bazel" 8 | # ament/ament_lint: 9 | # bazel: {} 10 | # ament/ament_package: 11 | # bazel: {} 12 | # ament/google_benchmark_vendor: 13 | # bazel: {} 14 | # ament/googletest: 15 | # bazel: {} 16 | # ament/uncrustify_vendor: 17 | # bazel: {} 18 | eProsima/Fast-CDR: 19 | bazel: 20 | "@rules_ros//repos:default.BUILD": "BUILD.bazel" 21 | eProsima/Fast-DDS: 22 | bazel: 23 | "@rules_ros//repos:default.BUILD": "BUILD.bazel" 24 | eProsima/foonathan_memory_vendor: 25 | bazel: 26 | "@rules_ros//repos:default.BUILD": "BUILD.bazel" 27 | eclipse-cyclonedds/cyclonedds: 28 | bazel: 29 | "@rules_ros//repos:default.BUILD": "BUILD.bazel" 30 | eclipse-iceoryx/iceoryx: 31 | bazel: 32 | "@rules_ros//repos:default.BUILD": "BUILD.bazel" 33 | # ignition/ignition_cmake2_vendor: 34 | # bazel: {} 35 | # ignition/ignition_math6_vendor: 36 | # bazel: {} 37 | # osrf/osrf_pycommon: 38 | # bazel: {} 39 | # osrf/osrf_testing_tools_cpp: 40 | # bazel: {} 41 | # ros-perception/image_common: 42 | # bazel: {} 43 | # ros-perception/laser_geometry: 44 | # bazel: {} 45 | # ros-planning/navigation_msgs: 46 | # bazel: {} 47 | # ros-tooling/keyboard_handler: 48 | # bazel: {} 49 | ros-tooling/libstatistics_collector: 50 | bazel: 51 | "@rules_ros//repos:ros-tooling.libstatistics_collector/root.BUILD": "BUILD.bazel" 52 | # ros-visualization/interactive_markers: 53 | # bazel: {} 54 | # ros-visualization/python_qt_binding: 55 | # bazel: {} 56 | # ros-visualization/qt_gui_core: 57 | # bazel: {} 58 | # ros-visualization/rqt: 59 | # bazel: {} 60 | # ros-visualization/rqt_action: 61 | # bazel: {} 62 | # ros-visualization/rqt_bag: 63 | # bazel: {} 64 | # ros-visualization/rqt_console: 65 | # bazel: {} 66 | # ros-visualization/rqt_graph: 67 | # bazel: {} 68 | # ros-visualization/rqt_msg: 69 | # bazel: {} 70 | # ros-visualization/rqt_plot: 71 | # bazel: {} 72 | # ros-visualization/rqt_publisher: 73 | # bazel: {} 74 | # ros-visualization/rqt_py_console: 75 | # bazel: {} 76 | # ros-visualization/rqt_reconfigure: 77 | # bazel: {} 78 | # ros-visualization/rqt_service_caller: 79 | # bazel: {} 80 | # ros-visualization/rqt_shell: 81 | # bazel: {} 82 | # ros-visualization/rqt_srv: 83 | # bazel: {} 84 | # ros-visualization/rqt_topic: 85 | # bazel: {} 86 | # ros-visualization/tango_icons_vendor: 87 | # bazel: {} 88 | # ros/class_loader: 89 | # bazel: {} 90 | # ros/kdl_parser: 91 | # bazel: {} 92 | # ros/pluginlib: 93 | # bazel: {} 94 | # ros/resource_retriever: 95 | # bazel: {} 96 | # ros/robot_state_publisher: 97 | # bazel: {} 98 | # ros/ros_environment: 99 | # bazel: {} 100 | # ros/ros_tutorials: 101 | # bazel: {} 102 | # ros/urdfdom: 103 | # bazel: {} 104 | # ros/urdfdom_headers: 105 | # bazel: {} 106 | # ros2/ament_cmake_ros: 107 | # bazel: {} 108 | ros2/common_interfaces: 109 | bazel: 110 | "@rules_ros//repos:ros2.common_interfaces/std_msgs.BUILD": "std_msgs/BUILD.bazel" 111 | # ros2/console_bridge_vendor: 112 | # bazel: {} 113 | # ros2/demos: 114 | # bazel: {} 115 | # ros2/eigen3_cmake_module: 116 | # bazel: {} 117 | # ros2/example_interfaces: 118 | # bazel: {} 119 | # ros2/examples: 120 | # bazel: {} 121 | # ros2/geometry2: 122 | # bazel: {} 123 | # ros2/launch: 124 | # bazel: {} 125 | # ros2/launch_ros: 126 | # bazel: {} 127 | # ros2/libyaml_vendor: 128 | # bazel: {} 129 | # ros2/message_filters: 130 | # bazel: {} 131 | # ros2/mimick_vendor: 132 | # bazel: {} 133 | # ros2/orocos_kdl_vendor: 134 | # bazel: {} 135 | # ros2/performance_test_fixture: 136 | # bazel: {} 137 | # ros2/pybind11_vendor: 138 | # bazel: {} 139 | # ros2/python_cmake_module: 140 | # bazel: {} 141 | ros2/rcl: 142 | bazel: 143 | "@rules_ros//repos:ros2.rcl/rcl.BUILD": "rcl/BUILD.bazel" 144 | "@rules_ros//repos:ros2.rcl/rcl_yaml_param_parser.BUILD": "rcl_yaml_param_parser/BUILD.bazel" 145 | ros2/rcl_interfaces: 146 | bazel: 147 | "@rules_ros//repos:ros2.rcl_interfaces/rcl_interfaces.BUILD": "rcl_interfaces/BUILD.bazel" 148 | "@rules_ros//repos:ros2.rcl_interfaces/rosgraph_msgs.BUILD": "rosgraph_msgs/BUILD.bazel" 149 | "@rules_ros//repos:ros2.rcl_interfaces/builtin_interfaces.BUILD": "builtin_interfaces/BUILD.bazel" 150 | "@rules_ros//repos:ros2.rcl_interfaces/statistics_msgs.BUILD": "statistics_msgs/BUILD.bazel" 151 | ros2/rcl_logging: 152 | bazel: 153 | "@rules_ros//repos:ros2.rcl_logging/rcl_logging_interface.BUILD": "rcl_logging_interface/BUILD.bazel" 154 | ros2/rclcpp: 155 | bazel: 156 | "@rules_ros//repos:ros2.rclcpp/build_interfaces.py": "rclcpp/build_interfaces.py" 157 | "@rules_ros//repos:ros2.rclcpp/rclcpp.BUILD": "rclcpp/BUILD.bazel" 158 | # ros2/rclpy: 159 | # bazel: {} 160 | ros2/rcpputils: 161 | bazel: 162 | "@rules_ros//repos:ros2.rcpputils/rcpputils.BUILD": "BUILD.bazel" 163 | ros2/rcutils: 164 | bazel: 165 | "@rules_ros//repos:ros2.rcutils/root.BUILD": "BUILD.bazel" 166 | "@rules_ros//repos:ros2.rcutils/build_logging_macros.py": "build_logging_macros.py" 167 | # ros2/realtime_support: 168 | # bazel: {} 169 | ros2/rmw: 170 | bazel: 171 | "@rules_ros//repos:ros2.rmw/rmw.BUILD": "rmw/BUILD.bazel" 172 | # ros2/rmw_connextdds: 173 | # bazel: {} 174 | # ros2/rmw_cyclonedds: 175 | # bazel: {} 176 | # ros2/rmw_dds_common: 177 | # bazel: {} 178 | # ros2/rmw_fastrtps: 179 | # bazel: {} 180 | # ros2/rmw_implementation: 181 | # bazel: {} 182 | ros2/ros2_tracing: 183 | bazel: 184 | "@rules_ros//repos:ros2.ros2_tracing/tracetools.BUILD": "tracetools/BUILD.bazel" 185 | ros2/ros2cli: 186 | bazel: 187 | "@rules_ros//repos:ros2.ros2cli/ros2cli.BUILD": "ros2cli/BUILD.bazel" 188 | "@rules_ros//repos:ros2.ros2cli/ros2pkg.BUILD": "ros2pkg/BUILD.bazel" 189 | "@rules_ros//repos:ros2.ros2cli/ros2run.BUILD": "ros2run/BUILD.bazel" 190 | # ros2/ros2cli_common_extensions: 191 | # bazel: {} 192 | # ros2/ros_testing: 193 | # bazel: {} 194 | # ros2/rosbag2: 195 | # bazel: {} 196 | ros2/rosidl: 197 | bazel: 198 | "@rules_ros//repos:ros2.rosidl/rosidl_runtime_c.BUILD": "rosidl_runtime_c/BUILD.bazel" 199 | "@rules_ros//repos:ros2.rosidl/rosidl_runtime_cpp.BUILD": "rosidl_runtime_cpp/BUILD.bazel" 200 | "@rules_ros//repos:ros2.rosidl/rosidl_adapter.BUILD": "rosidl_adapter/BUILD.bazel" 201 | "@rules_ros//repos:ros2.rosidl/rosidl_cli.BUILD": "rosidl_cli/BUILD.bazel" 202 | "@rules_ros//repos:ros2.rosidl/rosidl_parser.BUILD": "rosidl_parser/BUILD.bazel" 203 | "@rules_ros//repos:ros2.rosidl/rosidl_cmake.BUILD": "rosidl_cmake/BUILD.bazel" 204 | "@rules_ros//repos:ros2.rosidl/rosidl_typesupport_interface.BUILD": "rosidl_typesupport_interface/BUILD.bazel" 205 | "@rules_ros//repos:ros2.rosidl/rosidl_generator_c.BUILD": "rosidl_generator_c/BUILD.bazel" 206 | "@rules_ros//repos:ros2.rosidl/rosidl_generator_cpp.BUILD": "rosidl_generator_cpp/BUILD.bazel" 207 | ros2/rosidl_dds: 208 | bazel: 209 | "@rules_ros//repos:ros2.rosidl_dds/rosidl_generator_dds_idl.BUILD": "rosidl_generator_dds_idl/BUILD.bazel" 210 | # ros2/rosidl_defaults: 211 | # bazel: {} 212 | # ros2/rosidl_python: 213 | # bazel: {} 214 | # ros2/rosidl_runtime_py: 215 | # bazel: {} 216 | ros2/rosidl_typesupport: 217 | bazel: 218 | "@rules_ros//repos:ros2.rosidl_typesupport/rosidl_typesupport_c.BUILD": "rosidl_typesupport_c/BUILD.bazel" 219 | # ros2/rosidl_typesupport_fastrtps: 220 | # bazel: {} 221 | # ros2/rpyutils: 222 | # bazel: {} 223 | # ros2/rviz: 224 | # bazel: {} 225 | # ros2/spdlog_vendor: 226 | # bazel: {} 227 | # ros2/sros2: 228 | # bazel: {} 229 | # ros2/system_tests: 230 | # bazel: {} 231 | # ros2/test_interface_files: 232 | # bazel: {} 233 | # ros2/tinyxml2_vendor: 234 | # bazel: {} 235 | # ros2/tinyxml_vendor: 236 | # bazel: {} 237 | # ros2/tlsf: 238 | # bazel: {} 239 | # ros2/unique_identifier_msgs: 240 | # bazel: {} 241 | # ros2/urdf: 242 | # bazel: {} 243 | # ros2/yaml_cpp_vendor: 244 | # bazel: {} 245 | -------------------------------------------------------------------------------- /repos/config/defs.bzl: -------------------------------------------------------------------------------- 1 | # Copyright 2024 Apex.AI, Inc. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | load("@bazel_tools//tools/build_defs/repo:utils.bzl", "maybe") 16 | load("@rules_ros//repos/config:distros.bzl", "DISTROS") 17 | load("@rules_ros//repos/config/detail:ros2_config.bzl", "ros2_config") 18 | 19 | def _configure_ros2(*, name, distro_src, repos_index_overlays): 20 | distro_src_wo_setup_file = {k: v for k, v in distro_src.items() if k != "setup_file"} 21 | distro_src_wo_setup_file["build_file_content"] = 'exports_files(["ros2.repos"])' 22 | 23 | maybe(name = "ros2", **distro_src_wo_setup_file) 24 | 25 | ros2_config( 26 | name = name, 27 | repos_index = "@ros2//:ros2.repos", 28 | repos_index_overlays = [ 29 | "@rules_ros//repos/config:bazel.repos", 30 | ] + repos_index_overlays, 31 | setup_file = distro_src["setup_file"], 32 | ) 33 | 34 | def configure_ros2(*, name = "ros2_config", repos_index_overlays = [], distro): 35 | """Configure ROS 2 repositories based on the given distro name.""" 36 | 37 | if type(distro) == type(""): 38 | if not distro in DISTROS: 39 | fail("Distro {} is not supported. Choose one of {}".format(distro, DISTROS.keys())) 40 | distro_src = DISTROS[distro] 41 | else: 42 | if not type(distro) == type({}) or not "repo_rule" in distro: 43 | fail("Distro either needs to be a string (e.g. 'iron') or a dict with arguments for the maybe repo rule") 44 | distro_src = distro 45 | if not type(repos_index_overlays) == type([]): 46 | fail("repos_index_overlays needs to be a list of *.repos files") 47 | _configure_ros2(name = name, distro_src = distro_src, repos_index_overlays = repos_index_overlays) 48 | 49 | def configure_repos(*, name, repos_index, setup_file, repos_index_overlays = []): 50 | """Configure ROS 2 repositories based on the custom *.repos file.""" 51 | 52 | if not type(repos_index_overlays) == type([]): 53 | fail("repos_index_overlays needs to be a list of *.repos files") 54 | 55 | ros2_config( 56 | name = name, 57 | repos_index = repos_index, 58 | repos_index_overlays = repos_index_overlays, 59 | setup_file = setup_file, 60 | ) 61 | -------------------------------------------------------------------------------- /repos/config/detail/BUILD.bazel: -------------------------------------------------------------------------------- 1 | # Copyright 2024 Apex.AI, Inc. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | exports_files([ 16 | "generate_ros2_config.py", 17 | "lock_repos.py", 18 | ]) 19 | -------------------------------------------------------------------------------- /repos/config/detail/generate_repos_lock.bzl: -------------------------------------------------------------------------------- 1 | load("@python_deps//:requirements.bzl", "requirement") 2 | load("@rules_python//python:defs.bzl", "py_binary") 3 | 4 | def repos_lock_updater(*, name, repos_file, setup_file, overlay_files): 5 | """Executable rule for updating the `setup_file` from a `repos_file` and `overlay_files`.""" 6 | 7 | py_binary( 8 | name = name, 9 | srcs = [Label("lock_repos.py"), Label("generate_ros2_config.py")], 10 | main = Label("lock_repos.py"), 11 | data = [repos_file, setup_file] + overlay_files, 12 | args = [ 13 | "$(execpath {})".format(repos_file), 14 | "$(execpath {})".format(setup_file), 15 | ] + ["$(execpath {})".format(f) for f in overlay_files] + 16 | ["--workspace_name {}".format(native.repo_name())], 17 | deps = [requirement("pyyaml")], 18 | visibility = ["//visibility:public"], 19 | ) 20 | -------------------------------------------------------------------------------- /repos/config/detail/generate_ros2_config.py: -------------------------------------------------------------------------------- 1 | # Copyright 2024 Apex.AI, Inc. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | import yaml 16 | import hashlib 17 | import os 18 | 19 | def get_sha256sum(file): 20 | sha256_hash = hashlib.sha256() 21 | with open(file, "rb") as f: 22 | for byte_block in iter(lambda: f.read(4096), b""): 23 | sha256_hash.update(byte_block) 24 | return sha256_hash.hexdigest() 25 | 26 | def print_setup(repos, output_file, repos_file, overlay_files, workspace_name, use_tar = False): 27 | BZL_CMD = f"bazel run @{workspace_name}//:repos_lock.update" 28 | if use_tar: 29 | BZL_CMD += " -- --tar" 30 | HEADER = f"""# 31 | # DO NOT EDIT THIS FILE MANUALLY! 32 | # 33 | # To update, call `{BZL_CMD}` with the right distro set in the WORKSPACE 34 | # 35 | # SHA256 of @{workspace_name}//:{repos_file}: {get_sha256sum(repos_file)} 36 | # SHA256 of overlays: 37 | #{', '.join([f' @{workspace_name}//:{os.path.basename(overlay)}: {get_sha256sum(overlay)}' for overlay in overlay_files]) if overlay_files else ""} 38 | 39 | load("@bazel_tools//tools/build_defs/repo:utils.bzl", _maybe = "maybe") 40 | load("@rules_ros//repos/config/detail:git_repository.bzl", "git_repository") 41 | load("@rules_ros//repos/config/detail:http_archive.bzl", "http_archive") 42 | load("@rules_ros//repos/config/detail:new_local_repository.bzl", "new_local_repository") 43 | 44 | def setup(): 45 | pass 46 | """ 47 | 48 | print(HEADER, file=output_file) 49 | printed_first_load = False 50 | for repo, spec in repos.items(): 51 | if spec.get("bazel") is not None: 52 | if printed_first_load: 53 | output_file.write("\n") 54 | output_file.write(build_load_command(repo, spec)) 55 | printed_first_load = True 56 | 57 | 58 | def build_load_command(repo, spec): 59 | builder = { 60 | "git": build_git_load_command, 61 | "http_archive": build_http_archive_load_command, 62 | "local": build_local_load_command, 63 | } 64 | if spec.get('type') not in builder.keys(): 65 | return f"""\ 66 | print("WARNING: Unknown repo type {spec.get('type')} for repo @{repo.replace('/', '.')}") 67 | """ 68 | return builder[spec.get('type')](repo, spec) 69 | 70 | 71 | def build_build_files_attr(build_files): 72 | if not build_files: 73 | return "" 74 | content = '\n'.join(f' "{k}": "{v}",' for k,v in build_files.items()) 75 | return f"""build_files = {{ 76 | {content} 77 | }},""" 78 | 79 | 80 | def build_list_attr(name, list_attr): 81 | if not name: 82 | raise ValueError("Cannot build an attribute without a name") 83 | if not list_attr: 84 | return "" 85 | content = '\n'.join(f' "{i}",' for i in list_attr) 86 | return f"""\n{name} = [ 87 | {content} 88 | ],""" 89 | 90 | 91 | def build_http_archive_load_command(repo, spec): 92 | return f""" 93 | _maybe( 94 | name = "{repo.replace('/','.')}", 95 | {build_build_files_attr(spec['bazel'])} 96 | url = "{spec['url']}", 97 | sha256 = "{spec['hash']}", 98 | strip_prefix = "{spec['strip_prefix']}", 99 | repo_rule = http_archive,{build_list_attr('patches', spec.get('patches'))}{build_list_attr('patch_args', spec.get('patch_args'))} 100 | ) 101 | """ 102 | 103 | 104 | def build_local_load_command(repo, spec): 105 | return f"""\ 106 | _maybe( 107 | name = "{repo.replace('/','.')}", 108 | {build_build_files_attr(spec['bazel'])} 109 | path = "{spec['path']}", 110 | sha256 = "{spec['hash']}", 111 | repo_rule = new_local_repository, 112 | ) 113 | """ 114 | 115 | 116 | def build_git_load_command(repo, spec): 117 | return f"""\ 118 | _maybe( 119 | name = "{repo.replace('/','.')}", 120 | branch = "{spec['version']}", 121 | {build_build_files_attr(spec['bazel'])} 122 | commit = "{spec['hash']}", 123 | remote = "{spec['url']}", 124 | repo_rule = git_repository, 125 | shallow_since = "{spec['shallow_since']}", 126 | ) 127 | """ 128 | 129 | 130 | def merge_dict(origin, to_add): 131 | for key, value in to_add.items(): 132 | if key in origin and isinstance(origin[key], dict): 133 | merge_dict(origin[key],value) 134 | else: 135 | origin[key]=value 136 | 137 | 138 | def print_setup_file(repos, overlay_files, output_file, repos_file, workspace_name, use_tar = False): 139 | for input_path in overlay_files: 140 | with (open(input_path,"r")) as repo_file: 141 | merge_dict(repos, yaml.safe_load(repo_file)["repositories"]) 142 | 143 | print_setup(repos, output_file, repos_file, overlay_files, workspace_name, use_tar) 144 | -------------------------------------------------------------------------------- /repos/config/detail/git_repository.bzl: -------------------------------------------------------------------------------- 1 | # Copyright 2024 Apex.AI, Inc. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | load("@bazel_tools//tools/build_defs/repo:utils.bzl", "update_attrs") 16 | 17 | _archive_attrs = { 18 | "remote": attr.string( 19 | doc = "URI of the repository.", 20 | ), 21 | "branch": attr.string( 22 | doc = 23 | "Branch to be checked out.", 24 | ), 25 | "commit": attr.string( 26 | doc = 27 | "Hash of the commit to be checked out.", 28 | ), 29 | "shallow_since": attr.string( 30 | doc = 31 | "Time of required commit.", 32 | ), 33 | "build_files": attr.label_keyed_string_dict( 34 | doc = """ 35 | Dict with a file as key and the path where to place the file in the repository as value. 36 | This allows to place multiple (BUILD) files in a repo. 37 | """, 38 | ), 39 | } 40 | 41 | def _execute_or_fail(ctx, args, **kwargs): 42 | result = ctx.execute(args, **kwargs) 43 | if result.return_code != 0: 44 | fail(result.stderr) 45 | return result 46 | 47 | def _git_clone(ctx): 48 | _execute_or_fail(ctx, [ 49 | "git", 50 | "clone", 51 | ctx.attr.remote, 52 | ".", 53 | "--branch", 54 | ctx.attr.branch, 55 | "--shallow-since=" + ctx.attr.shallow_since, 56 | ]) 57 | _execute_or_fail(ctx, [ 58 | "git", 59 | "checkout", 60 | ctx.attr.commit, 61 | ]) 62 | 63 | def _file_exists(ctx, file_name): 64 | exec_result = ctx.execute(["ls", file_name]) 65 | if exec_result.return_code != 0: 66 | return False 67 | return True 68 | 69 | def _workspace_and_buildfiles(ctx): 70 | if not _file_exists(ctx, "WORKSPACE") and not _file_exists(ctx, "WORKSPACE.bazel"): 71 | ctx.file("WORKSPACE", content = 'workspace(name = "{}")'.format(ctx.name)) 72 | 73 | if not _file_exists(ctx, "WORKSPACE"): 74 | ctx.symlink("WORKSPACE", "WORKSPACE.bazel") 75 | 76 | for label, destinations in ctx.attr.build_files.items(): 77 | if type(destinations) != type([]): 78 | destinations = [destinations] 79 | for destination in destinations: 80 | ctx.symlink(label, destination) 81 | 82 | def _git_repository_impl(ctx): 83 | """Implementation of the git_repository rule.""" 84 | 85 | _git_clone(ctx) 86 | 87 | _workspace_and_buildfiles(ctx) 88 | 89 | return update_attrs(ctx.attr, _archive_attrs.keys(), {}) 90 | 91 | git_repository = repository_rule( 92 | implementation = _git_repository_impl, 93 | attrs = _archive_attrs, 94 | doc = 95 | """Custom rule to clone a git repo as external dependency. 96 | It allows to inject multiple BUILD files. 97 | """, 98 | ) 99 | -------------------------------------------------------------------------------- /repos/config/detail/http_archive.bzl: -------------------------------------------------------------------------------- 1 | # Copyright 2024 Apex.AI, Inc. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | load("@bazel_tools//tools/build_defs/repo:utils.bzl", "patch", "update_attrs") 16 | 17 | _archive_attrs = { 18 | "url": attr.string( 19 | doc = "URI of the archive.", 20 | ), 21 | "strip_prefix": attr.string( 22 | doc = 23 | "Path prefix to be stripped.", 24 | ), 25 | "sha256": attr.string( 26 | doc = 27 | "Hash of the commit to be checked out.", 28 | ), 29 | "build_files": attr.label_keyed_string_dict( 30 | doc = """ 31 | Dict with a file as key and the path where to place the file in the repository as value. 32 | This allows to place multiple (BUILD) files in a repo. 33 | """, 34 | ), 35 | "patches": attr.label_list( 36 | default = [], 37 | doc = """ 38 | A list of files that are to be applied as patches after extracting the archive. It uses 39 | the Bazel-native patch implementation which doesn't support fuzz match and binary patch. 40 | """, 41 | ), 42 | "patch_args": attr.string_list( 43 | default = [], 44 | doc = """ 45 | The arguments given to the patch tool. Defaults to -p0, however -p1 will usually be 46 | needed for patches generated by git. If multiple -p arguments are specified, the last 47 | one will take effect. If arguments other than -p are specified, Bazel will fall back to 48 | use patch command line tool instead of the Bazel-native patch implementation. When 49 | falling back to patch command line tool and patch_tool attribute is not specified, 50 | `patch` will be used. This only affects patch files in the `patches` attribute. 51 | """, 52 | ), 53 | } 54 | 55 | def _execute_or_fail(ctx, args, **kwargs): 56 | result = ctx.execute(args, **kwargs) 57 | if result.return_code != 0: 58 | fail(result.stderr) 59 | return result 60 | 61 | def _file_exists(ctx, file_name): 62 | exec_result = ctx.execute(["ls", file_name]) 63 | if exec_result.return_code != 0: 64 | return False 65 | return True 66 | 67 | def _workspace_and_buildfiles(ctx): 68 | if not _file_exists(ctx, "WORKSPACE") and not _file_exists(ctx, "WORKSPACE.bazel"): 69 | ctx.file("WORKSPACE", content = 'workspace(name = "{}")'.format(ctx.name)) 70 | 71 | if not _file_exists(ctx, "WORKSPACE"): 72 | ctx.symlink("WORKSPACE", "WORKSPACE.bazel") 73 | 74 | for label, destinations in ctx.attr.build_files.items(): 75 | if type(destinations) != type([]): 76 | destinations = [destinations] 77 | for destination in destinations: 78 | ctx.symlink(label, destination) 79 | 80 | def _http_archve_impl(ctx): 81 | """Implementation of the git_repository rule.""" 82 | 83 | download_info = ctx.download_and_extract( 84 | ctx.attr.url, 85 | sha256 = ctx.attr.sha256, 86 | stripPrefix = ctx.attr.strip_prefix, 87 | ) 88 | 89 | _workspace_and_buildfiles(ctx) 90 | 91 | patch(ctx) 92 | 93 | return update_attrs(ctx.attr, _archive_attrs.keys(), {"sha256": download_info.sha256}) 94 | 95 | http_archive = repository_rule( 96 | implementation = _http_archve_impl, 97 | attrs = _archive_attrs, 98 | doc = 99 | """Custom rule to use a compressed tarball for creating an external workspace. 100 | It allows to inject multiple BUILD files. 101 | """, 102 | ) 103 | -------------------------------------------------------------------------------- /repos/config/detail/lock_repos.py: -------------------------------------------------------------------------------- 1 | #! /usr/bin/env python3 2 | # Copyright 2024 Apex.AI, Inc. 3 | # 4 | # Licensed under the Apache License, Version 2.0 (the "License"); 5 | # you may not use this file except in compliance with the License. 6 | # You may obtain a copy of the License at 7 | # 8 | # http://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | # See the License for the specific language governing permissions and 14 | # limitations under the License. 15 | 16 | 17 | import argparse 18 | import tempfile 19 | import yaml 20 | import subprocess 21 | import os 22 | import hashlib 23 | from pathlib import Path 24 | from generate_ros2_config import print_setup_file 25 | 26 | REPO_TYPES = ["git", "tar"] 27 | 28 | def main(): 29 | parser = argparse.ArgumentParser(description='Generate a Bazel setup file containing repo ' 30 | 'rules to load every repository for a given repos file.') 31 | parser.add_argument('repos', type=str, help='Input YAML *.repos file') 32 | parser.add_argument('setup_bzl', type=str, help='Output Bazel setup file with repo rules.') 33 | parser.add_argument('overlays', type=str, nargs='*', help='Additional YAML files are used as ' 34 | 'overlays for *.repos file, e.g., to declare BUILD files for a repo.') 35 | parser.add_argument('--tar', action='store_true', help='Use the GitHub archive download.') 36 | parser.add_argument('--workspace_name', type=str, help='Workspace name to use in the setup file.') 37 | 38 | args = parser.parse_args() 39 | print(f"Using {args.repos} to generate {args.setup_bzl}") 40 | 41 | with open(args.repos, "r") as repos_file: 42 | repos = yaml.safe_load(repos_file) 43 | 44 | if repos.get("repositories") is None: 45 | raise ValueError("No repositories attribute found") 46 | 47 | for repo, spec in repos["repositories"].items(): 48 | if not spec["type"] in REPO_TYPES: 49 | raise ValueError(f"Repo type {spec['type']} not supported. Need one of {REPO_TYPES} instead.") 50 | additional_attributes = fetch_dependency_details(use_tar = args.tar, **spec) 51 | add_attributes(repos["repositories"][repo], additional_attributes) 52 | print("{}: {}".format(repo, [*additional_attributes.values()])) 53 | 54 | with open(args.setup_bzl, mode='w', encoding='utf8') as setup_bzl: 55 | print_setup_file(repos = repos["repositories"], 56 | overlay_files=args.overlays, 57 | output_file=setup_bzl, 58 | repos_file = args.repos, 59 | use_tar=args.tar, 60 | workspace_name=args.workspace_name) 61 | 62 | 63 | def fetch_dependency_details(*, use_tar, type, **kwargs): 64 | if type == "tar" or use_tar: 65 | return fetch_http_details(type = type, **kwargs) 66 | return fetch_git_details(type = type, **kwargs) 67 | 68 | def add_attributes(dictionary, additional_attributes): 69 | for k,v in additional_attributes.items(): 70 | dictionary[k] = v 71 | 72 | def fetch_http_details(*, type, version = None, url = None, **kwargs): 73 | forward_type = "http_archive" 74 | if "sha256" in kwargs: 75 | return { "type": forward_type} 76 | with tempfile.TemporaryDirectory() as tempdir: 77 | archive_filename = Path(tempdir) / "archive.tar.gz" 78 | if type == "git": 79 | url = url.rsplit(".git", 1)[0] 80 | url += f"/archive/refs/tags/{version}.tar.gz" 81 | result = subprocess.run( 82 | ["curl", "-L", "-f", "-o", archive_filename, url], 83 | stdout=subprocess.PIPE, 84 | encoding='utf8' 85 | ) 86 | if result.returncode != 0: 87 | raise ValueError(f"Error loading {url}, {version}: " + (result.stderr or "")) 88 | 89 | archive_bytes = archive_filename.read_bytes() 90 | hash = hashlib.sha256(archive_bytes).hexdigest() 91 | strip_prefix = extract_archive_root_folder(archive_filename, url) 92 | 93 | return { 94 | "hash":hash, 95 | "url": url, 96 | "strip_prefix": strip_prefix, 97 | "type": forward_type, 98 | } 99 | 100 | def extract_archive_root_folder(path, origin): 101 | result = subprocess.run( 102 | ["tar", "-tf", path], 103 | capture_output = True, 104 | encoding='utf8' 105 | ) 106 | if result.returncode != 0: 107 | raise ValueError(f"Not able to read archive from {origin}: " + result.stderr) 108 | return result.stdout.split('\n')[0].split('/')[0] 109 | 110 | 111 | def fetch_git_details(url, version, **kwargs): 112 | cwd = os.getcwd() 113 | max_retries = 4 114 | for i in range(max_retries + 1): 115 | with tempfile.TemporaryDirectory() as tempdir: 116 | try: 117 | result = subprocess.run( 118 | ["git", "clone", url, "--no-checkout", tempdir, "--depth", "1", 119 | "--branch", version, "--bare", "-q"], 120 | capture_output = True, 121 | encoding='utf8', 122 | timeout=5 123 | ) 124 | if result.returncode != 0: 125 | if max_retries == i: 126 | raise ValueError(result.stderr) 127 | else: 128 | print(f"git clone returncode failure. Retrying attempt {i+1}/{max_retries}") 129 | continue 130 | os.chdir(tempdir) 131 | result = subprocess.run( 132 | ["git", "log", "--date=raw", "--format=format:%H/%cd"], 133 | stdout=subprocess.PIPE, 134 | encoding='utf8', 135 | timeout=5 136 | ) 137 | if result.returncode != 0: 138 | if max_retries == i: 139 | raise ValueError(result.stderr) 140 | else: 141 | print(f"git log returncode failure. Retrying attempt {i+1}/{max_retries}") 142 | continue 143 | except subprocess.TimeoutExpired as e: 144 | if max_retries == i: 145 | raise e 146 | else: 147 | print(f"subprocess.TimeoutExpired failure. Retrying attempt {i+1}/{max_retries}") 148 | continue 149 | 150 | commit_hash, time = result.stdout.split("/") 151 | os.chdir(cwd) 152 | break 153 | return { 154 | "hash":commit_hash, 155 | "shallow_since": time, 156 | } 157 | 158 | 159 | if __name__ == "__main__": 160 | main() 161 | -------------------------------------------------------------------------------- /repos/config/detail/new_local_repository.bzl: -------------------------------------------------------------------------------- 1 | # Copyright 2024 Apex.AI, Inc. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | load("@bazel_tools//tools/build_defs/repo:utils.bzl", "update_attrs") 16 | 17 | _archive_attrs = { 18 | "path": attr.string( 19 | doc = "Path to the repository.", 20 | ), 21 | "build_files": attr.label_keyed_string_dict( 22 | doc = """ 23 | Dict with a file as key and the path where to place the file in the repository as value. 24 | This allows to place multiple (BUILD) files in a repo. 25 | """, 26 | ), 27 | } 28 | 29 | def _execute_or_fail(ctx, args, **kwargs): 30 | result = ctx.execute(args, **kwargs) 31 | if result.return_code != 0: 32 | fail(result.stderr) 33 | return result 34 | 35 | def _file_exists(ctx, file_name): 36 | exec_result = ctx.execute(["ls", file_name]) 37 | if exec_result.return_code != 0: 38 | return False 39 | return True 40 | 41 | def _workspace_and_buildfiles(ctx): 42 | if not _file_exists(ctx, "WORKSPACE") and not _file_exists(ctx, "WORKSPACE.bazel"): 43 | ctx.file("WORKSPACE", content = 'workspace(name = "{}")'.format(ctx.name)) 44 | 45 | if not _file_exists(ctx, "WORKSPACE"): 46 | ctx.symlink("WORKSPACE", "WORKSPACE.bazel") 47 | 48 | for label, destinations in ctx.attr.build_files.items(): 49 | if type(destinations) != type([]): 50 | destinations = [destinations] 51 | for destination in destinations: 52 | ctx.symlink(label, destination) 53 | 54 | def _files_in_directory(ctx, directory_path): 55 | exec_result = ctx.execute(["find", directory_path, "-maxdepth", "1", "-mindepth", "1"]) 56 | if exec_result.return_code != 0: 57 | fail(exec_result.stderr) 58 | 59 | return exec_result.stdout.splitlines() 60 | 61 | def _new_local_repository_impl(ctx): 62 | """Implementation of the git_repository rule.""" 63 | 64 | for f in _files_in_directory(ctx, ctx.attr.path): 65 | _execute_or_fail(ctx, ["cp", "-r", f, f.rpartition("/")[2]]) 66 | 67 | _workspace_and_buildfiles(ctx) 68 | 69 | return update_attrs(ctx.attr, _archive_attrs.keys(), {}) 70 | 71 | new_local_repository = repository_rule( 72 | implementation = _new_local_repository_impl, 73 | attrs = _archive_attrs, 74 | doc = 75 | """Custom rule to clone a git repo as external dependency. 76 | It allows to inject multiple BUILD files. 77 | """, 78 | ) 79 | -------------------------------------------------------------------------------- /repos/config/detail/ros2_config.bzl: -------------------------------------------------------------------------------- 1 | # Copyright 2024 Apex.AI, Inc. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | load("@bazel_tools//tools/build_defs/repo:utils.bzl", "update_attrs") 16 | 17 | _archive_attrs = { 18 | "repos_index": attr.label( 19 | doc = "YAML file containing the details of every ros2 repository.", 20 | ), 21 | "repos_index_overlays": attr.label_list( 22 | default = [], 23 | doc = """ 24 | Additional YAML files used as overlays for `repo_index` e.g. to declare BUILD files 25 | for a repo. 26 | """, 27 | ), 28 | "setup_file": attr.label( 29 | doc = "Resulting .bzl file containing repo rules to load every ros2 repository.", 30 | ), 31 | } 32 | 33 | BUILD_FILE_CONTENT = """\ 34 | load("@rules_ros//repos/config/detail:generate_repos_lock.bzl", "repos_lock_updater") 35 | 36 | repos_lock_updater( 37 | name = "repos_lock.update", 38 | repos_file = "ros.repos", 39 | setup_file = "setup.bzl", 40 | overlay_files = [ 41 | {overlays} 42 | ], 43 | ) 44 | 45 | exports_files(glob(["**/*"])) 46 | """ 47 | 48 | def _ros2_config_impl(ctx): 49 | ctx.symlink(ctx.attr.repos_index, "ros.repos") 50 | ctx.symlink(ctx.attr.setup_file, "setup.bzl") 51 | overlay_files = [] 52 | for i, file in enumerate(ctx.attr.repos_index_overlays): 53 | filename = "overlay_{}.bzl".format(i) 54 | ctx.symlink(file, filename) 55 | overlay_files.append(filename) 56 | ctx.file( 57 | "WORKSPACE", 58 | content = "workspace(name = {})".format(ctx.name), 59 | executable = False, 60 | ) 61 | ctx.file( 62 | "BUILD.bazel", 63 | content = BUILD_FILE_CONTENT.format( 64 | overlays = "\n".join([' "{}",'.format(filename) for filename in overlay_files]), 65 | workspace_name = ctx.name, 66 | ), 67 | executable = False, 68 | ) 69 | 70 | return update_attrs(ctx.attr, _archive_attrs.keys(), {}) 71 | 72 | ros2_config = repository_rule( 73 | implementation = _ros2_config_impl, 74 | attrs = _archive_attrs, 75 | ) 76 | -------------------------------------------------------------------------------- /repos/config/detail/test/test_repos_index_sha256.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | REPOS_INDEX_FILE="$1" 4 | REPOS_SETUP_FILE="$2" 5 | 6 | REPOS_SETUP_FILE_SHA256=$(grep "SHA256" "${REPOS_SETUP_FILE}" | cut -f 5 -d ' ') 7 | 8 | if [[ -z "${REPOS_SETUP_FILE_SHA256}" ]]; then 9 | echo "${REPOS_SETUP_FILE} DOES NOT HAVE A SHA256 COMMENT. TERMINATING" 10 | exit -1 11 | elif [[ "${REPOS_SETUP_FILE_SHA256}" =~ ^[a-f0-9]{65}$ ]]; then 12 | echo "${REPOS_SETUP_FILE} INVALID SHA256 COMMENT of ${REPOS_SETUP_FILE_SHA256}. TERMINATING" 13 | exit -1 14 | fi 15 | 16 | REPOS_INDEX_FILE_SHA256=$(sha256sum "${REPOS_INDEX_FILE}" | cut -f 1 -d ' ') 17 | 18 | if [ "${REPOS_INDEX_FILE_SHA256}" != "${REPOS_SETUP_FILE_SHA256}" ]; then 19 | echo "SHA256 MISMATCH. RUN 'bazel run @rules_ros//repos/config:repos_lock.update' THEN TRY AGAIN" 20 | exit -1 21 | fi 22 | 23 | exit 0 -------------------------------------------------------------------------------- /repos/config/distros.bzl: -------------------------------------------------------------------------------- 1 | load("@bazel_tools//tools/build_defs/repo:git.bzl", "new_git_repository") 2 | load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") 3 | 4 | ROS_PROJECT = "https://github.com/ros2/ros2.git" 5 | 6 | _VERSIONS = [ 7 | ("iron", "20230912", "fd40b4d80eb9c27f57b2b59ad8a947cd5f7f34fc67c8df1d7cc0a659127fc9f7"), 8 | ("humble", "20230925", "57495eab51338591a0117b6763827607808e26344d134d6666ded66e479bdf8b"), 9 | ("galactic", "20221209", "fd251be0e1d16c1f943a8f083dce7b75c60fc2095404c5834209a68846be48c7"), 10 | ("foxy", "20230620", "2cf7e3f9c5b01b7de2ec3c80097837758f3554e4f5c99a2aeca2bd7f4eb0bc1f"), 11 | ("eloquent", "2020-1212", "76f4b08bc4ecc6b126d2bdf5e8b86fa3d4b6d5101c122f7d0fd973aa77ef819a"), 12 | ("dashing", "20210610", "f0e00b81e93f764bef7591b0d9e3b89d73660696764663f18f926cd9795028c9"), 13 | ] 14 | 15 | _URL_TEMPLATE = "https://github.com/ros2/ros2/archive/refs/tags/release-{}-{}.tar.gz" 16 | _STRIP_PREFIX_TEMPLATE = "ros2-release-{}-{}" 17 | 18 | DISTROS = { 19 | distro: dict( 20 | repo_rule = http_archive, 21 | url = _URL_TEMPLATE.format(distro, date), 22 | strip_prefix = _STRIP_PREFIX_TEMPLATE.format(distro, date), 23 | sha256 = sha, 24 | setup_file = "@rules_ros//repos/config:setup_{}.lock.bzl".format(distro), 25 | ) 26 | for distro, date, sha in _VERSIONS 27 | } 28 | -------------------------------------------------------------------------------- /repos/config/setup_dashing.lock.bzl: -------------------------------------------------------------------------------- 1 | # 2 | # DO NOT EDIT THIS FILE MANUALLY! 3 | # 4 | # To update, call `bazel run @rules_ros//repos/config:repos_lock.update` with the right distro set in the WORKSPACE 5 | # 6 | # SHA256 of external/ros2/ros2.repos: da16d26ba1c05ea20cedf2f01250ed859ee255565053dd9650c831ff80e1f6ea 7 | 8 | load("@bazel_tools//tools/build_defs/repo:utils.bzl", _maybe = "maybe") 9 | load("@rules_ros//repos/config/detail:git_repository.bzl", "git_repository") 10 | load("@rules_ros//repos/config/detail:http_archive.bzl", "http_archive") 11 | load("@rules_ros//repos/config/detail:new_local_repository.bzl", "new_local_repository") 12 | 13 | def setup(): 14 | pass 15 | 16 | _maybe( 17 | name = "ament.ament_index", 18 | branch = "0.7.2", 19 | build_files = { 20 | "@rules_ros//repos:ament.ament_index/ament_index_cpp.BUILD": "ament_index_cpp/BUILD.bazel", 21 | "@rules_ros//repos:ament.ament_index/ament_index_python.BUILD": "ament_index_python/BUILD.bazel", 22 | }, 23 | commit = "9d42ba13d7694ad8da5b1622e433e691996c4502", 24 | remote = "https://github.com/ament/ament_index.git", 25 | repo_rule = git_repository, 26 | shallow_since = "1571244457 -0700", 27 | ) 28 | 29 | _maybe( 30 | name = "eclipse-cyclonedds.cyclonedds", 31 | branch = "0.7.0", 32 | build_files = { 33 | "@rules_ros//repos:default.BUILD": "BUILD.bazel", 34 | }, 35 | commit = "c261053186c455abc63ca5ac7d56c0808a59c364", 36 | remote = "https://github.com/eclipse-cyclonedds/cyclonedds.git", 37 | repo_rule = git_repository, 38 | shallow_since = "1596471565 +0200", 39 | ) 40 | 41 | _maybe( 42 | name = "eProsima.Fast-CDR", 43 | branch = "v1.0.13", 44 | build_files = { 45 | "@rules_ros//repos:default.BUILD": "BUILD.bazel", 46 | }, 47 | commit = "174f6ff1d3a227c5c900a4587ee32fa888267f5e", 48 | remote = "https://github.com/eProsima/Fast-CDR.git", 49 | repo_rule = git_repository, 50 | shallow_since = "1585310200 +0100", 51 | ) 52 | 53 | _maybe( 54 | name = "ros2.common_interfaces", 55 | branch = "0.7.1", 56 | build_files = { 57 | "@rules_ros//repos:ros2.common_interfaces/std_msgs.BUILD": "std_msgs/BUILD.bazel", 58 | }, 59 | commit = "30dbc60b45e22f2c88a4c46493388fdad3916845", 60 | remote = "https://github.com/ros2/common_interfaces.git", 61 | repo_rule = git_repository, 62 | shallow_since = "1621610616 -0700", 63 | ) 64 | 65 | _maybe( 66 | name = "ros2.rcl", 67 | branch = "0.7.10", 68 | build_files = { 69 | "@rules_ros//repos:ros2.rcl/rcl.BUILD": "rcl/BUILD.bazel", 70 | "@rules_ros//repos:ros2.rcl/rcl_yaml_param_parser.BUILD": "rcl_yaml_param_parser/BUILD.bazel", 71 | }, 72 | commit = "f28fd0d5ee8e13a4955dbe84bd336eeee7e2be5d", 73 | remote = "https://github.com/ros2/rcl.git", 74 | repo_rule = git_repository, 75 | shallow_since = "1621608437 -0700", 76 | ) 77 | 78 | _maybe( 79 | name = "ros2.rcl_interfaces", 80 | branch = "0.7.4", 81 | build_files = { 82 | "@rules_ros//repos:ros2.rcl_interfaces/rcl_interfaces.BUILD": "rcl_interfaces/BUILD.bazel", 83 | "@rules_ros//repos:ros2.rcl_interfaces/rosgraph_msgs.BUILD": "rosgraph_msgs/BUILD.bazel", 84 | "@rules_ros//repos:ros2.rcl_interfaces/builtin_interfaces.BUILD": "builtin_interfaces/BUILD.bazel", 85 | "@rules_ros//repos:ros2.rcl_interfaces/statistics_msgs.BUILD": "statistics_msgs/BUILD.bazel", 86 | }, 87 | commit = "bfa9c43dd7d8cfc5c6fcba8a164d8ef317a386d7", 88 | remote = "https://github.com/ros2/rcl_interfaces.git", 89 | repo_rule = git_repository, 90 | shallow_since = "1559174983 -0700", 91 | ) 92 | 93 | _maybe( 94 | name = "ros2.rcl_logging", 95 | branch = "0.2.1", 96 | build_files = { 97 | "@rules_ros//repos:ros2.rcl_logging/rcl_logging_interface.BUILD": "rcl_logging_interface/BUILD.bazel", 98 | }, 99 | commit = "6b1880038fed2893557c931a202c16b974637e42", 100 | remote = "https://github.com/ros2/rcl_logging.git", 101 | repo_rule = git_repository, 102 | shallow_since = "1557360130 -0500", 103 | ) 104 | 105 | _maybe( 106 | name = "ros2.rclcpp", 107 | branch = "0.7.16", 108 | build_files = { 109 | "@rules_ros//repos:ros2.rclcpp/build_interfaces.py": "rclcpp/build_interfaces.py", 110 | "@rules_ros//repos:ros2.rclcpp/rclcpp.BUILD": "rclcpp/BUILD.bazel", 111 | }, 112 | commit = "403aac966271132feadffca93dcfb24f6ab90efb", 113 | remote = "https://github.com/ros2/rclcpp.git", 114 | repo_rule = git_repository, 115 | shallow_since = "1621608557 -0700", 116 | ) 117 | 118 | _maybe( 119 | name = "ros2.rcpputils", 120 | branch = "0.1.1", 121 | build_files = { 122 | "@rules_ros//repos:ros2.rcpputils/rcpputils.BUILD": "BUILD.bazel", 123 | }, 124 | commit = "f8e638eb72bfbacea18ca1cf67c4f7d48561d9b2", 125 | remote = "https://github.com/ros2/rcpputils.git", 126 | repo_rule = git_repository, 127 | shallow_since = "1564532092 -0700", 128 | ) 129 | 130 | _maybe( 131 | name = "ros2.rcutils", 132 | branch = "0.7.6", 133 | build_files = { 134 | "@rules_ros//repos:ros2.rcutils/root.BUILD": "BUILD.bazel", 135 | "@rules_ros//repos:ros2.rcutils/build_logging_macros.py": "build_logging_macros.py", 136 | }, 137 | commit = "f868e5cb0eaeb9ae9fc984f6783922f375411007", 138 | remote = "https://github.com/ros2/rcutils.git", 139 | repo_rule = git_repository, 140 | shallow_since = "1606260966 -0800", 141 | ) 142 | 143 | _maybe( 144 | name = "ros2.rmw", 145 | branch = "0.7.2", 146 | build_files = { 147 | "@rules_ros//repos:ros2.rmw/rmw.BUILD": "rmw/BUILD.bazel", 148 | }, 149 | commit = "8652949435267cdf0fd65368f621146dea9a85eb", 150 | remote = "https://github.com/ros2/rmw.git", 151 | repo_rule = git_repository, 152 | shallow_since = "1560370615 +0000", 153 | ) 154 | 155 | _maybe( 156 | name = "ros2.ros2cli", 157 | branch = "0.7.11", 158 | build_files = { 159 | "@rules_ros//repos:ros2.ros2cli/ros2cli.BUILD": "ros2cli/BUILD.bazel", 160 | "@rules_ros//repos:ros2.ros2cli/ros2pkg.BUILD": "ros2pkg/BUILD.bazel", 161 | "@rules_ros//repos:ros2.ros2cli/ros2run.BUILD": "ros2run/BUILD.bazel", 162 | }, 163 | commit = "8ff79e6cfc88a8d973c854a6709404eed6db47e0", 164 | remote = "https://github.com/ros2/ros2cli.git", 165 | repo_rule = git_repository, 166 | shallow_since = "1594441053 -0400", 167 | ) 168 | 169 | _maybe( 170 | name = "ros2.rosidl", 171 | branch = "0.7.10", 172 | build_files = { 173 | "@rules_ros//repos:ros2.rosidl/rosidl_runtime_c.BUILD": "rosidl_runtime_c/BUILD.bazel", 174 | "@rules_ros//repos:ros2.rosidl/rosidl_runtime_cpp.BUILD": "rosidl_runtime_cpp/BUILD.bazel", 175 | "@rules_ros//repos:ros2.rosidl/rosidl_adapter.BUILD": "rosidl_adapter/BUILD.bazel", 176 | "@rules_ros//repos:ros2.rosidl/rosidl_cli.BUILD": "rosidl_cli/BUILD.bazel", 177 | "@rules_ros//repos:ros2.rosidl/rosidl_parser.BUILD": "rosidl_parser/BUILD.bazel", 178 | "@rules_ros//repos:ros2.rosidl/rosidl_cmake.BUILD": "rosidl_cmake/BUILD.bazel", 179 | "@rules_ros//repos:ros2.rosidl/rosidl_typesupport_interface.BUILD": "rosidl_typesupport_interface/BUILD.bazel", 180 | "@rules_ros//repos:ros2.rosidl/rosidl_generator_c.BUILD": "rosidl_generator_c/BUILD.bazel", 181 | "@rules_ros//repos:ros2.rosidl/rosidl_generator_cpp.BUILD": "rosidl_generator_cpp/BUILD.bazel", 182 | }, 183 | commit = "407b652ac8ca23beea2f1f24575dd57f0c9b4401", 184 | remote = "https://github.com/ros2/rosidl.git", 185 | repo_rule = git_repository, 186 | shallow_since = "1606259638 -0800", 187 | ) 188 | 189 | _maybe( 190 | name = "ros2.rosidl_dds", 191 | branch = "0.7.1", 192 | build_files = { 193 | "@rules_ros//repos:ros2.rosidl_dds/rosidl_generator_dds_idl.BUILD": "rosidl_generator_dds_idl/BUILD.bazel", 194 | }, 195 | commit = "e88b1d0e62a2dca0788142cf1fb266a3a3c3d7dc", 196 | remote = "https://github.com/ros2/rosidl_dds.git", 197 | repo_rule = git_repository, 198 | shallow_since = "1557357026 -0500", 199 | ) 200 | 201 | _maybe( 202 | name = "ros2.rosidl_typesupport", 203 | branch = "0.7.1", 204 | build_files = { 205 | "@rules_ros//repos:ros2.rosidl_typesupport/rosidl_typesupport_c.BUILD": "rosidl_typesupport_c/BUILD.bazel", 206 | }, 207 | commit = "38eb801f1f856a503676bb79875786b3a3b6d92d", 208 | remote = "https://github.com/ros2/rosidl_typesupport.git", 209 | repo_rule = git_repository, 210 | shallow_since = "1557357026 -0700", 211 | ) 212 | 213 | print("WARNING: Unknown repo type None for repo @eProsima.Fast-DDS") 214 | 215 | print("WARNING: Unknown repo type None for repo @eProsima.foonathan_memory_vendor") 216 | 217 | print("WARNING: Unknown repo type None for repo @eclipse-iceoryx.iceoryx") 218 | 219 | print("WARNING: Unknown repo type None for repo @ros-tooling.libstatistics_collector") 220 | 221 | print("WARNING: Unknown repo type None for repo @ros2.ros2_tracing") 222 | -------------------------------------------------------------------------------- /repos/config/setup_eloquent.lock.bzl: -------------------------------------------------------------------------------- 1 | # 2 | # DO NOT EDIT THIS FILE MANUALLY! 3 | # 4 | # To update, call `bazel run @rules_ros//repos/config:repos_lock.update` with the right distro set in the WORKSPACE 5 | # 6 | # SHA256 of external/ros2/ros2.repos: 71922db335c9a2092fb095e66b1e860f9713854bf704e0e00dc5910f7ec111a8 7 | 8 | load("@bazel_tools//tools/build_defs/repo:utils.bzl", _maybe = "maybe") 9 | load("@rules_ros//repos/config/detail:git_repository.bzl", "git_repository") 10 | load("@rules_ros//repos/config/detail:http_archive.bzl", "http_archive") 11 | load("@rules_ros//repos/config/detail:new_local_repository.bzl", "new_local_repository") 12 | 13 | def setup(): 14 | pass 15 | 16 | _maybe( 17 | name = "ament.ament_index", 18 | branch = "0.7.2", 19 | build_files = { 20 | "@rules_ros//repos:ament.ament_index/ament_index_cpp.BUILD": "ament_index_cpp/BUILD.bazel", 21 | "@rules_ros//repos:ament.ament_index/ament_index_python.BUILD": "ament_index_python/BUILD.bazel", 22 | }, 23 | commit = "9d42ba13d7694ad8da5b1622e433e691996c4502", 24 | remote = "https://github.com/ament/ament_index.git", 25 | repo_rule = git_repository, 26 | shallow_since = "1571244457 -0700", 27 | ) 28 | 29 | _maybe( 30 | name = "eclipse-cyclonedds.cyclonedds", 31 | branch = "0.7.0", 32 | build_files = { 33 | "@rules_ros//repos:default.BUILD": "BUILD.bazel", 34 | }, 35 | commit = "c261053186c455abc63ca5ac7d56c0808a59c364", 36 | remote = "https://github.com/eclipse-cyclonedds/cyclonedds.git", 37 | repo_rule = git_repository, 38 | shallow_since = "1596471565 +0200", 39 | ) 40 | 41 | _maybe( 42 | name = "eProsima.Fast-CDR", 43 | branch = "v1.0.11", 44 | build_files = { 45 | "@rules_ros//repos:default.BUILD": "BUILD.bazel", 46 | }, 47 | commit = "cc27c2490b694e97ca1bbcc169172fd63209bb90", 48 | remote = "https://github.com/eProsima/Fast-CDR.git", 49 | repo_rule = git_repository, 50 | shallow_since = "1566903518 +0200", 51 | ) 52 | 53 | _maybe( 54 | name = "eProsima.Fast-DDS", 55 | branch = "v1.9.3", 56 | build_files = { 57 | "@rules_ros//repos:default.BUILD": "BUILD.bazel", 58 | }, 59 | commit = "b5ae9e9c9ea7ce49c64c0ef3f6c96a3dc563b16f", 60 | remote = "https://github.com/eProsima/Fast-DDS.git", 61 | repo_rule = git_repository, 62 | shallow_since = "1573725955 +0100", 63 | ) 64 | 65 | _maybe( 66 | name = "eProsima.foonathan_memory_vendor", 67 | branch = "v0.3.0", 68 | build_files = { 69 | "@rules_ros//repos:default.BUILD": "BUILD.bazel", 70 | }, 71 | commit = "017ff0bdfd2c93930bf525a01f8663a032337a14", 72 | remote = "https://github.com/eProsima/foonathan_memory_vendor.git", 73 | repo_rule = git_repository, 74 | shallow_since = "1569302929 +0200", 75 | ) 76 | 77 | _maybe( 78 | name = "ros2.common_interfaces", 79 | branch = "0.8.1", 80 | build_files = { 81 | "@rules_ros//repos:ros2.common_interfaces/std_msgs.BUILD": "std_msgs/BUILD.bazel", 82 | }, 83 | commit = "81663c07b93889c3d0afda9b99cd5f1c7c98c1f2", 84 | remote = "https://github.com/ros2/common_interfaces.git", 85 | repo_rule = git_repository, 86 | shallow_since = "1571867898 -0700", 87 | ) 88 | 89 | _maybe( 90 | name = "ros2.rcl", 91 | branch = "0.8.5", 92 | build_files = { 93 | "@rules_ros//repos:ros2.rcl/rcl.BUILD": "rcl/BUILD.bazel", 94 | "@rules_ros//repos:ros2.rcl/rcl_yaml_param_parser.BUILD": "rcl_yaml_param_parser/BUILD.bazel", 95 | }, 96 | commit = "f5c01e4e2eb5d8f7fb16321f81815cd4b6b200bd", 97 | remote = "https://github.com/ros2/rcl.git", 98 | repo_rule = git_repository, 99 | shallow_since = "1607116198 -0600", 100 | ) 101 | 102 | _maybe( 103 | name = "ros2.rcl_interfaces", 104 | branch = "0.8.0", 105 | build_files = { 106 | "@rules_ros//repos:ros2.rcl_interfaces/rcl_interfaces.BUILD": "rcl_interfaces/BUILD.bazel", 107 | "@rules_ros//repos:ros2.rcl_interfaces/rosgraph_msgs.BUILD": "rosgraph_msgs/BUILD.bazel", 108 | "@rules_ros//repos:ros2.rcl_interfaces/builtin_interfaces.BUILD": "builtin_interfaces/BUILD.bazel", 109 | "@rules_ros//repos:ros2.rcl_interfaces/statistics_msgs.BUILD": "statistics_msgs/BUILD.bazel", 110 | }, 111 | commit = "93cedce2dacd25fa4f2969d022ccbe3f2903e3fe", 112 | remote = "https://github.com/ros2/rcl_interfaces.git", 113 | repo_rule = git_repository, 114 | shallow_since = "1569518728 -0500", 115 | ) 116 | 117 | _maybe( 118 | name = "ros2.rcl_logging", 119 | branch = "0.3.3", 120 | build_files = { 121 | "@rules_ros//repos:ros2.rcl_logging/rcl_logging_interface.BUILD": "rcl_logging_interface/BUILD.bazel", 122 | }, 123 | commit = "3955fc4fc37e46dc397c52cebd3e40732db1157d", 124 | remote = "https://github.com/ros2/rcl_logging.git", 125 | repo_rule = git_repository, 126 | shallow_since = "1571871211 +0000", 127 | ) 128 | 129 | _maybe( 130 | name = "ros2.rclcpp", 131 | branch = "0.8.5", 132 | build_files = { 133 | "@rules_ros//repos:ros2.rclcpp/build_interfaces.py": "rclcpp/build_interfaces.py", 134 | "@rules_ros//repos:ros2.rclcpp/rclcpp.BUILD": "rclcpp/BUILD.bazel", 135 | }, 136 | commit = "82202ae71f14fed3a487da90d8f4f74c07c7d1f7", 137 | remote = "https://github.com/ros2/rclcpp.git", 138 | repo_rule = git_repository, 139 | shallow_since = "1607116009 -0600", 140 | ) 141 | 142 | _maybe( 143 | name = "ros2.rcpputils", 144 | branch = "0.2.1", 145 | build_files = { 146 | "@rules_ros//repos:ros2.rcpputils/rcpputils.BUILD": "BUILD.bazel", 147 | }, 148 | commit = "33e2edb1dafd9dc1952e7f219c9ceee58905b831", 149 | remote = "https://github.com/ros2/rcpputils.git", 150 | repo_rule = git_repository, 151 | shallow_since = "1573612278 -0800", 152 | ) 153 | 154 | _maybe( 155 | name = "ros2.rcutils", 156 | branch = "0.8.5", 157 | build_files = { 158 | "@rules_ros//repos:ros2.rcutils/root.BUILD": "BUILD.bazel", 159 | "@rules_ros//repos:ros2.rcutils/build_logging_macros.py": "build_logging_macros.py", 160 | }, 161 | commit = "ef201364d5af13f74a9c368f271c762326d838be", 162 | remote = "https://github.com/ros2/rcutils.git", 163 | repo_rule = git_repository, 164 | shallow_since = "1607117730 -0600", 165 | ) 166 | 167 | _maybe( 168 | name = "ros2.rmw", 169 | branch = "0.8.1", 170 | build_files = { 171 | "@rules_ros//repos:ros2.rmw/rmw.BUILD": "rmw/BUILD.bazel", 172 | }, 173 | commit = "813b94ddd5650444b312304ad156f3b5d9f05e39", 174 | remote = "https://github.com/ros2/rmw.git", 175 | repo_rule = git_repository, 176 | shallow_since = "1571879357 -0700", 177 | ) 178 | 179 | _maybe( 180 | name = "ros2.ros2cli", 181 | branch = "0.8.8", 182 | build_files = { 183 | "@rules_ros//repos:ros2.ros2cli/ros2cli.BUILD": "ros2cli/BUILD.bazel", 184 | "@rules_ros//repos:ros2.ros2cli/ros2pkg.BUILD": "ros2pkg/BUILD.bazel", 185 | "@rules_ros//repos:ros2.ros2cli/ros2run.BUILD": "ros2run/BUILD.bazel", 186 | }, 187 | commit = "5d5b855369085d02631bc5bdd6ffb7fae680eb5b", 188 | remote = "https://github.com/ros2/ros2cli.git", 189 | repo_rule = git_repository, 190 | shallow_since = "1607117614 -0600", 191 | ) 192 | 193 | _maybe( 194 | name = "ros2.rosidl", 195 | branch = "0.8.3", 196 | build_files = { 197 | "@rules_ros//repos:ros2.rosidl/rosidl_runtime_c.BUILD": "rosidl_runtime_c/BUILD.bazel", 198 | "@rules_ros//repos:ros2.rosidl/rosidl_runtime_cpp.BUILD": "rosidl_runtime_cpp/BUILD.bazel", 199 | "@rules_ros//repos:ros2.rosidl/rosidl_adapter.BUILD": "rosidl_adapter/BUILD.bazel", 200 | "@rules_ros//repos:ros2.rosidl/rosidl_cli.BUILD": "rosidl_cli/BUILD.bazel", 201 | "@rules_ros//repos:ros2.rosidl/rosidl_parser.BUILD": "rosidl_parser/BUILD.bazel", 202 | "@rules_ros//repos:ros2.rosidl/rosidl_cmake.BUILD": "rosidl_cmake/BUILD.bazel", 203 | "@rules_ros//repos:ros2.rosidl/rosidl_typesupport_interface.BUILD": "rosidl_typesupport_interface/BUILD.bazel", 204 | "@rules_ros//repos:ros2.rosidl/rosidl_generator_c.BUILD": "rosidl_generator_c/BUILD.bazel", 205 | "@rules_ros//repos:ros2.rosidl/rosidl_generator_cpp.BUILD": "rosidl_generator_cpp/BUILD.bazel", 206 | }, 207 | commit = "5f79cdcb7830999b527c2370b4397a3cc587374a", 208 | remote = "https://github.com/ros2/rosidl.git", 209 | repo_rule = git_repository, 210 | shallow_since = "1607117948 -0600", 211 | ) 212 | 213 | _maybe( 214 | name = "ros2.rosidl_dds", 215 | branch = "0.7.1", 216 | build_files = { 217 | "@rules_ros//repos:ros2.rosidl_dds/rosidl_generator_dds_idl.BUILD": "rosidl_generator_dds_idl/BUILD.bazel", 218 | }, 219 | commit = "e88b1d0e62a2dca0788142cf1fb266a3a3c3d7dc", 220 | remote = "https://github.com/ros2/rosidl_dds.git", 221 | repo_rule = git_repository, 222 | shallow_since = "1557357026 -0500", 223 | ) 224 | 225 | _maybe( 226 | name = "ros2.rosidl_typesupport", 227 | branch = "0.8.1", 228 | build_files = { 229 | "@rules_ros//repos:ros2.rosidl_typesupport/rosidl_typesupport_c.BUILD": "rosidl_typesupport_c/BUILD.bazel", 230 | }, 231 | commit = "b51759ea94bfdc58afc8831d4c847c5891d14bc3", 232 | remote = "https://github.com/ros2/rosidl_typesupport.git", 233 | repo_rule = git_repository, 234 | shallow_since = "1607118075 -0600", 235 | ) 236 | 237 | print("WARNING: Unknown repo type None for repo @eclipse-iceoryx.iceoryx") 238 | 239 | print("WARNING: Unknown repo type None for repo @ros-tooling.libstatistics_collector") 240 | 241 | print("WARNING: Unknown repo type None for repo @ros2.ros2_tracing") 242 | -------------------------------------------------------------------------------- /repos/default.BUILD: -------------------------------------------------------------------------------- 1 | exports_files(glob(["**/*"])) 2 | -------------------------------------------------------------------------------- /repos/ros-tooling.libstatistics_collector/root.BUILD: -------------------------------------------------------------------------------- 1 | # Copyright 2024 Apex.AI, Inc. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | load("@bazel_skylib//rules:expand_template.bzl","expand_template") 16 | 17 | cc_library( 18 | name = "libstatistics_collector", 19 | srcs = glob([ 20 | "src/**/*.c", 21 | "src/**/*.cpp", 22 | ]), 23 | hdrs = glob([ 24 | "include/**/*.h", 25 | "include/**/*.hpp", 26 | ]), 27 | strip_include_prefix = "include", 28 | deps = [ 29 | "@ros2.rcl_interfaces//builtin_interfaces", 30 | "@ros2.rcpputils//:rcpputils", 31 | "@ros2.rcl_interfaces//statistics_msgs", 32 | ], 33 | visibility = ["//visibility:public"], 34 | ) 35 | -------------------------------------------------------------------------------- /repos/ros2.common_interfaces/std_msgs.BUILD: -------------------------------------------------------------------------------- 1 | # Copyright 2024 Apex.AI, Inc. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | load("@rules_ros//rosidl:defs.bzl", "msgs_library") 16 | 17 | msgs_library( 18 | name = "std_msgs", 19 | srcs = glob([ 20 | "msg/*.idl", 21 | "msg/*.msg", 22 | "srv/*.srv", 23 | ]), 24 | visibility = ["//visibility:public"], 25 | deps = [ 26 | "@ros2.rcl_interfaces//builtin_interfaces", 27 | ], 28 | ) 29 | 30 | -------------------------------------------------------------------------------- /repos/ros2.rcl/rcl.BUILD: -------------------------------------------------------------------------------- 1 | # Copyright 2024 Apex.AI, Inc. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | cc_library( 16 | name = "rcl", 17 | srcs = glob([ 18 | "src/**/*.c", 19 | "src/**/*.h", 20 | ]), 21 | hdrs = glob(["include/**/*.h"]), 22 | strip_include_prefix = "include", 23 | deps = [ 24 | "@ros2.rcutils//:rcutils", 25 | "@ros2.rmw//rmw", 26 | "@ros2.rosidl//rosidl_runtime_c", 27 | "@ros2.ros2_tracing//tracetools", 28 | "//rcl_yaml_param_parser", 29 | "@ros2.rcl_logging//rcl_logging_interface", 30 | "@ros2.rcl_interfaces//rcl_interfaces", 31 | ], 32 | local_defines = ["ROS_PACKAGE_NAME=\\\"rcl\\\""], 33 | visibility = ["//visibility:public"], 34 | ) 35 | 36 | -------------------------------------------------------------------------------- /repos/ros2.rcl/rcl_yaml_param_parser.BUILD: -------------------------------------------------------------------------------- 1 | # Copyright 2024 Apex.AI, Inc. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | cc_library( 16 | name = "rcl_yaml_param_parser", 17 | srcs = glob(["src/**/*.c"]), 18 | hdrs = glob(["include/**/*.h"]), 19 | strip_include_prefix = "include", 20 | deps = [ 21 | ":internal_headers", 22 | "@ros2.rcutils//:rcutils", 23 | "@libyaml//:libyaml", 24 | "@ros2.rmw//rmw", 25 | ], 26 | visibility = ["//visibility:public"], 27 | ) 28 | 29 | cc_library( 30 | name = "internal_headers", 31 | hdrs = glob(["src/**/*.h"]), 32 | strip_include_prefix = "src", 33 | ) 34 | -------------------------------------------------------------------------------- /repos/ros2.rcl_interfaces/builtin_interfaces.BUILD: -------------------------------------------------------------------------------- 1 | # Copyright 2024 Apex.AI, Inc. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | load("@rules_ros//rosidl:defs.bzl", "msgs_library") 16 | 17 | msgs_library( 18 | name = "builtin_interfaces", 19 | srcs = glob([ 20 | "msg/*.msg", 21 | "msg/*.idl", 22 | "srv/*.srv", 23 | ]), 24 | visibility = ["//visibility:public"], 25 | ) 26 | -------------------------------------------------------------------------------- /repos/ros2.rcl_interfaces/rcl_interfaces.BUILD: -------------------------------------------------------------------------------- 1 | # Copyright 2024 Apex.AI, Inc. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | load("@rules_ros//rosidl:defs.bzl", "msgs_library") 16 | 17 | msgs_library( 18 | name = "rcl_interfaces", 19 | srcs = glob([ 20 | "msg/*.msg", 21 | "msg/*.idl", 22 | "srv/*.srv", 23 | ]), 24 | visibility = ["//visibility:public"], 25 | deps = [ 26 | "//builtin_interfaces", 27 | ], 28 | ) 29 | -------------------------------------------------------------------------------- /repos/ros2.rcl_interfaces/rosgraph_msgs.BUILD: -------------------------------------------------------------------------------- 1 | # Copyright 2024 Apex.AI, Inc. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | load("@rules_ros//rosidl:defs.bzl", "msgs_library") 16 | 17 | msgs_library( 18 | name = "rosgraph_msgs", 19 | srcs = glob([ 20 | "msg/*.msg", 21 | "msg/*.idl", 22 | "srv/*.srv", 23 | ]), 24 | visibility = ["//visibility:public"], 25 | deps = [ 26 | "//builtin_interfaces", 27 | ], 28 | ) 29 | -------------------------------------------------------------------------------- /repos/ros2.rcl_interfaces/statistics_msgs.BUILD: -------------------------------------------------------------------------------- 1 | # Copyright 2024 Apex.AI, Inc. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | load("@rules_ros//rosidl:defs.bzl", "msgs_library") 16 | 17 | msgs_library( 18 | name = "statistics_msgs", 19 | srcs = glob([ 20 | "msg/*.msg", 21 | "msg/*.idl", 22 | "srv/*.srv", 23 | ]), 24 | visibility = ["//visibility:public"], 25 | deps = [ 26 | "//builtin_interfaces", 27 | ], 28 | ) 29 | -------------------------------------------------------------------------------- /repos/ros2.rcl_logging/rcl_logging_interface.BUILD: -------------------------------------------------------------------------------- 1 | # Copyright 2024 Apex.AI, Inc. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | cc_library( 16 | name = "rcl_logging_interface", 17 | srcs = glob(["src/**/*.c"]), 18 | hdrs = glob(["include/**/*.h"]), 19 | strip_include_prefix = "include", 20 | deps = ["@ros2.rcutils//:rcutils"], 21 | visibility = ["//visibility:public"], 22 | ) -------------------------------------------------------------------------------- /repos/ros2.rclcpp/build_interfaces.py: -------------------------------------------------------------------------------- 1 | # Copyright 2024 Apex.AI, Inc. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | import em 16 | import argparse 17 | 18 | if __name__ == "__main__": 19 | # execute only if run as a script 20 | parser = argparse.ArgumentParser() 21 | parser.add_argument("file_out", help="File to be generated") 22 | parser.add_argument("file_template", help="Template for the file to be filled") 23 | parser.add_argument("-D", help="Define") 24 | args = parser.parse_args() 25 | defines = ['-D', 'rcutils_module_path = \"\"'] 26 | if "D" in vars(args): 27 | defines.extend(['-D', args.D]) 28 | em.invoke(( 29 | [ 30 | '-o', args.file_out, 31 | # We don't need to populate rcutils_module_path as we already have rcutils imported, so 32 | # it will be found within the .em script. This parameter we pass (as empty) for legacy 33 | # reasons only to avoid changing the .em file. 34 | *defines, 35 | args.file_template 36 | ] 37 | )) 38 | -------------------------------------------------------------------------------- /repos/ros2.rclcpp/rclcpp.BUILD: -------------------------------------------------------------------------------- 1 | # Copyright 2024 Apex.AI, Inc. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | load("@rules_ros//utils:template_expansion.bzl", "cc_library_from_template") 16 | load("@python_deps//:requirements.bzl", "requirement") 17 | 18 | cc_library( 19 | name = "rclcpp", 20 | srcs = glob(["src/**/*.cpp", "src/**/*.hpp"]), 21 | hdrs = glob(["include/**/*.hpp"]), 22 | strip_include_prefix = "include", 23 | deps = [ 24 | "@ament.ament_index//ament_index_cpp", 25 | "@ros2.rcl//rcl", 26 | "@ros2.rmw//rmw", 27 | "@ros2.rcpputils//:rcpputils", 28 | "@ros2.rcl_interfaces//rosgraph_msgs", 29 | "@ros-tooling.libstatistics_collector//:libstatistics_collector", 30 | ":logging", 31 | ":get_interfaces", 32 | ":interface_traits", 33 | ], 34 | visibility = ["//visibility:public"], 35 | ) 36 | 37 | cc_library_from_template( 38 | name = "logging", 39 | generator_script = "@ros2.rcutils//:build_logging_macros", 40 | template = "resource/logging.hpp.em", 41 | package_name = "rclcpp" 42 | ) 43 | 44 | NODE_INTERFACES = [ 45 | "node_base", 46 | "node_clock", 47 | "node_graph", 48 | "node_logging", 49 | "node_parameters", 50 | "node_services", 51 | "node_time_source", 52 | "node_timers", 53 | "node_topics", 54 | "node_waitables", 55 | ] 56 | 57 | cc_library_from_template( 58 | name = "get_interfaces", 59 | generator_script = ":build_interfaces", 60 | template = "resource/get_interface.hpp.em", 61 | output_pattern = "node_interfaces/get_{interface_name}.hpp", 62 | package_name = "rclcpp", 63 | variables = {"interface_name": [interface + "_interface" for interface in NODE_INTERFACES]}, 64 | ) 65 | 66 | cc_library_from_template( 67 | name = "interface_traits", 68 | generator_script = ":build_interfaces", 69 | template = "resource/interface_traits.hpp.em", 70 | output_pattern = "node_interfaces/{interface_name}_traits.hpp", 71 | package_name = "rclcpp", 72 | variables = {"interface_name": [interface + "_interface" for interface in NODE_INTERFACES]}, 73 | ) 74 | 75 | 76 | py_binary( 77 | name = "build_interfaces", 78 | srcs = ["build_interfaces.py"], 79 | deps = [ 80 | requirement("empy"), 81 | ], 82 | ) 83 | -------------------------------------------------------------------------------- /repos/ros2.rcpputils/rcpputils.BUILD: -------------------------------------------------------------------------------- 1 | # Copyright 2024 Apex.AI, Inc. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | cc_library( 16 | name = "rcpputils", 17 | srcs = glob(["src/**/*.c"]), 18 | hdrs = glob(["include/**/*.hpp"]), 19 | strip_include_prefix = "include", 20 | visibility = ["//visibility:public"], 21 | ) -------------------------------------------------------------------------------- /repos/ros2.rcutils/build_logging_macros.py: -------------------------------------------------------------------------------- 1 | # Copyright 2024 Apex.AI, Inc. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | import em 16 | import argparse 17 | 18 | if __name__ == "__main__": 19 | # execute only if run as a script 20 | parser = argparse.ArgumentParser() 21 | parser.add_argument("file_out", help="File to be generated") 22 | parser.add_argument("file_template", help="Template for the file to be filled") 23 | args = parser.parse_args() 24 | em.invoke(( 25 | [ 26 | '-o', args.file_out, 27 | # We don't need to populate rcutils_module_path as we already have rcutils imported, so 28 | # it will be found within the .em script. This parameter we pass (as empty) for legacy 29 | # reasons only to avoid changing the .em file. 30 | '-D', 'rcutils_module_path = \"\"', 31 | args.file_template 32 | ] 33 | )) 34 | -------------------------------------------------------------------------------- /repos/ros2.rcutils/root.BUILD: -------------------------------------------------------------------------------- 1 | # Copyright 2024 Apex.AI, Inc. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | load("@rules_ros//utils:template_expansion.bzl", "cc_library_from_template") 16 | load("@python_deps//:requirements.bzl", "requirement") 17 | 18 | cc_library( 19 | name = "rcutils", 20 | srcs = glob([ 21 | "src/*.c", 22 | "src/*.h", 23 | ], 24 | exclude = ["src/time_*.c"], 25 | ) +select({ 26 | "@bazel_tools//src/conditions:windows": ["src/time_win32.c"], 27 | "//conditions:default": ["src/time_unix.c"], 28 | }), 29 | hdrs = glob(["include/**/*.h"]), 30 | # linkopts = ["-ldl"], 31 | strip_include_prefix = "include", 32 | local_defines = ['ROS_PACKAGE_NAME=\\\"rcutils\\\"', "_GNU_SOURCE"], 33 | deps = [ 34 | #":private_rcutils_includes", 35 | ":logging_macros", 36 | ], 37 | visibility = ["//visibility:public"], 38 | ) 39 | 40 | cc_library( 41 | name = "private_rcutils_includes", 42 | hdrs = glob(["src/*.h"]), 43 | strip_include_prefix = "src", 44 | ) 45 | 46 | 47 | py_library( 48 | name = "logging", 49 | srcs = [ 50 | "rcutils/__init__.py", 51 | "rcutils/logging.py", 52 | ], 53 | imports = ["rcutils"], 54 | visibility = ["//visibility:public"], 55 | deps = [ 56 | requirement("empy"), 57 | ], 58 | ) 59 | 60 | py_binary( 61 | name = "build_logging_macros", 62 | srcs = ["build_logging_macros.py"], 63 | visibility = ["//visibility:public"], 64 | deps = [ 65 | ":logging", 66 | ], 67 | ) 68 | 69 | cc_library_from_template( 70 | name = "logging_macros", 71 | generator_script = ":build_logging_macros", 72 | template = "resource/logging_macros.h.em", 73 | package_name = "rcutils", 74 | ) 75 | -------------------------------------------------------------------------------- /repos/ros2.rmw/rmw.BUILD: -------------------------------------------------------------------------------- 1 | # Copyright 2024 Apex.AI, Inc. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | cc_library( 16 | name = "rmw", 17 | srcs = glob(["src/**/*.c"]), 18 | hdrs = glob([ 19 | "include/**/*.h", 20 | "include/**/*.hpp", 21 | ]), 22 | strip_include_prefix = "include", 23 | deps = ["@ros2.rcutils//:rcutils"], 24 | visibility = ["//visibility:public"], 25 | ) -------------------------------------------------------------------------------- /repos/ros2.ros2_tracing/tracetools.BUILD: -------------------------------------------------------------------------------- 1 | # Copyright 2024 Apex.AI, Inc. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | load("@bazel_skylib//rules:expand_template.bzl","expand_template") 16 | 17 | cc_library( 18 | name = "tracetools", 19 | srcs = [ 20 | "src/tracetools.c", 21 | "src/utils.cpp", 22 | ], 23 | hdrs = [ 24 | "include/tracetools/tracetools.h", 25 | "include/tracetools/utils.hpp", 26 | "include/tracetools/visibility_control.hpp", 27 | ":config", 28 | ], 29 | strip_include_prefix = "include", 30 | deps = ["@ros2.rcutils//:rcutils"], 31 | visibility = ["//visibility:public"], 32 | ) 33 | 34 | # ToDo: config not yet fully implemented 35 | expand_template( 36 | name = "config", 37 | out = "include/tracetools/config.h", 38 | substitutions = { 39 | "#cmakedefine TRACETOOLS_DISABLED": "#define TRACETOOLS_DISABLED 1", 40 | "#cmakedefine TRACETOOLS_LTTNG_ENABLED": "" 41 | }, 42 | template = "include/tracetools/config.h.in", 43 | ) 44 | 45 | 46 | -------------------------------------------------------------------------------- /repos/ros2.ros2cli/ros2cli.BUILD: -------------------------------------------------------------------------------- 1 | # Copyright 2024 Apex.AI, Inc. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | load("@rules_python//python:packaging.bzl", "py_wheel") 16 | load("@rules_ros//pkg:defs.bzl", "ros_pkg") 17 | 18 | py_library( 19 | name = "ros2cli_py", 20 | srcs = glob(["ros2cli/**/*.py"]), 21 | ) 22 | 23 | py_wheel( 24 | name = "ros2cli_whl", 25 | # packages=find_packages(exclude=['test']), 26 | # data_files=[ 27 | # ('share/' + package_name, ['package.xml']), 28 | # ('share/ament_index/resource_index/packages', 29 | # ['resource/' + package_name]), 30 | # ], 31 | # install_requires=['ros2cli'], 32 | # zip_safe=True, 33 | author = "Dirk Thomas", 34 | author_email = "dthomas@osrfoundation.org", 35 | # maintainer='Dirk Thomas', 36 | # maintainer_email='dthomas@osrfoundation.org', 37 | # url='https://github.com/ros2/ros2cli/tree/master/ros2run', 38 | # download_url='https://github.com/ros2/ros2cli/releases', 39 | # keywords=[], 40 | classifiers = [ 41 | "Environment :: Console", 42 | "Intended Audience :: Developers", 43 | "License :: OSI Approved :: Apache Software License", 44 | "Programming Language :: Python", 45 | ], 46 | #description_file = "README.md", 47 | distribution = "ros2cli", 48 | #tests_require=['pytest'], 49 | entry_points = { 50 | "ros2cli.command": [ 51 | "daemon = ros2cli.command.daemon:DaemonCommand", 52 | "extension_points = ros2cli.command.extension_points:ExtensionPointsCommand", 53 | "extensions = ros2cli.command.extensions:ExtensionsCommand", 54 | ], 55 | "ros2cli.extension_point": [ 56 | "ros2cli.command = ros2cli.command:CommandExtension", 57 | "ros2cli.daemon.verb = ros2cli.verb.daemon:VerbExtension", 58 | ], 59 | "ros2cli.daemon.verb": [ 60 | "start = ros2cli.verb.daemon.start:StartVerb", 61 | "status = ros2cli.verb.daemon.status:StatusVerb", 62 | "stop = ros2cli.verb.daemon.stop:StopVerb", 63 | ], 64 | "console_scripts": [ 65 | "ros2 = ros2cli.cli:main", 66 | "_ros2_daemon = ros2cli.daemon:main", 67 | ], 68 | }, 69 | license = "Apache License, Version 2.0", 70 | strip_path_prefixes = ["ros2cli"], 71 | version = "0.8.6", 72 | deps = [":ros2cli_py"], 73 | ) 74 | 75 | ros_pkg( 76 | name = "ros2cli", 77 | description = "Framework for ROS 2 command line tools.", 78 | license = "Apex.AI License", 79 | maintainer_email = "dthomas@osrfoundation.org", 80 | maintainer_name = "Dirk Thomas", 81 | pkg_name = "ros2cli", 82 | py_packages = ["ros2cli_whl"], 83 | deps = [ 84 | "//ros2pkg", 85 | "//ros2run", 86 | "@ament.ament_index//ament_index_python", 87 | ], 88 | version = "0.8.6", 89 | visibility = ["//visibility:public"], 90 | ) 91 | -------------------------------------------------------------------------------- /repos/ros2.ros2cli/ros2pkg.BUILD: -------------------------------------------------------------------------------- 1 | # Copyright 2024 Apex.AI, Inc. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | load("@rules_python//python:packaging.bzl", "py_wheel") 16 | load("@rules_ros//pkg:defs.bzl", "ros_pkg") 17 | 18 | py_library( 19 | name = "ros2pkg_py", 20 | srcs = glob(["ros2pkg/**/*.py"]), 21 | ) 22 | 23 | py_wheel( 24 | name = "ros2pkg_whl", 25 | # packages=find_packages(exclude=['test']), 26 | # data_files=[ 27 | # ('share/' + package_name, ['package.xml']), 28 | # ('share/ament_index/resource_index/packages', 29 | # ['resource/' + package_name]), 30 | # ], 31 | # install_requires=['ros2cli'], 32 | # zip_safe=True, 33 | author = "Dirk Thomas", 34 | author_email = "dthomas@osrfoundation.org", 35 | # maintainer='Dirk Thomas', 36 | # maintainer_email='dthomas@osrfoundation.org', 37 | # url='https://github.com/ros2/ros2cli/tree/master/ros2run', 38 | # download_url='https://github.com/ros2/ros2cli/releases', 39 | # keywords=[], 40 | classifiers = [ 41 | "Environment :: Console", 42 | "Intended Audience :: Developers", 43 | "License :: OSI Approved :: Apache Software License", 44 | "Programming Language :: Python", 45 | ], 46 | #description_file = "README.md", 47 | distribution = "ros2pkg", 48 | #tests_require=['pytest'], 49 | entry_points = { 50 | "ros2cli.command": [ 51 | "pkg = ros2pkg.command.pkg:PkgCommand", 52 | ], 53 | "ros2cli.extension_point": [ 54 | "ros2pkg.verb = ros2pkg.verb:VerbExtension", 55 | ], 56 | "ros2pkg.verb": [ 57 | "create = ros2pkg.verb.create:CreateVerb", 58 | "executables = ros2pkg.verb.executables:ExecutablesVerb", 59 | "list = ros2pkg.verb.list:ListVerb", 60 | "prefix = ros2pkg.verb.prefix:PrefixVerb", 61 | "xml = ros2pkg.verb.xml:XmlVerb", 62 | ], 63 | }, 64 | license = "Apache License, Version 2.0", 65 | strip_path_prefixes = ["ros2pkg"], 66 | version = "0.8.6", 67 | deps = [":ros2pkg_py"], 68 | ) 69 | 70 | ros_pkg( 71 | name = "ros2pkg", 72 | description = "The pkg command for ROS 2 command line tools.", 73 | license = "Apex.AI License", 74 | maintainer_email = "dthomas@osrfoundation.org", 75 | maintainer_name = "Dirk Thomas", 76 | pkg_name = "ros2pkg", 77 | py_packages = ["ros2pkg_whl"], 78 | version = "0.8.6", 79 | visibility = ["//visibility:public"], 80 | ) 81 | -------------------------------------------------------------------------------- /repos/ros2.ros2cli/ros2run.BUILD: -------------------------------------------------------------------------------- 1 | # Copyright 2024 Apex.AI, Inc. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | load("@rules_python//python:packaging.bzl", "py_wheel") 16 | load("@rules_ros//pkg:defs.bzl", "ros_pkg") 17 | 18 | py_library( 19 | name = "ros2run_py", 20 | srcs = glob(["ros2run/**/*.py"]), 21 | ) 22 | 23 | py_wheel( 24 | name = "ros2run_whl", 25 | # packages=find_packages(exclude=['test']), 26 | # data_files=[ 27 | # ('share/' + package_name, ['package.xml']), 28 | # ('share/ament_index/resource_index/packages', 29 | # ['resource/' + package_name]), 30 | # ], 31 | # install_requires=['ros2cli'], 32 | # zip_safe=True, 33 | author = "Dirk Thomas", 34 | author_email = "dthomas@osrfoundation.org", 35 | # maintainer='Dirk Thomas', 36 | # maintainer_email='dthomas@osrfoundation.org', 37 | # url='https://github.com/ros2/ros2cli/tree/master/ros2run', 38 | # download_url='https://github.com/ros2/ros2cli/releases', 39 | # keywords=[], 40 | classifiers = [ 41 | "Environment :: Console", 42 | "Intended Audience :: Developers", 43 | "License :: OSI Approved :: Apache Software License", 44 | "Programming Language :: Python", 45 | ], 46 | # description_file = "README.md", 47 | distribution = "ros2run", 48 | #tests_require=['pytest'], 49 | entry_points = { 50 | "ros2cli.command": [ 51 | "run = ros2run.command.run:RunCommand", 52 | ], 53 | }, 54 | license = "Apache License, Version 2.0", 55 | strip_path_prefixes = ["ros2run"], 56 | version = "0.8.6", 57 | visibility = ["//visibility:public"], 58 | deps = [":ros2run_py"], 59 | ) 60 | 61 | ros_pkg( 62 | name = "ros2run", 63 | description = "The run command for ROS 2 command line tools.", 64 | license = "Apex.AI License", 65 | maintainer_email = "dthomas@osrfoundation.org", 66 | maintainer_name = "Dirk Thomas", 67 | pkg_name = "ros2run", 68 | py_packages = ["ros2run_whl"], 69 | version = "0.8.6", 70 | visibility = ["//visibility:public"], 71 | ) 72 | -------------------------------------------------------------------------------- /repos/ros2.rosidl/rosidl_adapter.BUILD: -------------------------------------------------------------------------------- 1 | # Copyright 2024 Apex.AI, Inc. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | load("@python_deps//:requirements.bzl", "requirement") 16 | 17 | py_library( 18 | name = "rosidl_adapter", 19 | srcs = glob([ 20 | "rosidl_adapter/**/*.py", 21 | "rosidl_adapter/*.py", 22 | ]), 23 | data = glob(["rosidl_adapter/resource/*.idl.em"]), 24 | imports = ["."], 25 | visibility = ["//visibility:public"], 26 | deps = [ 27 | "//rosidl_cli", 28 | requirement("catkin_pkg"), 29 | requirement("empy"), 30 | ], 31 | ) 32 | 33 | py_binary( 34 | name = "msg2idl", 35 | srcs = ["scripts/msg2idl.py"], 36 | legacy_create_init = 0, # required for py_binaries used on execution platform 37 | visibility = ["//visibility:public"], 38 | deps = [":rosidl_adapter"], 39 | ) 40 | 41 | py_binary( 42 | name = "srv2idl", 43 | srcs = ["scripts/srv2idl.py"], 44 | legacy_create_init = 0, # required for py_binaries used on execution platform 45 | visibility = ["//visibility:public"], 46 | deps = [":rosidl_adapter"], 47 | ) 48 | 49 | py_test( 50 | name = "test_base_type", 51 | srcs = [ 52 | "test/test_base_type.py", 53 | ], 54 | deps = [ 55 | ":rosidl_adapter", 56 | requirement("pytest"), 57 | ], 58 | ) 59 | -------------------------------------------------------------------------------- /repos/ros2.rosidl/rosidl_cli.BUILD: -------------------------------------------------------------------------------- 1 | # Copyright 2024 Apex.AI, Inc. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | load("@python_deps//:requirements.bzl", "requirement") 16 | 17 | py_library( 18 | name = "rosidl_cli", 19 | srcs = glob([ 20 | "rosidl_cli/**/*.py", 21 | "rosidl_cli/*.py", 22 | ]), 23 | imports = ["."], 24 | visibility = ["//visibility:public"], 25 | deps = [ 26 | requirement("pyyaml"), 27 | ], 28 | ) 29 | 30 | -------------------------------------------------------------------------------- /repos/ros2.rosidl/rosidl_cmake.BUILD: -------------------------------------------------------------------------------- 1 | # Copyright 2024 Apex.AI, Inc. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | load("@python_deps//:requirements.bzl", "requirement") 16 | 17 | py_library( 18 | name = "rosidl_cmake_python", 19 | srcs = [ 20 | "rosidl_cmake/__init__.py", 21 | ], 22 | imports = ["."], 23 | visibility = ["//visibility:public"], 24 | deps = [ 25 | "//rosidl_parser:rosidl_parser_python", 26 | requirement("empy"), 27 | ], 28 | ) 29 | -------------------------------------------------------------------------------- /repos/ros2.rosidl/rosidl_generator_c.BUILD: -------------------------------------------------------------------------------- 1 | # Copyright 2024 Apex.AI, Inc. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | load("@bazel_skylib//rules:copy_file.bzl", "copy_file") 16 | 17 | py_library( 18 | name = "rosidl_generator_c_python", 19 | srcs = [ 20 | "rosidl_generator_c/__init__.py", 21 | ], 22 | imports = ["."], 23 | visibility = ["//visibility:public"], 24 | deps = [ 25 | "@ros2.rosidl//rosidl_cmake:rosidl_cmake_python", 26 | "@ros2.rosidl//rosidl_parser:rosidl_parser_python", 27 | ], 28 | ) 29 | 30 | copy_file( 31 | name = "rosidl_generator_c_with_py_extension", 32 | src = "bin/rosidl_generator_c", 33 | out = "generator.py", 34 | allow_symlink = True, 35 | ) 36 | 37 | py_binary( 38 | name = "generator", 39 | srcs = [ 40 | "generator.py", 41 | ], 42 | legacy_create_init = 0, # required for py_binaries used on execution platform 43 | visibility = ["//visibility:public"], 44 | deps = [ 45 | ":rosidl_generator_c_python", 46 | ], 47 | ) 48 | 49 | filegroup( 50 | name = "resource", 51 | srcs = glob(["resource/*.em"]), 52 | visibility = ["//visibility:public"], 53 | ) 54 | 55 | exports_files([ 56 | "resource/rosidl_generator_c__visibility_control.h.in", 57 | ]) 58 | 59 | # Test run (In cmake only enabled if APEX_CERT is not set) 60 | # cc_msgs_library( 61 | # name = "messages", 62 | # srcs = glob( 63 | # [ 64 | # "msg/*.idl", 65 | # "srv/*.srv", 66 | # ], 67 | # exclude = [ 68 | # "msg/WStrings.idl", # Exclude as cyclonedds does not support wstrings 69 | # ], 70 | # ), 71 | # visibility = ["//visibility:private"], 72 | # ) 73 | # 74 | # cc_test( 75 | # name = "test_compilation_c", 76 | # srcs = [ 77 | # "test/separate_compilation.c", 78 | # "test/separate_compilation.h", 79 | # "test/test_compilation.c", 80 | # ], 81 | # linkopts = ["-ldl"], 82 | # visibility = ["//visibility:private"], 83 | # deps = [":messages"], 84 | # ) 85 | # 86 | # # Does not compile as it relies on wstring 87 | # #cc_test( 88 | # # name = "test_interfaces_c", 89 | # # srcs = ["test/test_interfaces.c"], 90 | # # deps = [ ":messages" ], 91 | # # visibility = ["//visibility:private"], 92 | # #) 93 | # 94 | # cc_test( 95 | # name = "test_invalid_initialization_c", 96 | # srcs = ["test/test_invalid_initialization.c"], 97 | # linkopts = ["-ldl"], 98 | # visibility = ["//visibility:private"], 99 | # deps = [":messages"], 100 | # ) 101 | 102 | cc_test( 103 | name = "test_strict_aliasing_c", 104 | srcs = ["test/test_strict_aliasing.c"], 105 | linkopts = ["-ldl"], 106 | visibility = ["//visibility:private"], 107 | deps = [":messages"], 108 | ) 109 | -------------------------------------------------------------------------------- /repos/ros2.rosidl/rosidl_generator_cpp.BUILD: -------------------------------------------------------------------------------- 1 | # Copyright 2024 Apex.AI, Inc. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | load("@bazel_skylib//rules:copy_file.bzl", "copy_file") 16 | # load("//apex_os/core/rosidl/rules_rosidl:defs.bzl", "cc_msgs_library") 17 | 18 | py_library( 19 | name = "rosidl_generator_cpp_python", 20 | srcs = [ 21 | "rosidl_generator_cpp/__init__.py", 22 | ], 23 | imports = ["."], 24 | deps = [ 25 | "@ros2.rosidl//rosidl_cmake:rosidl_cmake_python", 26 | "@ros2.rosidl//rosidl_parser:rosidl_parser_python", 27 | ], 28 | ) 29 | 30 | copy_file( 31 | name = "rosidl_generator_cpp_with_py_extension", 32 | src = "bin/rosidl_generator_cpp", 33 | out = "generator.py", 34 | allow_symlink = True, 35 | ) 36 | 37 | py_binary( 38 | name = "generator", 39 | srcs = [ 40 | "generator.py", 41 | ], 42 | legacy_create_init = 0, # required for py_binaries used on execution platform 43 | visibility = ["//visibility:public"], 44 | deps = [ 45 | ":rosidl_generator_cpp_python", 46 | ], 47 | ) 48 | 49 | filegroup( 50 | name = "resource", 51 | srcs = glob(["resource/*.em"]), 52 | visibility = ["//visibility:public"], 53 | ) 54 | 55 | # Test run 56 | # cc_msgs_library( 57 | # name = "messages", 58 | # srcs = glob( 59 | # [ 60 | # "msg/*.idl", 61 | # "srv/*.srv", 62 | # ], 63 | # exclude = [ 64 | # "msg/Malformatted.idl", 65 | # "msg/UnknownTypes.idl", 66 | # "msg/WStrings.idl", # Exclude as cyclonedds does not support wstrings 67 | # "msg/WChar.idl", # Exclude as cyclonedds does not support wchar 68 | # ], 69 | # ), 70 | # visibility = ["//visibility:public"], 71 | # ) 72 | -------------------------------------------------------------------------------- /repos/ros2.rosidl/rosidl_parser.BUILD: -------------------------------------------------------------------------------- 1 | # Copyright 2024 Apex.AI, Inc. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | load("@python_deps//:requirements.bzl", "requirement") 16 | 17 | py_library( 18 | name = "rosidl_parser_python", 19 | srcs = glob([ 20 | "rosidl_parser/*.py", 21 | ]), 22 | data = ["rosidl_parser/grammar.lark"], 23 | imports = ["."], 24 | visibility = ["//visibility:public"], 25 | deps = [ 26 | requirement("lark"), 27 | ], 28 | ) 29 | -------------------------------------------------------------------------------- /repos/ros2.rosidl/rosidl_runtime_c.BUILD: -------------------------------------------------------------------------------- 1 | # Copyright 2024 Apex.AI, Inc. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | cc_library( 16 | name = "rosidl_runtime_c", 17 | srcs = glob(["src/*.c"]), 18 | hdrs = glob(["include/**/*.h"]), 19 | strip_include_prefix = "include", 20 | visibility = ["//visibility:public"], 21 | deps = [ 22 | "@ros2.rcutils//:rcutils", 23 | "@ros2.rosidl//rosidl_typesupport_interface", 24 | ], 25 | ) 26 | -------------------------------------------------------------------------------- /repos/ros2.rosidl/rosidl_runtime_cpp.BUILD: -------------------------------------------------------------------------------- 1 | # Copyright 2024 Apex.AI, Inc. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | cc_library( 16 | name = "rosidl_runtime_cpp", 17 | srcs = [], 18 | hdrs = glob([ 19 | "include/rosidl_runtime_cpp/*.hpp", 20 | "include/rosidl_typesupport_cpp/*.hpp", 21 | ]), 22 | strip_include_prefix = "include", 23 | visibility = ["//visibility:public"], 24 | deps = [ 25 | # "//apex_os/core/dds_typesupport", 26 | ], 27 | ) 28 | -------------------------------------------------------------------------------- /repos/ros2.rosidl/rosidl_typesupport_interface.BUILD: -------------------------------------------------------------------------------- 1 | # Copyright 2024 Apex.AI, Inc. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | cc_library( 16 | name = "rosidl_typesupport_interface", 17 | hdrs = glob(["include/**/*.h"]), 18 | strip_include_prefix = "include", 19 | visibility = ["//visibility:public"], 20 | deps = [], 21 | ) 22 | -------------------------------------------------------------------------------- /repos/ros2.rosidl_dds/rosidl_generator_dds_idl.BUILD: -------------------------------------------------------------------------------- 1 | # Copyright 2024 Apex.AI, Inc. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | load("@bazel_skylib//rules:copy_file.bzl", "copy_file") 16 | 17 | py_library( 18 | name = "rosidl_generator_dds_idl_python", 19 | srcs = [ 20 | "rosidl_generator_dds_idl/__init__.py", 21 | ], 22 | imports = ["."], 23 | ) 24 | 25 | copy_file( 26 | name = "rosidl_generator_dds_idl_with_py_extension", 27 | src = "bin/rosidl_generator_dds_idl", 28 | out = "generator.py", 29 | allow_symlink = True, 30 | ) 31 | 32 | filegroup( 33 | name = "resource", 34 | srcs = glob(["resource/*.em"]), 35 | visibility = ["//visibility:public"], 36 | ) 37 | 38 | py_binary( 39 | name = "generator", 40 | srcs = [ 41 | "rosidl_generator_dds_idl_with_py_extension", 42 | ], 43 | data = [ 44 | ":resource", 45 | ], 46 | legacy_create_init = 0, # required for py_binaries used on execution platform 47 | visibility = ["//visibility:public"], 48 | deps = [ 49 | ":rosidl_generator_dds_idl_python", 50 | # "//apex_os/core/apex_dds/apex_middleware/apex_middleware_typefiles_generator", 51 | "@ros2.rosidl//rosidl_cmake:rosidl_cmake_python", 52 | # "//apex_os/core/rosidl/rosidl_parser:rosidl_parser_python", 53 | ], 54 | ) 55 | -------------------------------------------------------------------------------- /repos/ros2.rosidl_typesupport/rosidl_typesupport_c.BUILD: -------------------------------------------------------------------------------- 1 | # Copyright 2024 Apex.AI, Inc. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | load("@bazel_skylib//rules:copy_file.bzl", "copy_file") 16 | 17 | py_library( 18 | name = "rosidl_typesupport_c_python", 19 | srcs = [ 20 | "rosidl_typesupport_c/__init__.py", 21 | ], 22 | imports = ["."], 23 | deps = [ 24 | "@ros2.rosidl//rosidl_cmake:rosidl_cmake_python", 25 | ], 26 | ) 27 | 28 | copy_file( 29 | name = "rosidl_typesupport_c_with_py_extension", 30 | src = "bin/rosidl_typesupport_c", 31 | out = "generator.py", 32 | allow_symlink = True, 33 | ) 34 | 35 | py_binary( 36 | name = "generator", 37 | srcs = [ 38 | ":generator.py", 39 | ], 40 | legacy_create_init = 0, # required for py_binaries used on execution platform 41 | visibility = ["//visibility:public"], 42 | deps = [ 43 | ":rosidl_typesupport_c_python", 44 | "@ros2.rosidl//rosidl_cmake:rosidl_cmake_python", 45 | "@ros2.rosidl//rosidl_parser:rosidl_parser_python", 46 | ], 47 | ) 48 | 49 | cc_library( 50 | name = "rosidl_typesupport_c", 51 | srcs = glob([ 52 | "src/*.c", 53 | "src/*.cpp", 54 | "src/*.hpp", 55 | ]), 56 | hdrs = glob([ 57 | "include/rosidl_typesupport_c/*.h", 58 | ]), 59 | strip_include_prefix = "include", 60 | visibility = ["//visibility:public"], 61 | deps = [ 62 | #"//apex_os/core/dds_typesupport", 63 | "@ros2.rosidl//rosidl_runtime_c", 64 | "@ros2.rcpputils//:rcpputils", 65 | ], 66 | ) 67 | 68 | filegroup( 69 | name = "config_files", 70 | srcs = glob(["resource/*.in"]), 71 | visibility = ["//visibility:public"], 72 | ) 73 | 74 | filegroup( 75 | name = "resource", 76 | srcs = glob(["resource/*.em"]), 77 | visibility = ["//visibility:public"], 78 | ) 79 | 80 | exports_files([ 81 | "resource/rosidl_typesupport_c__visibility_control.h.in", 82 | ]) 83 | -------------------------------------------------------------------------------- /rosidl/BUILD.bazel: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ApexAI/rules_ros/5d2d81bc7779cbdada626be299354a3b5544ba2f/rosidl/BUILD.bazel -------------------------------------------------------------------------------- /rosidl/defs.bzl: -------------------------------------------------------------------------------- 1 | # Copyright 2024 Apex.AI, Inc. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | load(":detail/cc_library_with_msgs_provider.bzl", _msgs_library_with_cc = "msgs_library_with_cc") 16 | load(":detail/rosidl_adapter.bzl", _rosidl_adapter = "rosidl_adapter") 17 | load(":detail/rosidl_generator_c.bzl", _cc_rosidl_generator_c_library = "cc_rosidl_generator_c_library") 18 | load(":detail/rosidl_generator_cpp.bzl", _cc_rosidl_generator_cpp_library = "cc_rosidl_generator_cpp_library") 19 | load(":detail/rosidl_typesupport_c.bzl", _cc_rosidl_typesupport_c_library = "cc_rosidl_typesupport_c_library") 20 | 21 | raw_msgs_library = _rosidl_adapter 22 | 23 | def msgs_library( 24 | *, 25 | name, 26 | srcs = [], 27 | deps = [], 28 | visibility = None): 29 | """ Create a library for msg/srv/idl files with all default bindings (currently C++) 30 | 31 | Provides: 32 | This rule provides a `MsgsInfo` provider to be used as a dependency for other msgs_library. 33 | It also provides a `CcInfo` provider to be used as a dependency for C/C++ library with the cc toolchain. 34 | 35 | This macro provides an auxilary target `{name}__raw__` which only contains the `MsgsInfo` 36 | provider without any bindings. 37 | 38 | Args: 39 | name: [String] The target name 40 | srcs: [List of Labels] Idl files (of all kinds msg, srv, idl) 41 | deps: [List of Labels] Dependencies to `cc_library` or other `msgs_library` 42 | visibility: Visability label 43 | """ 44 | 45 | # Convert: *.msg, *.srv -> *.idl (ROS), Copy: *.idl -> *.idl (ROS) 46 | name_raw = "{}_raw".format(name) 47 | _rosidl_adapter( 48 | name = name_raw, 49 | srcs = srcs, 50 | deps = deps, 51 | visibility = visibility, 52 | ) 53 | 54 | # Collect generated cc_libraries 55 | cc_libs = [] 56 | 57 | # Library with rosidl_generator_c 58 | name_rosidl_generator_c = "{}__rosidl_generator_c".format(name) 59 | cc_libs.append(":" + name_rosidl_generator_c) 60 | _cc_rosidl_generator_c_library( 61 | name = name_rosidl_generator_c, 62 | srcs = [":" + name_raw], 63 | deps = [ 64 | "@ros2.rosidl//rosidl_runtime_c", 65 | ] + deps, 66 | ) 67 | 68 | # Library with rosidl_generator_cpp 69 | name_rosidl_generator_cpp = "{}__rosidl_generator_cpp".format(name) 70 | cc_libs.append(":" + name_rosidl_generator_cpp) 71 | _cc_rosidl_generator_cpp_library( 72 | name = name_rosidl_generator_cpp, 73 | srcs = [":" + name_raw], 74 | deps = [ 75 | "@ros2.rosidl//rosidl_runtime_cpp", 76 | ] + deps, 77 | linkstatic = True, # No object files 78 | ) 79 | 80 | # Library with rosidl_typesupport_c 81 | name_rosidl_typesupport_c = "{}__rosidl_typesupport_c".format(name) 82 | cc_libs.append(":" + name_rosidl_typesupport_c) 83 | _cc_rosidl_typesupport_c_library( 84 | name = name_rosidl_typesupport_c, 85 | srcs = [":" + name_raw], 86 | typesupports = ["rmw_cyclonedds_cpp"], 87 | deps = [ 88 | ":" + name_rosidl_generator_c, 89 | "@ros2.rosidl_typesupport//rosidl_typesupport_c", 90 | ] + deps, 91 | ) 92 | 93 | _msgs_library_with_cc( 94 | name = name, 95 | deps = cc_libs + deps, 96 | msgs = ":" + name_raw, 97 | visibility = visibility, 98 | ) 99 | -------------------------------------------------------------------------------- /rosidl/detail/cc_library_with_hdrs_extracted_from_srcs.bzl: -------------------------------------------------------------------------------- 1 | # Copyright 2024 Apex.AI, Inc. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | def _filtered_filegroup_impl(ctx): 16 | return [DefaultInfo( 17 | files = depset([f for f in ctx.files.files_to_filter if f.extension in ctx.attr.suffixes]), 18 | )] 19 | 20 | _filtered_filegroup = rule( 21 | implementation = _filtered_filegroup_impl, 22 | attrs = { 23 | "files_to_filter": attr.label_list( 24 | mandatory = True, 25 | allow_files = True, 26 | ), 27 | "suffixes": attr.string_list( 28 | mandatory = True, 29 | ), 30 | }, 31 | ) 32 | 33 | def cc_library_with_hdrs_extracted_from_srcs(*, name, srcs, **kwargs): 34 | _filtered_filegroup( 35 | name = "_%s_hdrs" % name, 36 | visibility = ["//visibility:private"], 37 | files_to_filter = srcs, 38 | suffixes = ["h", "hh", "hpp", "hxx", "inc", "inl", "H"], 39 | ) 40 | native.cc_library( 41 | name = name, 42 | srcs = srcs, 43 | hdrs = [":_%s_hdrs" % name], 44 | **kwargs 45 | ) 46 | -------------------------------------------------------------------------------- /rosidl/detail/cc_library_with_msgs_provider.bzl: -------------------------------------------------------------------------------- 1 | # Copyright 2024 Apex.AI, Inc. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | load(":providers.bzl", "MsgsInfo") 16 | 17 | def _msgs_library_with_cc_impl(ctx): 18 | cc_info = cc_common.merge_cc_infos(cc_infos = [dep[CcInfo] for dep in ctx.attr.deps]) 19 | msgs_info = ctx.attr.msgs[MsgsInfo] 20 | return [cc_info, msgs_info] 21 | 22 | msgs_library_with_cc = rule( 23 | implementation = _msgs_library_with_cc_impl, 24 | attrs = { 25 | "deps": attr.label_list(providers = [CcInfo]), 26 | "msgs": attr.label(providers = [MsgsInfo]), 27 | }, 28 | fragments = ["cpp"], 29 | toolchains = ["@bazel_tools//tools/cpp:toolchain_type"], 30 | doc = """ 31 | Rule that provides two providers: 32 | * a MsgsInfo provider containing all idl_srcs and transitive 33 | dependencies 34 | * a CcInfo provider including all transitive dependencies 35 | """, 36 | ) 37 | -------------------------------------------------------------------------------- /rosidl/detail/common_config.bzl: -------------------------------------------------------------------------------- 1 | # Copyright 2024 Apex.AI, Inc. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | load(":detail/misc_support.bzl", "get_package_name") 16 | 17 | def _create_common_config_internal(ctx, *, srcs, output_directory, split_position, output_file_create_func, skip_first_filepath_element = False, append_extra_package_name = False): 18 | # Step 0: Config 19 | package_name = get_package_name(ctx) 20 | 21 | # Step 1: Prepare output list 22 | _outputs = [] 23 | _idl_tuples = [] 24 | _subdir = None 25 | for src in srcs: 26 | _src_split = src.path.split("/") 27 | _subdir = "/".join(_src_split[:-split_position]) 28 | _filepath = "/".join(_src_split[-split_position + (1 if skip_first_filepath_element else 0):-1]) 29 | _filename = _src_split[-1] 30 | _idl_tuples.append(_subdir + ":" + _filepath + "/" + _filename) 31 | for output_file_name in output_file_create_func(_filename): 32 | _output_temp = output_directory + "/" if output_directory else "" 33 | _outputs.append(ctx.actions.declare_file(_output_temp + _filepath + "/" + output_file_name)) 34 | 35 | # Step 2: Fixed set of dirnames for msg, srv 36 | _dirnames = ["msg", "srv"] 37 | 38 | # Step 3: Check if any output available ... no output is an error! 39 | if not _subdir: 40 | fail("Nothing to generate.") 41 | 42 | # Return result 43 | return struct( 44 | package_name = package_name, 45 | output_dir = _subdir + "/" + (package_name + "/" if append_extra_package_name else "") + output_directory if output_directory else _subdir, 46 | output_dir_relative = output_directory, 47 | output_dir_subdir = _subdir, 48 | outputs = _outputs, 49 | idl_tuples = _idl_tuples, 50 | dirnames = _dirnames, 51 | ) 52 | 53 | def create_common_config(ctx, *, srcs, output_file_create_func): 54 | return _create_common_config_internal( 55 | ctx, 56 | srcs = srcs, 57 | output_directory = get_package_name(ctx), 58 | split_position = 2, 59 | output_file_create_func = output_file_create_func, 60 | ) 61 | 62 | def create_common_config_for_dds_idl_generator(ctx, *, srcs, output_file_create_func): 63 | return _create_common_config_internal( 64 | ctx, 65 | srcs = srcs, 66 | output_directory = None, 67 | split_position = 2, 68 | output_file_create_func = output_file_create_func, 69 | ) 70 | 71 | def create_common_config_for_apex_middleware_typefiles_generator(ctx, *, output_file_create_func): 72 | return _create_common_config_internal( 73 | ctx, 74 | srcs = ctx.files.srcs, 75 | output_directory = get_package_name(ctx), 76 | split_position = 4, 77 | output_file_create_func = output_file_create_func, 78 | skip_first_filepath_element = True, 79 | append_extra_package_name = True, 80 | ) 81 | -------------------------------------------------------------------------------- /rosidl/detail/misc_support.bzl: -------------------------------------------------------------------------------- 1 | # Copyright 2024 Apex.AI, Inc. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | _POSSIBLE_TYPES = ["msg", "srv", "idl"] 16 | 17 | def get_package_name(ctx): 18 | """Get the name of the package form its rule context label.""" 19 | return ctx.label.package.split("/")[-1] 20 | 21 | def tokenize_message(msg_path): 22 | """ 23 | Split a message into its folder path, type, message name and extension. 24 | 25 | Example: "blah/msg/String.idl" -> ["blah", "msg", "String", "idl"] 26 | 27 | :param msg_path: Path to a message 28 | 29 | :returns: A tuple of path, name, extension: "blah/msg/String.idl" -> ["blah", "String", "idl"] 30 | """ 31 | for type_name in _POSSIBLE_TYPES: 32 | type_with_slashes = "/{}/".format(type_name) 33 | if type_with_slashes in msg_path: 34 | local_folder_path, msg_with_extension = msg_path.split(type_with_slashes) 35 | msg_name, extension = msg_with_extension.split(".") 36 | return local_folder_path, type_name, msg_name, extension 37 | fail("Message source {} must have one of {} prefixes.".format(msg_path, _POSSIBLE_TYPES)) 38 | 39 | def to_snake_case(name): 40 | """ Translate a name to snake case. 41 | Will translate 42 | 'AbcDef' to 'abc_def' 43 | 'ABCDef' to 'a_b_c_def' 44 | """ 45 | words = [] 46 | current_word = "" 47 | for char in name.elems(): 48 | if char == ".": 49 | break 50 | if char.isupper() and current_word: 51 | words.append(current_word) 52 | current_word = "" 53 | current_word += char.lower() 54 | words.append(current_word) 55 | return "_".join(words) 56 | 57 | def to_snake_case_with_exceptions(name): 58 | """ Translate a name to snake case with the execption of multiple upper case 59 | characters in a row. 60 | Will translate 61 | 'AbcDef' to 'abc_def' 62 | 'ABCDef' to 'abc_def' 63 | 'ColorRBGA' to 'color_rgba' 64 | """ 65 | isupper = [c.isupper() or (c == ".") for c in name.elems()] 66 | isupper.append(True) 67 | result = name[0].lower() 68 | for i in range(1, len(name)): 69 | if name[i] == ".": 70 | break 71 | if ((not isupper[i - 1] and isupper[i]) or 72 | (isupper[i - 1] and isupper[i] and not isupper[i + 1])): 73 | result += "_" 74 | result += name[i].lower() 75 | return result 76 | 77 | def to_identifier(name): 78 | res = "" 79 | for char in name.elems(): 80 | if char.isalnum() or char == "_": 81 | res += char 82 | return res 83 | 84 | def extract_single_dirname(files): 85 | if len(files) == 0: 86 | fail("Empty list of files not allowed.") 87 | dirname = files[0].dirname 88 | for f in files[1:]: 89 | if f.dirname != dirname: 90 | fail("Directory names unequal.") 91 | return dirname 92 | -------------------------------------------------------------------------------- /rosidl/detail/rosidl_adapter.bzl: -------------------------------------------------------------------------------- 1 | # Copyright 2024 Apex.AI, Inc. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | load(":detail/misc_support.bzl", "get_package_name", "tokenize_message") 16 | load(":providers.bzl", "MsgsInfo", "create_msgs_info_provider") 17 | 18 | _DUMMY_PACKAGE_XML = """\ 19 | 20 | 21 | 22 | {package_name} 23 | 0.0.1 24 | This is a generated xml 25 | Generated 26 | Apache License 2.0 27 | 28 | 29 | 30 | """ 31 | 32 | def _convert_to_idl_file(ctx, message_file): 33 | """Convert a non-idl file to idl one.""" 34 | 35 | _, type_name, msg_name, extension = tokenize_message(message_file.path) 36 | msg_local_path = "{type_name}/{name}.{extension}".format( 37 | type_name = type_name, 38 | name = msg_name, 39 | extension = extension, 40 | ) 41 | local_idl_file_path = "{name}.{extension}".format(name = msg_name, extension = "idl") 42 | 43 | if extension == "idl": 44 | out_idl_file = ctx.actions.declare_file(msg_local_path) 45 | args = ctx.actions.args() 46 | args.add(message_file) 47 | args.add(out_idl_file) 48 | ctx.actions.run( 49 | inputs = [message_file], 50 | outputs = [out_idl_file], 51 | progress_message = "Copying {} to idl".format(message_file.path), 52 | executable = "/bin/cp", 53 | arguments = [args], 54 | ) 55 | return out_idl_file 56 | elif extension == "srv" or extension == "msg": 57 | # We symlink the input file to the output folder as the python script for the idl adapter 58 | # generates the output file in the same folder as the input file. This is the only way I found 59 | # to make sure the output file is actually populated. 60 | in_file_symlink = ctx.actions.declare_file(msg_local_path) 61 | ctx.actions.symlink( 62 | output = in_file_symlink, 63 | target_file = message_file, 64 | progress_message = "Symlink file: {}".format(msg_local_path), 65 | ) 66 | 67 | # We need a dummy xml to trick the idl adapter script into thinking that we are running it from 68 | # a colcon package for whatever reason. We are not using any dependencies in that script, so 69 | # this should be safe. An alternative would be to give this function the actual xml file, but 70 | # for that it would need to be part of the attrs provided to this rule (specified by the user). 71 | dummy_package_xml = ctx.actions.declare_file("package.xml", sibling = in_file_symlink) 72 | ctx.actions.write( 73 | output = dummy_package_xml, 74 | content = _DUMMY_PACKAGE_XML.format(package_name = get_package_name(ctx)), 75 | ) 76 | 77 | out_idl_file = ctx.actions.declare_file(local_idl_file_path, sibling = in_file_symlink) 78 | args = ctx.actions.args() 79 | args.add(in_file_symlink) 80 | ctx.actions.run( 81 | inputs = [in_file_symlink, dummy_package_xml], 82 | outputs = [out_idl_file], 83 | progress_message = "Convert {} to idl".format(in_file_symlink.path), 84 | executable = { 85 | "msg": ctx.executable._msg2idl_idl_adapter, 86 | "srv": ctx.executable._srv2idl_idl_adapter, 87 | }[extension], 88 | arguments = [args], 89 | ) 90 | return out_idl_file 91 | else: 92 | fail( 93 | "Unable to handle \"" + message_file.path + "\". Message extension is not supported.", 94 | ) 95 | 96 | def _rosidl_adapter_impl(ctx): 97 | idl_files = [] 98 | for src in ctx.files.srcs: 99 | idl_files.append(_convert_to_idl_file(ctx, src)) 100 | return [ 101 | create_msgs_info_provider(srcs = idl_files, deps = ctx.attr.deps), 102 | DefaultInfo( 103 | files = depset(direct = idl_files), 104 | ), 105 | ] 106 | 107 | rosidl_adapter = rule( 108 | implementation = _rosidl_adapter_impl, 109 | provides = [MsgsInfo], 110 | attrs = { 111 | "srcs": attr.label_list( 112 | allow_files = [".idl", ".msg", ".srv"], 113 | mandatory = True, 114 | ), 115 | "deps": attr.label_list( 116 | providers = [MsgsInfo], 117 | ), 118 | "_msg2idl_idl_adapter": attr.label( 119 | executable = True, 120 | default = "@ros2.rosidl//rosidl_adapter:msg2idl", 121 | cfg = "exec", 122 | doc = "A converter from msg to idl files.", 123 | ), 124 | "_srv2idl_idl_adapter": attr.label( 125 | executable = True, 126 | default = "@ros2.rosidl//rosidl_adapter:srv2idl", 127 | cfg = "exec", 128 | doc = "A converter from srv to idl files.", 129 | ), 130 | }, 131 | ) 132 | -------------------------------------------------------------------------------- /rosidl/detail/rosidl_generator_c.bzl: -------------------------------------------------------------------------------- 1 | # Copyright 2024 Apex.AI, Inc. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | load(":detail/cc_library_with_hdrs_extracted_from_srcs.bzl", "cc_library_with_hdrs_extracted_from_srcs") 16 | load(":detail/common_config.bzl", "create_common_config") 17 | load(":detail/misc_support.bzl", "extract_single_dirname", "to_snake_case_with_exceptions") 18 | load(":detail/visiability_control.bzl", "create_visibility_control_h") 19 | load(":providers.bzl", "MsgsInfo") 20 | 21 | _default_attrs = { 22 | "_generator": attr.label( 23 | default = "@ros2.rosidl//rosidl_generator_c:generator", 24 | executable = True, 25 | cfg = "exec", 26 | doc = "A generator used to actually generate", 27 | ), 28 | "_generator_resources": attr.label_list( 29 | default = [ 30 | "@ros2.rosidl//rosidl_generator_c:resource", 31 | ], 32 | cfg = "exec", 33 | ), 34 | "_visibility_control_h_in": attr.label( 35 | default = "@ros2.rosidl//rosidl_generator_c:resource/rosidl_generator_c__visibility_control.h.in", 36 | allow_single_file = True, 37 | ), 38 | } 39 | 40 | def _dict_union(x, y): 41 | z = {} 42 | z.update(x) 43 | z.update(y) 44 | return z 45 | 46 | def _output_files_create(name): 47 | snake_case_name = to_snake_case_with_exceptions(name) 48 | return [ 49 | snake_case_name + "" + ".h", 50 | "detail/" + snake_case_name + "__struct" + ".h", 51 | "detail/" + snake_case_name + "__type_support" + ".h", 52 | "detail/" + snake_case_name + "__functions" + ".h", 53 | "detail/" + snake_case_name + "__functions" + ".c", 54 | ] 55 | 56 | def _build_generator_c_files(ctx, srcs): 57 | # Step 1: Configure 58 | cfg = create_common_config( 59 | ctx, 60 | srcs = srcs, 61 | output_file_create_func = _output_files_create, 62 | ) 63 | 64 | # Step 2: Write config file 65 | _config = { 66 | "package_name": cfg.package_name, 67 | "output_dir": cfg.output_dir, 68 | "template_dir": extract_single_dirname(ctx.files._generator_resources), 69 | "idl_tuples": cfg.idl_tuples, 70 | "target_dependencies": [], 71 | } 72 | arguments_json_file = ctx.actions.declare_file("rosidl_generator_c__arguments.json") 73 | ctx.actions.write( 74 | output = arguments_json_file, 75 | content = json.encode_indent(_config, indent = " "), 76 | ) 77 | 78 | # Step 3: Run rosidl_generator_c 79 | args = ctx.actions.args() 80 | args.add("--generator-arguments-file", arguments_json_file.path) 81 | ctx.actions.run( 82 | executable = ctx.executable._generator, 83 | arguments = [args], 84 | inputs = srcs + [arguments_json_file], 85 | tools = ctx.files._generator_resources, 86 | outputs = cfg.outputs, 87 | ) 88 | 89 | # Step 4: Add visibility control file 90 | create_visibility_control_h( 91 | ctx, 92 | cfg, 93 | output_filename = "rosidl_generator_c__visibility_control.h", 94 | ) 95 | return cfg.outputs 96 | 97 | def _rosidl_generator_c_impl(ctx): 98 | outputs = _build_generator_c_files(ctx, ctx.files.srcs) 99 | return [ 100 | DefaultInfo(files = depset(direct = outputs)), 101 | ] 102 | 103 | _rosidl_generator_c = rule( 104 | implementation = _rosidl_generator_c_impl, 105 | attrs = _dict_union(_default_attrs, {"srcs": attr.label_list(allow_files = [".idl"])}), 106 | ) 107 | 108 | def _rosidl_generator_c_aspect_impl(target, ctx): 109 | outputs = _build_generator_c_files(ctx, target[OutputGroupInfo].rosidl_generator_dds_idl.to_list()) 110 | return [ 111 | DefaultInfo(files = depset(direct = outputs)), 112 | ] 113 | 114 | rosidl_generator_c_aspect = aspect( 115 | implementation = _rosidl_generator_c_aspect_impl, 116 | attrs = _default_attrs, 117 | required_providers = [MsgsInfo], 118 | attr_aspects = ["deps"], 119 | ) 120 | 121 | def cc_rosidl_generator_c_library(*, name, srcs, **kwargs): 122 | _rosidl_generator_c( 123 | name = "_%s_files" % name, 124 | srcs = srcs, 125 | ) 126 | cc_library_with_hdrs_extracted_from_srcs( 127 | name = name, 128 | srcs = [":_%s_files" % name], 129 | strip_include_prefix = ".", 130 | **kwargs 131 | ) 132 | -------------------------------------------------------------------------------- /rosidl/detail/rosidl_generator_cpp.bzl: -------------------------------------------------------------------------------- 1 | # Copyright 2024 Apex.AI, Inc. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | load("@bazel_skylib//rules:common_settings.bzl", "BuildSettingInfo") 16 | load(":detail/cc_library_with_hdrs_extracted_from_srcs.bzl", "cc_library_with_hdrs_extracted_from_srcs") 17 | load(":detail/common_config.bzl", "create_common_config") 18 | load(":detail/misc_support.bzl", "extract_single_dirname", "to_snake_case_with_exceptions") 19 | 20 | def output_files_create(name): 21 | snake_case_name = to_snake_case_with_exceptions(name) 22 | return [ 23 | snake_case_name + ".hpp", 24 | "detail/" + snake_case_name + "__builder" + ".hpp", 25 | "detail/" + snake_case_name + "__struct" + ".hpp", 26 | "detail/" + snake_case_name + "__traits" + ".hpp", 27 | ] 28 | 29 | def _rosidl_generator_cpp_impl(ctx): 30 | # Step 1: Configure 31 | cfg = create_common_config( 32 | ctx, 33 | srcs = ctx.files.srcs, 34 | output_file_create_func = lambda name: output_files_create(name), 35 | ) 36 | 37 | # Step 2: Write config file 38 | _config = { 39 | "package_name": cfg.package_name, 40 | "output_dir": cfg.output_dir, 41 | "template_dir": extract_single_dirname(ctx.files._generator_resources), 42 | "idl_tuples": cfg.idl_tuples, 43 | "target_dependencies": [], 44 | } 45 | arguments_json_file = ctx.actions.declare_file("rosidl_generator_cpp__arguments.json") 46 | ctx.actions.write( 47 | output = arguments_json_file, 48 | content = json.encode_indent(_config, indent = " "), 49 | ) 50 | 51 | # Step 3: Run rosidl_generator_cpp 52 | args = ctx.actions.args() 53 | args.add("--generator-arguments-file", arguments_json_file.path) 54 | ctx.actions.run( 55 | executable = ctx.executable._generator, 56 | arguments = [args], 57 | inputs = ctx.files.srcs + [arguments_json_file], 58 | tools = ctx.files._generator_resources, 59 | outputs = cfg.outputs, 60 | ) 61 | 62 | # Final: Return results 63 | return [ 64 | DefaultInfo( 65 | files = depset(direct = cfg.outputs), 66 | ), 67 | ] 68 | 69 | _rosidl_generator_cpp = rule( 70 | implementation = _rosidl_generator_cpp_impl, 71 | attrs = { 72 | "srcs": attr.label_list(allow_files = [".idl"]), 73 | "_generator": attr.label( 74 | default = "@ros2.rosidl//rosidl_generator_cpp:generator", 75 | executable = True, 76 | cfg = "exec", 77 | doc = "A generator used to actually generate", 78 | ), 79 | "_generator_resources": attr.label_list( 80 | default = [ 81 | "@ros2.rosidl//rosidl_generator_cpp:resource", 82 | ], 83 | cfg = "exec", 84 | ), 85 | }, 86 | ) 87 | 88 | def cc_rosidl_generator_cpp_library(*, name, srcs, **kwargs): 89 | _rosidl_generator_cpp( 90 | name = "_%s_files" % name, 91 | srcs = srcs, 92 | ) 93 | cc_library_with_hdrs_extracted_from_srcs( 94 | name = name, 95 | srcs = [":_%s_files" % name], 96 | strip_include_prefix = ".", 97 | **kwargs 98 | ) 99 | -------------------------------------------------------------------------------- /rosidl/detail/rosidl_generator_dds_idl.bzl: -------------------------------------------------------------------------------- 1 | # Copyright 2024 Apex.AI, Inc. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | load(":detail/common_config.bzl", "create_common_config_for_dds_idl_generator") 16 | load(":detail/misc_support.bzl", "extract_single_dirname") 17 | load(":providers.bzl", "MsgsInfo") 18 | 19 | _default_attrs = { 20 | "_generator": attr.label( 21 | default = "@ros2.rosidl_dds//rosidl_generator_dds_idl:generator", 22 | executable = True, 23 | cfg = "exec", 24 | doc = "A generator used to actually generate the messages.", 25 | ), 26 | "_generator_resources": attr.label_list( 27 | default = [ 28 | "@ros2.rosidl_dds//rosidl_generator_dds_idl:resource", 29 | ], 30 | cfg = "exec", 31 | ), 32 | "_additional_service_templates": attr.label_list( 33 | default = [], 34 | allow_files = [".em"], 35 | doc = "Sometimes due to how python scripts work they need this additional input.", 36 | ), 37 | } 38 | 39 | def _dict_union(x, y): 40 | z = {} 41 | z.update(x) 42 | z.update(y) 43 | return z 44 | 45 | def _output_files_create(name): 46 | return [ 47 | "apex_middleware_typefiles" + "/" + name.replace(".idl", "_.idl"), 48 | ] 49 | 50 | def _build_dds_idl_files(ctx, srcs): 51 | # Step 1: Configure 52 | cfg = create_common_config_for_dds_idl_generator( 53 | ctx, 54 | srcs = srcs, 55 | output_file_create_func = _output_files_create, 56 | ) 57 | 58 | # Step 2: Write config file 59 | _config = { 60 | "package_name": cfg.package_name, 61 | "output_dir": cfg.output_dir, 62 | "template_dir": extract_single_dirname(ctx.files._generator_resources), 63 | "idl_tuples": cfg.idl_tuples, 64 | "target_dependencies": [], 65 | } 66 | arguments_json_file = ctx.actions.declare_file("rosidl_generator_dds_idl__apex_middleware_typefiles__arguments.json") 67 | ctx.actions.write( 68 | output = arguments_json_file, 69 | content = json.encode_indent(_config, indent = " "), 70 | ) 71 | 72 | # Step 3: Run rosidl_generator_c 73 | args = ctx.actions.args() 74 | 75 | args.add("--generator-arguments-file", arguments_json_file.path) 76 | 77 | # args.add("--subfolders", "apex_middleware_typefiles") 78 | # args.add("--extension", "apex_middleware_typefiles_generator.rosidl_generator_dds_idl_extension") 79 | if ctx.attr._additional_service_templates: 80 | args.add("--additional-service-templates") 81 | for p in ctx.files._additional_service_templates: 82 | args.add(p.path) 83 | ctx.actions.run( 84 | executable = ctx.executable._generator, 85 | arguments = [args], 86 | inputs = srcs + ctx.files._additional_service_templates + [arguments_json_file], 87 | tools = ctx.files._generator_resources, 88 | outputs = cfg.outputs, 89 | ) 90 | 91 | # Final: Return output files 92 | return cfg.outputs 93 | 94 | def _rosidl_generator_dds_idl_impl(ctx): 95 | outputs = _build_dds_idl_files(ctx, ctx.files.srcs) 96 | return [ 97 | DefaultInfo(files = depset(direct = outputs)), 98 | ] 99 | 100 | rosidl_generator_dds_idl = rule( 101 | implementation = _rosidl_generator_dds_idl_impl, 102 | attrs = _dict_union( 103 | _default_attrs, 104 | {"srcs": attr.label_list(allow_files = [".idl"])}, 105 | ), 106 | ) 107 | 108 | def _rosidl_generator_dds_idl_aspect_impl(target, ctx): 109 | outputs = _build_dds_idl_files(ctx, target[MsgsInfo].srcs) 110 | return [ 111 | OutputGroupInfo(rosidl_generator_dds_idl = outputs), 112 | ] 113 | 114 | rosidl_generator_dds_idl_aspect = aspect( 115 | implementation = _rosidl_generator_dds_idl_aspect_impl, 116 | attrs = _default_attrs, 117 | required_providers = [MsgsInfo], 118 | attr_aspects = ["deps"], 119 | ) 120 | -------------------------------------------------------------------------------- /rosidl/detail/rosidl_typesupport_c.bzl: -------------------------------------------------------------------------------- 1 | # Copyright 2024 Apex.AI, Inc. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | load(":detail/cc_library_with_hdrs_extracted_from_srcs.bzl", "cc_library_with_hdrs_extracted_from_srcs") 16 | load(":detail/common_config.bzl", "create_common_config") 17 | load(":detail/misc_support.bzl", "extract_single_dirname", "to_snake_case_with_exceptions") 18 | load(":detail/visiability_control.bzl", "create_visibility_control_h") 19 | 20 | def output_files_create(name): 21 | snake_case_name = to_snake_case_with_exceptions(name) 22 | return [ 23 | snake_case_name + "__type_support" + ".cpp", 24 | ] 25 | 26 | def _rosidl_typesupport_c_impl(ctx): 27 | # Step 1: Configure 28 | cfg = create_common_config( 29 | ctx, 30 | srcs = ctx.files.srcs, 31 | output_file_create_func = output_files_create, 32 | ) 33 | 34 | # Step 2: Write config file 35 | _config = { 36 | "package_name": cfg.package_name, 37 | "output_dir": cfg.output_dir, 38 | "template_dir": extract_single_dirname(ctx.files._generator_resources), 39 | "idl_tuples": cfg.idl_tuples, 40 | "target_dependencies": [], 41 | } 42 | arguments_json_file = ctx.actions.declare_file("rosidl_typesupport_c__arguments.json") 43 | ctx.actions.write( 44 | output = arguments_json_file, 45 | content = json.encode_indent(_config, indent = " "), 46 | ) 47 | 48 | # Step 3: Run rosidl_generator_c 49 | args = ctx.actions.args() 50 | args.add("--generator-arguments-file", arguments_json_file.path) 51 | if len(ctx.attr.typesupports) < 1: 52 | fail("Typesupports may not be an empty list") 53 | args.add("--typesupports") 54 | for rmw in ctx.attr.typesupports: 55 | args.add(rmw) 56 | ctx.actions.run( 57 | executable = ctx.executable._generator, 58 | arguments = [args], 59 | inputs = ctx.files.srcs + [arguments_json_file], 60 | tools = ctx.files._generator_resources, 61 | outputs = cfg.outputs, 62 | ) 63 | 64 | # Final: Return results 65 | return [ 66 | DefaultInfo( 67 | files = depset(direct = cfg.outputs), 68 | ), 69 | ] 70 | 71 | _rosidl_typesupport_c = rule( 72 | implementation = _rosidl_typesupport_c_impl, 73 | attrs = { 74 | "srcs": attr.label_list(allow_files = [".idl"]), 75 | "_generator": attr.label( 76 | default = "@ros2.rosidl_typesupport//rosidl_typesupport_c:generator", 77 | executable = True, 78 | cfg = "exec", 79 | doc = "A generator used to actually generate", 80 | ), 81 | "_generator_resources": attr.label_list( 82 | default = [ 83 | "@ros2.rosidl_typesupport//rosidl_typesupport_c:resource", 84 | ], 85 | cfg = "exec", 86 | ), 87 | "_visibility_control_h_in": attr.label( 88 | default = "@ros2.rosidl_typesupport//rosidl_typesupport_c:resource/rosidl_typesupport_c__visibility_control.h.in", 89 | allow_single_file = True, 90 | ), 91 | "typesupports": attr.string_list( 92 | mandatory = True, 93 | doc = "Typesupports that are required to generate the messages.", 94 | ), 95 | }, 96 | ) 97 | 98 | def cc_rosidl_typesupport_c_library(*, name, srcs, typesupports, **kwargs): 99 | _rosidl_typesupport_c( 100 | name = "_%s_files" % name, 101 | srcs = srcs, 102 | typesupports = typesupports, 103 | ) 104 | cc_library_with_hdrs_extracted_from_srcs( 105 | name = name, 106 | srcs = [":_%s_files" % name], 107 | strip_include_prefix = ".", 108 | **kwargs 109 | ) 110 | -------------------------------------------------------------------------------- /rosidl/detail/visiability_control.bzl: -------------------------------------------------------------------------------- 1 | # Copyright 2024 Apex.AI, Inc. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | def create_visibility_control_h(ctx, cfg, *, output_filename): 16 | for _dirname in cfg.dirnames: 17 | visibility_control_h = ctx.actions.declare_file(cfg.output_dir_relative + "/" + _dirname + "/" + output_filename) 18 | cfg.outputs.append(visibility_control_h) 19 | ctx.actions.expand_template( 20 | template = ctx.file._visibility_control_h_in, 21 | output = visibility_control_h, 22 | substitutions = { 23 | "@PROJECT_NAME_UPPER@": cfg.package_name.upper(), 24 | "@PROJECT_NAME@": cfg.package_name, 25 | }, 26 | ) 27 | -------------------------------------------------------------------------------- /rosidl/providers.bzl: -------------------------------------------------------------------------------- 1 | # Copyright 2024 Apex.AI, Inc. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | MsgsInfo = provider( 16 | doc = """ 17 | Provider for a set of idl files containing message definitions. 18 | Fields: 19 | srcs: list of files (*.idl, *.srv) 20 | deps: depset of targets containing a MsgsInfo provider. 21 | """, 22 | fields = [ 23 | "srcs", 24 | "deps", 25 | ], 26 | ) 27 | 28 | def create_msgs_info_provider(*, srcs = None, deps = None): 29 | """ 30 | Create a `MsgsInfo` provider object. 31 | 32 | Arguments: 33 | srcs: idl files containing message and service definitions. 34 | deps: list of dependencies that contain `MsgsInfo` providers. 35 | Dependencies without a `MsgsInfo` provider will be ignored. 36 | """ 37 | srcs = [] if srcs == None else srcs 38 | deps = [] if deps == None else deps 39 | 40 | deps = depset( 41 | direct = [dep for dep in deps if MsgsInfo in dep], 42 | transitive = [dep[MsgsInfo].deps for dep in deps if MsgsInfo in dep], 43 | ) 44 | return MsgsInfo(srcs = srcs, deps = deps) 45 | 46 | def get_files_from_deps(msgs_info): 47 | msgs_info_list = [target[MsgsInfo] for target in msgs_info.deps.to_list()] 48 | files = [] 49 | for msgs_info in msgs_info_list: 50 | files.extend(msgs_info.srcs) 51 | return files 52 | 53 | def get_all_files(msgs_info): 54 | files = get_files_from_deps(msgs_info) 55 | files.extend(msgs_info.srcs) 56 | return files 57 | -------------------------------------------------------------------------------- /thirdparty/BUILD.bazel: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ApexAI/rules_ros/5d2d81bc7779cbdada626be299354a3b5544ba2f/thirdparty/BUILD.bazel -------------------------------------------------------------------------------- /thirdparty/bazel_skylib/BUILD: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ApexAI/rules_ros/5d2d81bc7779cbdada626be299354a3b5544ba2f/thirdparty/bazel_skylib/BUILD -------------------------------------------------------------------------------- /thirdparty/bazel_skylib/repositories.bzl: -------------------------------------------------------------------------------- 1 | # Copyright 2024 Apex.AI, Inc. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") 16 | load("@bazel_tools//tools/build_defs/repo:utils.bzl", "maybe") 17 | 18 | BAZEL_SKYLIB_VERSION = "1.3.0" 19 | BAZEL_SKYLIB_SHA = "74d544d96f4a5bb630d465ca8bbcfe231e3594e5aae57e1edbf17a6eb3ca2506" 20 | 21 | def load_bazel_skylib_repositories(): 22 | maybe( 23 | name = "bazel_skylib", 24 | repo_rule = http_archive, 25 | urls = [ 26 | "https://mirror.bazel.build/github.com/bazelbuild/bazel-skylib/releases/download/{version}/bazel-skylib-{version}.tar.gz".format( 27 | version = BAZEL_SKYLIB_VERSION, 28 | ), 29 | "https://github.com/bazelbuild/bazel-skylib/releases/download/{version}/bazel-skylib-{version}.tar.gz".format( 30 | version = BAZEL_SKYLIB_VERSION, 31 | ), 32 | ], 33 | sha256 = BAZEL_SKYLIB_SHA, 34 | ) 35 | -------------------------------------------------------------------------------- /thirdparty/bazel_skylib/setup.bzl: -------------------------------------------------------------------------------- 1 | # Copyright 2024 Apex.AI, Inc. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | load("@bazel_skylib//:workspace.bzl", "bazel_skylib_workspace") 16 | 17 | def setup_bazel_skylib_repositories(): 18 | bazel_skylib_workspace() 19 | -------------------------------------------------------------------------------- /thirdparty/libyaml/BUILD.bazel: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ApexAI/rules_ros/5d2d81bc7779cbdada626be299354a3b5544ba2f/thirdparty/libyaml/BUILD.bazel -------------------------------------------------------------------------------- /thirdparty/libyaml/libyaml.BUILD.bazel: -------------------------------------------------------------------------------- 1 | # Copyright 2024 Apex.AI, Inc. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | cc_library( 16 | name = "libyaml", 17 | srcs = glob([ 18 | "src/*.c", 19 | "src/*.h", 20 | ]), 21 | hdrs = glob(["include/*.h"]), 22 | defines = [ 23 | 'YAML_VERSION_STRING=\\\"0.2.5\\\"', 24 | "YAML_VERSION_MAJOR=0", 25 | "YAML_VERSION_MINOR=2", 26 | "YAML_VERSION_PATCH=5", 27 | ], 28 | includes = ["include"], 29 | visibility = ["//visibility:public"], 30 | ) 31 | -------------------------------------------------------------------------------- /thirdparty/libyaml/repositories.bzl: -------------------------------------------------------------------------------- 1 | # Copyright 2024 Apex.AI, Inc. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") 16 | load("@bazel_tools//tools/build_defs/repo:utils.bzl", "maybe") 17 | 18 | LIBYAML_VERSION = "0.2.5" 19 | LIBYAML_SHA = "45ec4bc54856a45e9815c897f8f7236c541b7673e18d49504335ece464aa02cc" 20 | 21 | def load_libyaml_repositories(): 22 | maybe( 23 | name = "libyaml", 24 | repo_rule = http_archive, 25 | urls = ["https://github.com/yaml/libyaml/releases/download/{version}/yaml-{version}.zip".format(version = LIBYAML_VERSION)], 26 | sha256 = LIBYAML_SHA, 27 | strip_prefix = "yaml-{version}".format(version = LIBYAML_VERSION), 28 | build_file = "@rules_ros//thirdparty/libyaml:libyaml.BUILD.bazel", 29 | ) 30 | -------------------------------------------------------------------------------- /thirdparty/python/BUILD.bazel: -------------------------------------------------------------------------------- 1 | load("@rules_python//python:pip.bzl", "compile_pip_requirements") 2 | 3 | compile_pip_requirements( 4 | name = "requirements_lock", 5 | ) 6 | -------------------------------------------------------------------------------- /thirdparty/python/install_deps.bzl: -------------------------------------------------------------------------------- 1 | load("@python_deps//:requirements.bzl", _install_deps = "install_deps") 2 | 3 | install_deps = _install_deps 4 | -------------------------------------------------------------------------------- /thirdparty/python/pip_parse.bzl: -------------------------------------------------------------------------------- 1 | load("@python_interpreter//:defs.bzl", "interpreter") 2 | load("@rules_python//python:pip.bzl", _pip_parse = "pip_parse") 3 | 4 | def pip_parse(): 5 | _pip_parse( 6 | name = "python_deps", 7 | python_interpreter_target = interpreter, 8 | requirements_lock = "@rules_ros//thirdparty/python:requirements_lock.txt", 9 | ) 10 | -------------------------------------------------------------------------------- /thirdparty/python/repositories.bzl: -------------------------------------------------------------------------------- 1 | # Copyright 2024 Apex.AI, Inc. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") 16 | load("@bazel_tools//tools/build_defs/repo:utils.bzl", "maybe") 17 | 18 | PYTHON_VERSION = "3.8.13" 19 | RULES_PYTHON_VERSION = "0.12.0" 20 | RULES_PYTHON_SHA = "b593d13bb43c94ce94b483c2858e53a9b811f6f10e1e0eedc61073bd90e58d9c" 21 | 22 | def load_rules_python_repositories(): 23 | maybe( 24 | name = "rules_python", 25 | repo_rule = http_archive, 26 | url = "https://github.com/bazelbuild/rules_python/archive/refs/tags/{version}.tar.gz".format( 27 | version = RULES_PYTHON_VERSION, 28 | ), 29 | sha256 = RULES_PYTHON_SHA, 30 | strip_prefix = "rules_python-{version}".format(version = RULES_PYTHON_VERSION), 31 | ) 32 | -------------------------------------------------------------------------------- /thirdparty/python/requirements_lock.in: -------------------------------------------------------------------------------- 1 | empy==3.3.2 2 | jinja2==3.1.2 3 | catkin_pkg==0.4.14 4 | lark==0.10.1 5 | pytest==6.2.4 6 | pyyaml==6.0.0 -------------------------------------------------------------------------------- /thirdparty/python/setup_toolchain.bzl: -------------------------------------------------------------------------------- 1 | load("@rules_python//python:repositories.bzl", "python_register_toolchains") 2 | load("@rules_ros//thirdparty/python:repositories.bzl", "PYTHON_VERSION") 3 | 4 | def register_python_toolchain(): 5 | python_register_toolchains( 6 | name = "python_interpreter", 7 | # Available versions are listed in @rules_python//python:versions.bzl. 8 | python_version = PYTHON_VERSION, 9 | ) 10 | -------------------------------------------------------------------------------- /thirdparty/rules_pkg/BUILD: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ApexAI/rules_ros/5d2d81bc7779cbdada626be299354a3b5544ba2f/thirdparty/rules_pkg/BUILD -------------------------------------------------------------------------------- /thirdparty/rules_pkg/repositories.bzl: -------------------------------------------------------------------------------- 1 | load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") 2 | load("@bazel_tools//tools/build_defs/repo:utils.bzl", "maybe") 3 | 4 | RULES_PKG_VERSION = struct( 5 | version = "0.10.1", 6 | sha256 = "d250924a2ecc5176808fc4c25d5cf5e9e79e6346d79d5ab1c493e289e722d1d0", 7 | ) 8 | 9 | def load_rules_pkg_repositories(): 10 | maybe( 11 | name = "rules_pkg", 12 | repo_rule = http_archive, 13 | urls = [ 14 | "https://github.com/bazelbuild/rules_pkg/releases/download/{version}/rules_pkg-{version}.tar.gz".format( 15 | version = RULES_PKG_VERSION.version, 16 | ), 17 | ], 18 | sha256 = RULES_PKG_VERSION.sha256, 19 | ) 20 | -------------------------------------------------------------------------------- /thirdparty/rules_pkg/setup.bzl: -------------------------------------------------------------------------------- 1 | load("@rules_pkg//:deps.bzl", "rules_pkg_dependencies") 2 | 3 | def setup_rules_pkg_repositories(): 4 | rules_pkg_dependencies() 5 | -------------------------------------------------------------------------------- /thirdparty/setup_01.bzl: -------------------------------------------------------------------------------- 1 | # Copyright 2024 Apex.AI, Inc. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | load("@rules_ros//thirdparty/bazel_skylib:repositories.bzl", "load_bazel_skylib_repositories") 16 | load("@rules_ros//thirdparty/libyaml:repositories.bzl", "load_libyaml_repositories") 17 | load("@rules_ros//thirdparty/python:repositories.bzl", "load_rules_python_repositories") 18 | load("@rules_ros//thirdparty/rules_pkg:repositories.bzl", "load_rules_pkg_repositories") 19 | 20 | def setup_01(): 21 | load_rules_python_repositories() 22 | load_libyaml_repositories() 23 | load_bazel_skylib_repositories() 24 | load_rules_pkg_repositories() 25 | -------------------------------------------------------------------------------- /thirdparty/setup_02.bzl: -------------------------------------------------------------------------------- 1 | # Copyright 2024 Apex.AI, Inc. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | load("@rules_ros//thirdparty/bazel_skylib:setup.bzl", "setup_bazel_skylib_repositories") 16 | load("@rules_ros//thirdparty/python:setup_toolchain.bzl", "register_python_toolchain") 17 | load("@rules_ros//thirdparty/rules_pkg:setup.bzl", "setup_rules_pkg_repositories") 18 | 19 | def setup_02(): 20 | register_python_toolchain() 21 | setup_bazel_skylib_repositories() 22 | setup_rules_pkg_repositories() 23 | -------------------------------------------------------------------------------- /thirdparty/setup_03.bzl: -------------------------------------------------------------------------------- 1 | # Copyright 2024 Apex.AI, Inc. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | load("@rules_ros//thirdparty/python:pip_parse.bzl", "pip_parse") 16 | 17 | def setup_03(): 18 | pip_parse() 19 | -------------------------------------------------------------------------------- /thirdparty/setup_04.bzl: -------------------------------------------------------------------------------- 1 | # Copyright 2024 Apex.AI, Inc. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | load("@rules_ros//thirdparty/python:install_deps.bzl", "install_deps") 16 | 17 | def setup_04(): 18 | install_deps() 19 | -------------------------------------------------------------------------------- /utils/BUILD.bazel: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ApexAI/rules_ros/5d2d81bc7779cbdada626be299354a3b5544ba2f/utils/BUILD.bazel -------------------------------------------------------------------------------- /utils/template_expansion.bzl: -------------------------------------------------------------------------------- 1 | # Copyright 2024 Apex.AI, Inc. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | def _expand_template_impl(ctx): 16 | """Get am .em template and produce a header-only library from the generated file.""" 17 | package_name = ctx.attr.package_name 18 | template_file = ctx.file.template 19 | if not template_file.basename.endswith(".em"): 20 | fail("The template file must end with '.em'") 21 | if len(ctx.attr.variables) > 1: 22 | fail("More than one variable definition not implemented.") 23 | variable = ctx.attr.variables.keys()[0] if len(ctx.attr.variables) != 0 else None 24 | values = ctx.attr.variables[variable] if variable != None else [None] 25 | outputs = [] 26 | 27 | for value in values: 28 | out_file_basename = ctx.attr.output_pattern.format(**{variable: value}) if ctx.attr.output_pattern != "" else template_file.basename.rsplit(".", 1)[0] 29 | output_file = ctx.actions.declare_file( 30 | "include/{package_name}/{file_name}".format( 31 | package_name = package_name, 32 | file_name = out_file_basename, 33 | ), 34 | ) 35 | args = [output_file.path] + [template_file.path] 36 | if value != None: 37 | args.extend(["-D", variable + ' = "' + value + '"']) 38 | ctx.actions.run( 39 | inputs = [template_file], 40 | outputs = [output_file], 41 | progress_message = "Generating a header from template {}".format(template_file.path), 42 | executable = ctx.executable.generator_script, 43 | arguments = args, 44 | ) 45 | outputs.append(output_file) 46 | 47 | includes_folder = output_file.path.rsplit(package_name, 1)[0] 48 | return [CcInfo( 49 | compilation_context = cc_common.create_compilation_context( 50 | includes = depset([includes_folder]), 51 | headers = depset(outputs), 52 | ), 53 | )] 54 | 55 | cc_library_from_template = rule( 56 | implementation = _expand_template_impl, 57 | output_to_genfiles = True, 58 | attrs = { 59 | "package_name": attr.string( 60 | doc = "Name of the ROS package.", 61 | ), 62 | "template": attr.label( 63 | mandatory = True, 64 | allow_single_file = [".em"], 65 | doc = "Input file that will be used to generate the output file.", 66 | ), 67 | "output_pattern": attr.string( 68 | mandatory = False, 69 | default = "", 70 | ), 71 | "variables": attr.string_list_dict( 72 | mandatory = False, 73 | doc = "Variables, that will be used for looping through the template expansion.", 74 | default = {}, 75 | ), 76 | "generator_script": attr.label( 77 | mandatory = True, 78 | executable = True, 79 | cfg = "exec", 80 | doc = "A generator script used to generate the output C++ file from the template one.", 81 | ), 82 | }, 83 | ) 84 | --------------------------------------------------------------------------------