Skip to content

Commit

Permalink
Use custom cargo-bazel
Browse files Browse the repository at this point in the history
  • Loading branch information
mvukov committed Jul 7, 2024
1 parent af957a9 commit deddc4e
Show file tree
Hide file tree
Showing 6 changed files with 59 additions and 49 deletions.
5 changes: 4 additions & 1 deletion WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,10 @@ rust_setup_stage_2()

load("//repositories:rust_setup_stage_3.bzl", "rust_setup_stage_3")

rust_setup_stage_3()
rust_setup_stage_3(
# Only needed for CI here, see https://github.com/bazelbuild/rules_rust/pull/2698.
generator = "@com_github_mvukov_rules_ros2_cargo_bazel//:cargo-bazel",
)

load("//repositories:rust_setup_stage_4.bzl", "rust_setup_stage_4")

Expand Down
13 changes: 6 additions & 7 deletions examples/WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,10 @@ rust_setup_stage_2()

load("@com_github_mvukov_rules_ros2//repositories:rust_setup_stage_3.bzl", "rust_setup_stage_3")

rust_setup_stage_3()
rust_setup_stage_3(
# Only needed for CI here, see https://github.com/bazelbuild/rules_rust/pull/2698.
generator = "@com_github_mvukov_rules_ros2_cargo_bazel//:cargo-bazel",
)

load("@com_github_mvukov_rules_ros2//repositories:rust_setup_stage_4.bzl", "rust_setup_stage_4")

