Skip to content

Commit

Permalink
feat: port to bzlmod
Browse files Browse the repository at this point in the history
  • Loading branch information
finn-ball authored and Finn Ball committed Jun 17, 2024
1 parent f200d4e commit 6d23557
Show file tree
Hide file tree
Showing 13 changed files with 82 additions and 230 deletions.
8 changes: 0 additions & 8 deletions .bazelrc
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,6 @@
# Mandatory at the moment for Bazel 7.0.0.
build --noincompatible_sandbox_hermetic_tmp

# This is mandatory if your build env doesn't have a proper Python 3 exe
# -- like the CI build image for this repo.
# The build image is using a fake python exe, see
# https://github.com/mvukov/bazel_builder/blob/main/Dockerfile.
# If blzmod is enabled, but not used as in this repo at the moment),
# then bazel for some reason tries to auto-detect a Python exe.
build --noenable_bzlmod

# Fix the wrong default to generate __init__.py to delimit a Python package.
# This is a mandatory flag.
build --incompatible_default_to_explicit_init_py
Expand Down
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
bazel-*
__pycache__
user.bazelrc
MODULE.bazel*
MODULE.bazel.lock
71 changes: 71 additions & 0 deletions MODULE.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
module(name = "rules_ros", repo_name = "com_github_mvukov_rules_ros")

bazel_dep(name = "bazel_skylib", version = "1.6.1")
bazel_dep(name = "bzip2", version = "1.0.8.bcr.1")
bazel_dep(name = "eigen", version = "3.4.0.bcr.1")
bazel_dep(name = "gflags", version = "2.2.2")
bazel_dep(name = "glog", version = "0.7.0")
bazel_dep(name = "googletest", version = "1.14.0.bcr.1")
bazel_dep(name = "lz4", version = "1.9.4")
bazel_dep(name = "platforms", version = "0.0.10")
bazel_dep(name = "rules_cc", version = "0.0.9")
bazel_dep(name = "rules_foreign_cc", version = "0.10.1")
bazel_dep(name = "rules_python", version = "0.32.2")

non_module_ros_repositories = use_extension("//extensions:ros_repositories.bzl", "non_module_dependencies")
use_repo(
non_module_ros_repositories,
"console_bridge",
"roscpp_core",
"rosconsole",
"ros_genmsg",
"ros_gencpp",
"ros_genpy",
"ros_std_msgs",
"ros_comm_msgs",
"ros_comm",
"ros_ros",
"ros_common_msgs",
"ros_actionlib",
"ros_dynamic_reconfigure",
"ros_geometry2",
"orocos_kdl",
"urdfdom_headers",
"tinyxml",
"urdfdom",
)

bazel_dep(name = "rules_boost")
archive_override(
module_name = "rules_boost",
urls = "https://github.com/nelhage/rules_boost/archive/42d8155d8f20a1aee8ee20b7903a495bdfb9befd.zip",
strip_prefix = "rules_boost-42d8155d8f20a1aee8ee20b7903a495bdfb9befd",
integrity = "sha256-I1iTdF3qckTmDRab+0yjA37Iya9AOGvEGJVoPtfpADM=",
)

non_module_boost_repositories = use_extension("@rules_boost//:boost/repositories.bzl", "non_module_dependencies")
use_repo(
non_module_boost_repositories,
"boost",
)

python = use_extension("@rules_python//python/extensions:python.bzl", "python")
python.toolchain(
is_default = True,
python_version = "3.10",
)
use_repo(python, "python_3_10", "python_versions")

pip = use_extension("@rules_python//python/extensions:pip.bzl", "pip")
pip.parse(
hub_name = "rules_ros_pip_deps",
python_version = "3.10",
requirements_lock = "@com_github_mvukov_rules_ros//:requirements_lock.txt",
)
use_repo(pip, "rules_ros_pip_deps")

internal_deps = use_extension("@rules_python//python/private/bzlmod:internal_deps.bzl", "internal_deps")
use_repo(
internal_deps,
"rules_python_internal",
)
34 changes: 0 additions & 34 deletions WORKSPACE

This file was deleted.

Empty file added extensions/BUILD.bazel
Empty file.
8 changes: 8 additions & 0 deletions extensions/ros_repositories.bzl
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
load("//repositories:repositories.bzl", "ros_repositories")

def _non_module_dependencies_impl(_ctx):
ros_repositories()

non_module_dependencies = module_extension(
implementation = _non_module_dependencies_impl,
)
16 changes: 0 additions & 16 deletions repositories/bzip2.BUILD.bazel

This file was deleted.

15 changes: 0 additions & 15 deletions repositories/deps.bzl

This file was deleted.

57 changes: 0 additions & 57 deletions repositories/eigen.BUILD.bazel

This file was deleted.

16 changes: 0 additions & 16 deletions repositories/lz4.BUILD.bazel

This file was deleted.

