Skip to content

Commit e738925

Browse files
authored
Replace cargo-raze with rules_rust's crate universe. (#181)
Signed-off-by: Piotr Sikora <[email protected]>
1 parent 96f791a commit e738925

20 files changed

+1217
-494
lines changed

.github/workflows/rust.yml

+5-7
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ jobs:
4242
run: |
4343
go install github.com/google/addlicense@latest
4444
export PATH=$PATH:$(go env GOPATH)/bin
45-
addlicense -check .
45+
addlicense -check -ignore "bazel/cargo/remote/**" .
4646
4747
bazel:
4848
runs-on: ubuntu-latest
@@ -63,7 +63,7 @@ jobs:
6363
~/.cargo/.crates2.json
6464
~/.cargo/bin
6565
~/.cargo/registry
66-
key: ${{ hashFiles('WORKSPACE', '.bazelrc', '.bazelversion', 'bazel/cargo/Cargo.raze.lock', 'bazel/dependencies.bzl', 'bazel/repositories.bzl') }}
66+
key: ${{ hashFiles('WORKSPACE', '.bazelrc', '.bazelversion', 'bazel/cargo/Cargo.Bazel.lock', 'bazel/dependencies.bzl', 'bazel/repositories.bzl') }}
6767

6868
- name: Build (wasm32-unknown-unknown)
6969
run: bazelisk --noworkspace_rc build --platforms=@rules_rust//rust/platform:wasm //...
@@ -78,11 +78,9 @@ jobs:
7878
buildifier -mode=check WORKSPACE
7979
buildifier -mode=check BUILD
8080
81-
- name: Format (cargo raze)
81+
- name: Format (rules_rust)
8282
run: |
83-
mv bazel/cargo/Cargo.raze.lock Cargo.lock
84-
bazelisk --noworkspace_rc run @cargo_raze//:raze -- --manifest-path=$(pwd)/Cargo.toml
85-
mv Cargo.lock bazel/cargo/Cargo.raze.lock
83+
bazelisk --noworkspace_rc run //bazel/cargo:crates_vendor
8684
git diff --exit-code
8785
8886
stable:
@@ -181,7 +179,7 @@ jobs:
181179

182180
- name: Run cargo audit
183181
run: |
184-
cp -p bazel/cargo/Cargo.raze.lock .
182+
cp -p bazel/cargo/Cargo.Bazel.lock Cargo.lock
185183
cargo audit
186184
187185
example:

BUILD

+6-2
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,10 @@
1515
load("@rules_rust//cargo:cargo_build_script.bzl", "cargo_build_script")
1616
load("@rules_rust//rust:defs.bzl", "rust_library")
1717

18+
exports_files([
19+
"Cargo.toml",
20+
])
21+
1822
cargo_build_script(
1923
name = "proxy_wasm_build_script",
2024
srcs = ["build.rs"],
@@ -30,7 +34,7 @@ rust_library(
3034
visibility = ["//visibility:public"],
3135
deps = [
3236
":proxy_wasm_build_script",
33-
"//bazel/cargo:hashbrown",
34-
"//bazel/cargo:log",
37+
"//bazel/cargo/remote:hashbrown",
38+
"//bazel/cargo/remote:log",
3539
],
3640
)

Cargo.toml

-5
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,3 @@ opt-level = 3
2020
codegen-units = 1
2121
panic = "abort"
2222
strip = "debuginfo"
23-
24-
[package.metadata.raze]
25-
package_aliases_dir = "bazel/cargo"
26-
workspace_path = "//bazel/cargo"
27-
genmode = "Remote"

README.md

+3-2
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
When updating dependencies, you need to regenerate Bazel `BUILD` files to match updated `Cargo.toml`:
3333

3434
```sh
35-
cargo install cargo-raze --version 0.15.0
36-
cargo raze --generate-lockfile
35+
cargo generate-lockfile
36+
mv Cargo.lock bazel/cargo/Cargo.Bazel.lock
37+
bazel run //bazel/cargo:crates_vendor
3738
```

WORKSPACE

-19
Original file line numberDiff line numberDiff line change
@@ -7,22 +7,3 @@ proxy_wasm_rust_sdk_repositories()
77
load("@proxy_wasm_rust_sdk//bazel:dependencies.bzl", "proxy_wasm_rust_sdk_dependencies")
88

99
proxy_wasm_rust_sdk_dependencies()
10-
11-
# Needed only when using @cargo_raze//:raze to generate BUILD files in //bazel/cargo.
12-
13-
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
14-
15-
http_archive(
16-
name = "cargo_raze",
17-
sha256 = "58ecdbae2680b71edc19a0f563cdb73e66c8914689b6edab258c8b90a93b13c7",
18-
strip_prefix = "cargo-raze-0.15.0",
19-
url = "https://github.com/google/cargo-raze/archive/v0.15.0.tar.gz",
20-
)
21-
22-
load("@cargo_raze//:repositories.bzl", "cargo_raze_repositories")
23-
24-
cargo_raze_repositories()
25-
26-
load("@cargo_raze//:transitive_deps.bzl", "cargo_raze_transitive_deps")
27-
28-
cargo_raze_transitive_deps()

bazel/cargo/BUILD

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# Copyright 2022 Google LLC
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_rust//crate_universe:defs.bzl", "crates_vendor")
16+
17+
exports_files([
18+
"Cargo.Bazel.lock",
19+
])
20+
21+
crates_vendor(
22+
name = "crates_vendor",
23+
cargo_lockfile = "//bazel/cargo:Cargo.Bazel.lock",
24+
manifests = ["//:Cargo.toml"],
25+
mode = "remote",
26+
tags = ["manual"],
27+
vendor_path = "//bazel/cargo/remote",
28+
)

bazel/cargo/BUILD.bazel

-49
This file was deleted.

bazel/cargo/Cargo.raze.lock renamed to bazel/cargo/Cargo.Bazel.lock

+2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
# This file is automatically @generated by Cargo.
22
# It is not intended for manual editing.
3+
version = 3
4+
35
[[package]]
46
name = "ahash"
57
version = "0.8.2"

bazel/cargo/crates.bzl

-72
This file was deleted.

0 commit comments

Comments
 (0)