Skip to content

Commit a13c1c7

Browse files
authored
Add support for Bazel modules. (#333)
Signed-off-by: Matthieu MOREL <matthieu.morel35@gmail.com>
1 parent b3d3815 commit a13c1c7

File tree

6 files changed

+2073
-3
lines changed

6 files changed

+2073
-3
lines changed

.bazelrc

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,2 @@
1-
# Disable Bzlmod
2-
common --noenable_bzlmod
3-
41
# Force Bazel to use --target=wasm32-wasip1
52
build --platforms=@rules_rust//rust/platform:wasi

.github/workflows/rust.yml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,9 +87,15 @@ jobs:
8787
- name: Build (wasm32-unknown-unknown)
8888
run: bazelisk --noworkspace_rc build --noenable_bzlmod --platforms=@rules_rust//rust/platform:wasm //...
8989

90+
- name: Build (wasm32-unknown-unknown/bzlmod)
91+
run: bazelisk --noworkspace_rc build --enable_bzlmod --platforms=@rules_rust//rust/platform:wasm //...
92+
9093
- name: Build (wasm32-wasip1)
9194
run: bazelisk --noworkspace_rc build --noenable_bzlmod --platforms=@rules_rust//rust/platform:wasi //...
9295

96+
- name: Build (wasm32-wasip1/bzlmod)
97+
run: bazelisk --noworkspace_rc build --enable_bzlmod --platforms=@rules_rust//rust/platform:wasi //...
98+
9399
- name: Format (buildifier)
94100
run: |
95101
buildifier -mode=check -r .
@@ -99,6 +105,9 @@ jobs:
99105
bazelisk --noworkspace_rc run --noenable_bzlmod //bazel/cargo:crates_vendor
100106
git diff --exit-code
101107
108+
- name: Format (MODULE.bazel.lock)
109+
run: bazelisk mod deps --lockfile_mode=error
110+
102111
msrv:
103112
runs-on: ubuntu-24.04
104113

MODULE.bazel

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
# Copyright 2025 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+
module(
16+
name = "proxy_wasm_rust_sdk",
17+
version = "0.2.5-dev",
18+
)
19+
20+
# Regular dependencies (sorted alphabetically).
21+
bazel_dep(name = "bazel_features", version = "1.38.0")
22+
bazel_dep(name = "bazel_skylib", version = "1.8.2")
23+
bazel_dep(name = "rules_cc", version = "0.2.14")
24+
bazel_dep(name = "rules_rust", version = "0.67.0")
25+
single_version_override(
26+
module_name = "rules_rust",
27+
patch_strip = 1,
28+
patches = [
29+
"//bazel:rules_rust.patch",
30+
],
31+
version = "0.67.0",
32+
)
33+
34+
# Configure Rust toolchain.
35+
rust = use_extension("@rules_rust//rust:extensions.bzl", "rust")
36+
rust.toolchain(
37+
edition = "2018",
38+
versions = ["1.90.0"],
39+
)
40+
use_repo(rust, "rust_toolchains")
41+
42+
register_toolchains(
43+
"@rust_toolchains//:all",
44+
# Dummy C/C++ toolchains for Wasm targets.
45+
"@rules_rust//rust/private/dummy_cc_toolchain:dummy_cc_wasm32_toolchain",
46+
"@rules_rust//rust/private/dummy_cc_toolchain:dummy_cc_wasm64_toolchain",
47+
)
48+
49+
# Cargo dependencies.
50+
crates_deps = use_extension("//bazel:extensions.bzl", "crates_deps")
51+
use_repo(
52+
crates_deps,
53+
"crates_vendor",
54+
"crates_vendor__hashbrown-0.16.0",
55+
"crates_vendor__log-0.4.27",
56+
)

0 commit comments

Comments
 (0)