Expand All @@ -76,18 +79,14 @@ load("@rules_rust//crate_universe:defs.bzl", "crate", "crates_repository", "rend
crates_repository(
name = "examples_crate_index",
cargo_lockfile = "//:examples_cargo.lock",
# Only needed for CI here, see https://github.com/bazelbuild/rules_rust/pull/2698.
generator = "@com_github_mvukov_rules_ros2_cargo_bazel//:cargo-bazel",
lockfile = "//:examples_cargo_bazel.lock",
packages = {
"signal-hook": crate.spec(
version = "0.3",
),
},
# Setting the default package name to `""` forces the use of the macros defined in this repository
# to always use the root package when looking for dependencies or aliases. This should be considered
# optional as the repository also exposes alises for easy access to all dependencies.
render_config = render_config(
default_package_name = "",
),
)

load("@examples_crate_index//:defs.bzl", "crate_repositories")
Expand Down
14 changes: 7 additions & 7 deletions examples/examples_cargo_bazel.lock
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"checksum": "7c081874d6f965d85626fc45037c9ce86b518c0cfa66ff177c0da2d928498142",
"checksum": "33883b467ee6ea9debe7140882d3fa0a7a3b85fa991e49cd15698d1c382e7ae7",
"crates": {
"direct-cargo-bazel-deps 0.0.1": {
"name": "direct-cargo-bazel-deps",
Expand All @@ -12,7 +12,7 @@
"crate_name": "direct_cargo_bazel_deps",
"crate_root": ".direct_cargo_bazel_deps.rs",
"srcs": {
"allow_empty": false,
"allow_empty": true,
"include": [
"**/*.rs"
]
Expand Down Expand Up @@ -57,7 +57,7 @@
"crate_name": "libc",
"crate_root": "src/lib.rs",
"srcs": {
"allow_empty": false,
"allow_empty": true,
"include": [
"**/*.rs"
]
Expand All @@ -69,7 +69,7 @@
"crate_name": "build_script_build",
"crate_root": "build.rs",
"srcs": {
"allow_empty": false,
"allow_empty": true,
"include": [
"**/*.rs"
]
Expand Down Expand Up @@ -129,7 +129,7 @@
"crate_name": "signal_hook",
"crate_root": "src/lib.rs",
"srcs": {
"allow_empty": false,
"allow_empty": true,
"include": [
"**/*.rs"
]
Expand All @@ -141,7 +141,7 @@
"crate_name": "build_script_build",
"crate_root": "build.rs",
"srcs": {
"allow_empty": false,
"allow_empty": true,
"include": [
"**/*.rs"
]
Expand Down Expand Up @@ -210,7 +210,7 @@
"crate_name": "signal_hook_registry",
"crate_root": "src/lib.rs",
"srcs": {
"allow_empty": false,
"allow_empty": true,
"include": [
"**/*.rs"
]
Expand Down
50 changes: 25 additions & 25 deletions repositories/rust/Cargo.Bazel.lock
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"checksum": "632f9e467d85430f369e3206c034af3beff188f493b896e07550c11708258a0b",
"checksum": "f74560aaa8935947b45b8fbdeea50f6d00c3b4f5f10669905c7a700e4ba527fb",
"crates": {
"autocfg 1.3.0": {
"name": "autocfg",
Expand All @@ -17,7 +17,7 @@
"crate_name": "autocfg",
"crate_root": "src/lib.rs",
"srcs": {
"allow_empty": false,
"allow_empty": true,
"include": [
"**/*.rs"
]
Expand Down Expand Up @@ -51,7 +51,7 @@
"crate_name": "direct_cargo_bazel_deps",
"crate_root": ".direct_cargo_bazel_deps.rs",
"srcs": {
"allow_empty": false,
"allow_empty": true,
"include": [
"**/*.rs"
]
Expand Down Expand Up @@ -100,7 +100,7 @@
"crate_name": "futures",
"crate_root": "src/lib.rs",
"srcs": {
"allow_empty": false,
"allow_empty": true,
"include": [
"**/*.rs"
]
Expand Down Expand Up @@ -183,7 +183,7 @@
"crate_name": "futures_channel",
"crate_root": "src/lib.rs",
"srcs": {
"allow_empty": false,
"allow_empty": true,
"include": [
"**/*.rs"
]
Expand Down Expand Up @@ -244,7 +244,7 @@
"crate_name": "futures_core",
"crate_root": "src/lib.rs",
"srcs": {
"allow_empty": false,
"allow_empty": true,
"include": [
"**/*.rs"
]
Expand Down Expand Up @@ -290,7 +290,7 @@
"crate_name": "futures_executor",
"crate_root": "src/lib.rs",
"srcs": {
"allow_empty": false,
"allow_empty": true,
"include": [
"**/*.rs"
]
Expand Down Expand Up @@ -352,7 +352,7 @@
"crate_name": "futures_io",
"crate_root": "src/lib.rs",
"srcs": {
"allow_empty": false,
"allow_empty": true,
"include": [
"**/*.rs"
]
Expand Down Expand Up @@ -397,7 +397,7 @@
"crate_name": "futures_macro",
"crate_root": "src/lib.rs",
"srcs": {
"allow_empty": false,
"allow_empty": true,
"include": [
"**/*.rs"
]
Expand Down Expand Up @@ -453,7 +453,7 @@
"crate_name": "futures_sink",
"crate_root": "src/lib.rs",
"srcs": {
"allow_empty": false,
"allow_empty": true,
"include": [
"**/*.rs"
]
Expand Down Expand Up @@ -499,7 +499,7 @@
"crate_name": "futures_task",
"crate_root": "src/lib.rs",
"srcs": {
"allow_empty": false,
"allow_empty": true,
"include": [
"**/*.rs"
]
Expand Down Expand Up @@ -545,7 +545,7 @@
"crate_name": "futures_util",
"crate_root": "src/lib.rs",
"srcs": {
"allow_empty": false,
"allow_empty": true,
"include": [
"**/*.rs"
]
Expand Down Expand Up @@ -652,7 +652,7 @@
"crate_name": "memchr",
"crate_root": "src/lib.rs",
"srcs": {
"allow_empty": false,
"allow_empty": true,
"include": [
"**/*.rs"
]
Expand Down Expand Up @@ -699,7 +699,7 @@
"crate_name": "pin_project_lite",
"crate_root": "src/lib.rs",
"srcs": {
"allow_empty": false,
"allow_empty": true,
"include": [
"**/*.rs"
]
Expand Down Expand Up @@ -738,7 +738,7 @@
"crate_name": "pin_utils",
"crate_root": "src/lib.rs",
"srcs": {
"allow_empty": false,
"allow_empty": true,
"include": [
"**/*.rs"
]
Expand Down Expand Up @@ -777,7 +777,7 @@
"crate_name": "proc_macro2",
"crate_root": "src/lib.rs",
"srcs": {
"allow_empty": false,
"allow_empty": true,
"include": [
"**/*.rs"
]
Expand All @@ -789,7 +789,7 @@
"crate_name": "build_script_build",
"crate_root": "build.rs",
"srcs": {
"allow_empty": false,
"allow_empty": true,
"include": [
"**/*.rs"
]
Expand Down Expand Up @@ -853,7 +853,7 @@
"crate_name": "quote",
"crate_root": "src/lib.rs",
"srcs": {
"allow_empty": false,
"allow_empty": true,
"include": [
"**/*.rs"
]
Expand Down Expand Up @@ -908,7 +908,7 @@
"crate_name": "serde",
"crate_root": "src/lib.rs",
"srcs": {
"allow_empty": false,
"allow_empty": true,
"include": [
"**/*.rs"
]
Expand All @@ -920,7 +920,7 @@
"crate_name": "build_script_build",
"crate_root": "build.rs",
"srcs": {
"allow_empty": false,
"allow_empty": true,
"include": [
"**/*.rs"
]
Expand Down Expand Up @@ -991,7 +991,7 @@
"crate_name": "serde_derive",
"crate_root": "src/lib.rs",
"srcs": {
"allow_empty": false,
"allow_empty": true,
"include": [
"**/*.rs"
]
Expand Down Expand Up @@ -1053,7 +1053,7 @@
"crate_name": "slab",
"crate_root": "src/lib.rs",
"srcs": {
"allow_empty": false,
"allow_empty": true,
"include": [
"**/*.rs"
]
Expand All @@ -1065,7 +1065,7 @@
"crate_name": "build_script_build",
"crate_root": "build.rs",
"srcs": {
"allow_empty": false,
"allow_empty": true,
"include": [
"**/*.rs"
]
Expand Down Expand Up @@ -1133,7 +1133,7 @@
"crate_name": "syn",
"crate_root": "src/lib.rs",
"srcs": {
"allow_empty": false,
"allow_empty": true,
"include": [
"**/*.rs"
]
Expand Down Expand Up @@ -1201,7 +1201,7 @@
"crate_name": "unicode_ident",
"crate_root": "src/lib.rs",
"srcs": {
"allow_empty": false,
"allow_empty": true,
"include": [
"**/*.rs"
]
Expand Down
17 changes: 15 additions & 2 deletions repositories/rust_setup_stage_1.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ def rust_setup_stage_1():
maybe(
http_archive,
name = "rules_rust",
integrity = "sha256-pt9MIrs/tDVzpMQIjvbQ+v44oOzQ+FrSH/2IiAAzcDA=",
sha256 = "17c53bf800b932f32d3ca19d2cb9e8ad533ce1c0d729f0d183077bfddab7ad46",
patch_args = ["-p1"],
patches = ["@com_github_mvukov_rules_ros2//repositories/patches:rules_rust_fix_collect_deps.patch"],
urls = ["https://github.com/bazelbuild/rules_rust/releases/download/0.44.0/rules_rust-v0.44.0.tar.gz"],
url = "https://github.com/bazelbuild/rules_rust/releases/download/0.46.0/rules_rust-v0.46.0.tar.gz",
)

maybe(
Expand All @@ -25,3 +25,16 @@ def rust_setup_stage_1():
"@com_github_mvukov_rules_ros2//repositories/patches:ros2_rust_no_msg_vendoring.patch",
],
)

# Only needed for CI, see https://github.com/bazelbuild/rules_rust/pull/2698.
maybe(
http_archive,
name = "com_github_mvukov_rules_ros2_cargo_bazel",
build_file_content = """
exports_files([
"cargo-bazel",
])
""",
sha256 = "6d6d68b898b38cb58d3c29e2e54d5795e2f652ebcac1ecf3bb0ac99fc86480e7",
url = "https://github.com/mvukov/rules_rust/releases/download/0.46.0-mvukov-cargo-bazel/cargo-bazel.zip",
)
9 changes: 2 additions & 7 deletions repositories/rust_setup_stage_3.bzl
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
load("@rules_rust//crate_universe:defs.bzl", "crate", "crates_repository", "render_config")

def rust_setup_stage_3():
def rust_setup_stage_3(**kwargs):
crates_repository(
name = "rules_ros2_crate_index",
cargo_lockfile = "@com_github_mvukov_rules_ros2//repositories/rust:Cargo.lock",
Expand All @@ -14,10 +14,5 @@ def rust_setup_stage_3():
version = "1",
),
},
# Setting the default package name to `""` forces the use of the macros defined in this repository
# to always use the root package when looking for dependencies or aliases. This should be considered
# optional as the repository also exposes alises for easy access to all dependencies.
render_config = render_config(
default_package_name = "",
),
**kwargs
)

0 comments on commit deddc4e

Please sign in to comment.