Skip to content

Commit 1934ff6

Browse files
committed
Added bzlmod support to test/no_std
1 parent 9cdb86c commit 1934ff6

File tree

3 files changed

+110
-55
lines changed

3 files changed

+110
-55
lines changed

test/no_std/.bazelrc

Lines changed: 80 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,81 @@
1-
common --noenable_bzlmod
1+
###############################################################################
2+
## Bazel Configuration Flags
3+
##
4+
## `.bazelrc` is a Bazel configuration file.
5+
## https://bazel.build/docs/best-practices#bazelrc-file
6+
###############################################################################
27

3-
# This isn't currently the defaut in Bazel, but we enable it to test we'll be ready if/when it flips.
4-
build --incompatible_disallow_empty_glob
8+
# https://bazel.build/reference/command-line-reference#flag--enable_platform_specific_config
9+
common --enable_platform_specific_config
10+
11+
# Enable the only currently supported report type
12+
# https://bazel.build/reference/command-line-reference#flag--combined_report
13+
coverage --combined_report=lcov
14+
15+
# Avoid fully cached builds reporting no coverage and failing CI
16+
# https://bazel.build/reference/command-line-reference#flag--experimental_fetch_all_coverage_outputs
17+
coverage --experimental_fetch_all_coverage_outputs
18+
19+
# Required for some of the tests
20+
# https://bazel.build/reference/command-line-reference#flag--experimental_cc_shared_library
21+
common --experimental_cc_shared_library
22+
23+
###############################################################################
24+
## Unique configuration groups
25+
###############################################################################
26+
27+
# Enable use of the nightly toolchains.
28+
build:nightly --@rules_rust//rust/toolchain/channel=nightly
29+
30+
# Enable rustfmt for all targets in the workspace
31+
build:rustfmt --aspects=@rules_rust//rust:defs.bzl%rustfmt_aspect
32+
build:rustfmt --output_groups=+rustfmt_checks
33+
34+
# Enable clippy for all targets in the workspace
35+
build:clippy --aspects=@rules_rust//rust:defs.bzl%rust_clippy_aspect
36+
build:clippy --output_groups=+clippy_checks
37+
38+
# Enable unpretty for all targets in the workspace
39+
build:unpretty --aspects=@rules_rust//rust:defs.bzl%rust_unpretty_aspect
40+
build:unpretty --output_groups=+rust_unpretty
41+
42+
# `unpretty` requires the nightly toolchain. See tracking issue:
43+
# https://github.com/rust-lang/rust/issues/43364
44+
build:unpretty --config=nightly
45+
46+
###############################################################################
47+
## Incompatibility flags
48+
###############################################################################
49+
50+
# https://github.com/bazelbuild/bazel/issues/8195
51+
build --incompatible_disallow_empty_glob=true
52+
53+
# https://github.com/bazelbuild/bazel/issues/12821
54+
build --nolegacy_external_runfiles
55+
56+
# Required for cargo_build_script support before Bazel 7
57+
build --incompatible_merge_fixed_and_default_shell_env
58+
59+
###############################################################################
60+
## Bzlmod
61+
###############################################################################
62+
63+
# A configuration for disabling bzlmod.
64+
common:no-bzlmod --noenable_bzlmod --enable_workspace
65+
66+
# Disable the bzlmod lockfile, so we don't accidentally commit MODULE.bazel.lock
67+
common --lockfile_mode=off
68+
69+
# Allow bazel configuration flags to locate the core rules to avoid adding local
70+
# override paths to the `MODULE.bazel` file and breaking downstream consumers.
71+
common --override_module=rules_rust=../../
72+
73+
###############################################################################
74+
## Custom user flags
75+
##
76+
## This should always be the last thing in the `.bazelrc` file to ensure
77+
## consistent behavior when setting flags in that file as `.bazelrc` files are
78+
## evaluated top to bottom.
79+
###############################################################################
80+
81+
try-import %workspace%/user.bazelrc

test/no_std/MODULE.bazel

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
module(
2+
name = "rules_rust_test_no_std",
3+
version = "0.0.0",
4+
)
5+
6+
bazel_dep(name = "rules_rust", version = "0.55.6")
7+
local_path_override(
8+
module_name = "rules_rust",
9+
path = "../..",
10+
)
11+
12+
rust = use_extension("@rules_rust//rust:extensions.bzl", "rust")
13+
rust.toolchain(
14+
edition = "2021",
15+
versions = [
16+
"nightly/2024-10-17",
17+
"1.82.0",
18+
],
19+
)
20+
use_repo(rust, "rust_toolchains")
21+
22+
register_toolchains("@rust_toolchains//:all")
23+
24+
crate = use_extension("@rules_rust//crate_universe:extensions.bzl", "crate")
25+
crate.spec(
26+
package = "libc_alloc",
27+
version = "1.0.3",
28+
)
29+
crate.from_specs(name = "no_std_crate_index")
30+
use_repo(crate, "no_std_crate_index")

test/no_std/WORKSPACE.bazel

Lines changed: 0 additions & 52 deletions
This file was deleted.

0 commit comments

Comments
 (0)