Skip to content

Replace cargo-raze with rules_rust's crate universe. #181

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Dec 6, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 5 additions & 7 deletions .github/workflows/rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ jobs:
run: |
go install github.com/google/addlicense@latest
export PATH=$PATH:$(go env GOPATH)/bin
addlicense -check .
addlicense -check -ignore "bazel/cargo/remote/**" .

bazel:
runs-on: ubuntu-latest
Expand All @@ -63,7 +63,7 @@ jobs:
~/.cargo/.crates2.json
~/.cargo/bin
~/.cargo/registry
key: ${{ hashFiles('WORKSPACE', '.bazelrc', '.bazelversion', 'bazel/cargo/Cargo.raze.lock', 'bazel/dependencies.bzl', 'bazel/repositories.bzl') }}
key: ${{ hashFiles('WORKSPACE', '.bazelrc', '.bazelversion', 'bazel/cargo/Cargo.Bazel.lock', 'bazel/dependencies.bzl', 'bazel/repositories.bzl') }}

- name: Build (wasm32-unknown-unknown)
run: bazelisk --noworkspace_rc build --platforms=@rules_rust//rust/platform:wasm //...
Expand All @@ -78,11 +78,9 @@ jobs:
buildifier -mode=check WORKSPACE
buildifier -mode=check BUILD

- name: Format (cargo raze)
- name: Format (rules_rust)
run: |
mv bazel/cargo/Cargo.raze.lock Cargo.lock
bazelisk --noworkspace_rc run @cargo_raze//:raze -- --manifest-path=$(pwd)/Cargo.toml
mv Cargo.lock bazel/cargo/Cargo.raze.lock
bazelisk --noworkspace_rc run //bazel/cargo:crates_vendor
git diff --exit-code

stable:
Expand Down Expand Up @@ -181,7 +179,7 @@ jobs:

- name: Run cargo audit
run: |
cp -p bazel/cargo/Cargo.raze.lock .
cp -p bazel/cargo/Cargo.Bazel.lock Cargo.lock
cargo audit

example:
Expand Down
8 changes: 6 additions & 2 deletions BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@
load("@rules_rust//cargo:cargo_build_script.bzl", "cargo_build_script")
load("@rules_rust//rust:defs.bzl", "rust_library")

exports_files([
"Cargo.toml",
])

cargo_build_script(
name = "proxy_wasm_build_script",
srcs = ["build.rs"],
Expand All @@ -30,7 +34,7 @@ rust_library(
visibility = ["//visibility:public"],
deps = [
":proxy_wasm_build_script",
"//bazel/cargo:hashbrown",
"//bazel/cargo:log",
"//bazel/cargo/remote:hashbrown",
"//bazel/cargo/remote:log",
],
)
5 changes: 0 additions & 5 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,3 @@ opt-level = 3
codegen-units = 1
panic = "abort"
strip = "debuginfo"

[package.metadata.raze]
package_aliases_dir = "bazel/cargo"
workspace_path = "//bazel/cargo"
genmode = "Remote"
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
When updating dependencies, you need to regenerate Bazel `BUILD` files to match updated `Cargo.toml`:

```sh
cargo install cargo-raze --version 0.15.0
cargo raze --generate-lockfile
cargo generate-lockfile
mv Cargo.lock bazel/cargo/Cargo.Bazel.lock
bazel run //bazel/cargo:crates_vendor
```
19 changes: 0 additions & 19 deletions WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -7,22 +7,3 @@ proxy_wasm_rust_sdk_repositories()
load("@proxy_wasm_rust_sdk//bazel:dependencies.bzl", "proxy_wasm_rust_sdk_dependencies")

proxy_wasm_rust_sdk_dependencies()

# Needed only when using @cargo_raze//:raze to generate BUILD files in //bazel/cargo.

load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")

http_archive(
name = "cargo_raze",
sha256 = "58ecdbae2680b71edc19a0f563cdb73e66c8914689b6edab258c8b90a93b13c7",
strip_prefix = "cargo-raze-0.15.0",
url = "https://github.com/google/cargo-raze/archive/v0.15.0.tar.gz",
)

load("@cargo_raze//:repositories.bzl", "cargo_raze_repositories")

cargo_raze_repositories()

load("@cargo_raze//:transitive_deps.bzl", "cargo_raze_transitive_deps")

cargo_raze_transitive_deps()
28 changes: 28 additions & 0 deletions bazel/cargo/BUILD
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# Copyright 2022 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

load("@rules_rust//crate_universe:defs.bzl", "crates_vendor")

exports_files([
"Cargo.Bazel.lock",
])

crates_vendor(
name = "crates_vendor",
cargo_lockfile = "//bazel/cargo:Cargo.Bazel.lock",
manifests = ["//:Cargo.toml"],
mode = "remote",
tags = ["manual"],
vendor_path = "//bazel/cargo/remote",
)
49 changes: 0 additions & 49 deletions bazel/cargo/BUILD.bazel

This file was deleted.

2 changes: 2 additions & 0 deletions bazel/cargo/Cargo.raze.lock → bazel/cargo/Cargo.Bazel.lock
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# This file is automatically @generated by Cargo.
# It is not intended for manual editing.
version = 3

[[package]]
name = "ahash"
version = "0.8.2"
Expand Down
72 changes: 0 additions & 72 deletions bazel/cargo/crates.bzl

This file was deleted.

Loading