81 changes: 0 additions & 81 deletions repositories/repositories.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -7,60 +7,6 @@ load("@bazel_tools//tools/build_defs/repo:utils.bzl", "maybe")
def ros_repositories():
"""Imports external/third-party repositories.
"""
maybe(
http_archive,
name = "rules_python",
sha256 = "4912ced70dc1a2a8e4b86cec233b192ca053e82bc72d877b98e126156e8f228d",
strip_prefix = "rules_python-0.32.2",
url = "https://github.com/bazelbuild/rules_python/archive/refs/tags/0.32.2.tar.gz",
)

maybe(
http_archive,
name = "bazel_skylib",
urls = ["https://github.com/bazelbuild/bazel-skylib/releases/download/1.5.0/bazel-skylib-1.5.0.tar.gz"],
sha256 = "cd55a062e763b9349921f0f5db8c3933288dc8ba4f76dd9416aac68acee3cb94",
)

maybe(
http_archive,
name = "com_github_gflags_gflags",
sha256 = "34af2f15cf7367513b352bdcd2493ab14ce43692d2dcd9dfc499492966c64dcf",
strip_prefix = "gflags-2.2.2",
urls = ["https://github.com/gflags/gflags/archive/v2.2.2.tar.gz"],
)

maybe(
http_archive,
name = "com_github_google_glog",
sha256 = "62efeb57ff70db9ea2129a16d0f908941e355d09d6d83c9f7b18557c0a7ab59e",
strip_prefix = "glog-d516278b1cd33cd148e8989aec488b6049a4ca0b",
urls = ["https://github.com/google/glog/archive/d516278b1cd33cd148e8989aec488b6049a4ca0b.zip"],
)

maybe(
http_archive,
name = "googletest",
sha256 = "8ad598c73ad796e0d8280b082cebd82a630d73e73cd3c70057938a6501bba5d7",
strip_prefix = "googletest-1.14.0",
url = "https://github.com/google/googletest/archive/refs/tags/v1.14.0.tar.gz",
)

maybe(
http_archive,
name = "rules_foreign_cc",
sha256 = "476303bd0f1b04cc311fc258f1708a5f6ef82d3091e53fd1977fa20383425a6a",
strip_prefix = "rules_foreign_cc-0.10.1",
url = "https://github.com/bazelbuild/rules_foreign_cc/archive/refs/tags/0.10.1.tar.gz",
)

maybe(
http_archive,
name = "com_github_nelhage_rules_boost",
sha256 = "90028713d869769d49a9f26a57e89e9f0e83cc0edc1208727aecf0e3ee094967",
strip_prefix = "rules_boost-f621ad7bec2abf5a597ed1271fd823d2761943b2",
urls = ["https://github.com/nelhage/rules_boost/archive/f621ad7bec2abf5a597ed1271fd823d2761943b2.zip"],
)

maybe(
http_archive,
Expand Down Expand Up @@ -134,24 +80,6 @@ def ros_repositories():
urls = ["https://github.com/ros/ros_comm_msgs/archive/1.11.3.tar.gz"],
)

maybe(
http_archive,
name = "lz4",
build_file = "@com_github_mvukov_rules_ros//repositories:lz4.BUILD.bazel",
sha256 = "030644df4611007ff7dc962d981f390361e6c97a34e5cbc393ddfbe019ffe2c1",
strip_prefix = "lz4-1.9.3",
urls = ["https://github.com/lz4/lz4/archive/v1.9.3.tar.gz"],
)

maybe(
http_archive,
name = "bzip2",
build_file = "@com_github_mvukov_rules_ros//repositories:bzip2.BUILD.bazel",
sha256 = "ab5a03176ee106d3f0fa90e381da478ddae405918153cca248e682cd0c4a2269",
strip_prefix = "bzip2-1.0.8",
urls = ["https://sourceware.org/pub/bzip2/bzip2-1.0.8.tar.gz"],
)

# Branched off ros_comm 1.15.9. Changes are in branch feature/rules_ros.
maybe(
http_archive,
Expand Down Expand Up @@ -200,15 +128,6 @@ def ros_repositories():

############################################################################

maybe(
http_archive,
name = "eigen",
build_file = "@com_github_mvukov_rules_ros2//repositories:eigen.BUILD.bazel",
sha256 = "8586084f71f9bde545ee7fa6d00288b264a2b7ac3607b974e54d13e7162c1c72",
strip_prefix = "eigen-3.4.0",
urls = ["https://gitlab.com/libeigen/eigen/-/archive/3.4.0/eigen-3.4.0.tar.gz"],
)

maybe(
http_archive,
name = "ros_geometry2",
Expand Down
2 changes: 1 addition & 1 deletion repositories/ros_comm.BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,7 @@ cc_ros_library(
":roslz4",
"@boost//:filesystem",
"@boost//:format",
"@bzip2",
"@bzip2//:bz2",
"@console_bridge",
"@roscpp_core//:roscpp_serialization",
"@roscpp_core//:roscpp_traits",
Expand Down
2 changes: 1 addition & 1 deletion repositories/rosconsole.BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ cc_ros_library(
"@boost//:regex",
"@boost//:system",
"@boost//:thread",
"@com_github_google_glog//:glog",
"@glog",
"@roscpp_core//:cpp_common",
"@roscpp_core//:rostime",
],
Expand Down

0 comments on commit 6d23557

Please sign in to comment.