Skip to content

Commit 0b1edc6

Browse files
authored
Merge branch 'main' into bindgen
2 parents 23b3b57 + b0daae0 commit 0b1edc6

File tree

49 files changed

+2247
-89
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

49 files changed

+2247
-89
lines changed

.bazelversion

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
8.4.2

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@
66

77
This repository provides rules for building [Rust](https://www.rust-lang.org/) projects with [Bazel](https://bazel.build/).
88

9+
### Starter repo
10+
11+
The fastest way to try this in an empty project is to click the green "Use this template" button on https://github.com/bazel-starters/rust.
12+
913
## Community
1014

1115
General discussions and announcements take place in the [GitHub Discussions](https://github.com/bazelbuild/rules_rust/discussions), but there are

cargo/private/cargo_build_script.bzl

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -420,12 +420,22 @@ def _cargo_build_script_impl(ctx):
420420
env["LDFLAGS"] = " ".join(_pwd_flags(link_args))
421421

422422
# Defaults for cxx flags.
423-
env["CC"] = "${{pwd}}/{}".format(ctx.executable._fallback_cc.path)
424-
env["CXX"] = "${{pwd}}/{}".format(ctx.executable._fallback_cxx.path)
425-
env["AR"] = "${{pwd}}/{}".format(ctx.executable._fallback_ar.path)
426423
env["ARFLAGS"] = ""
427424
env["CFLAGS"] = ""
428425
env["CXXFLAGS"] = ""
426+
fallback_tools = []
427+
if not cc_toolchain:
428+
fallbacks = {
429+
"AR": "_fallback_ar",
430+
"CC": "_fallback_cc",
431+
"CXX": "_fallback_cxx",
432+
}
433+
for key, attr in fallbacks.items():
434+
tool = getattr(ctx.executable, attr)
435+
if not tool:
436+
fail("cargo_build_script without a cc toolchain requires %s" % attr)
437+
fallback_tools.append(tool)
438+
env[key] = "${{pwd}}/{}".format(tool.path)
429439

430440
if cc_toolchain:
431441
# MSVC requires INCLUDE to be set
@@ -516,10 +526,7 @@ def _cargo_build_script_impl(ctx):
516526
direct = [
517527
script,
518528
ctx.executable._cargo_build_script_runner,
519-
ctx.executable._fallback_cc,
520-
ctx.executable._fallback_cxx,
521-
ctx.executable._fallback_ar,
522-
] + ([toolchain.target_json] if toolchain.target_json else []),
529+
] + fallback_tools + ([toolchain.target_json] if toolchain.target_json else []),
523530
transitive = script_data + script_tools + toolchain_tools,
524531
)
525532

@@ -744,16 +751,19 @@ cargo_build_script = rule(
744751
"_fallback_ar": attr.label(
745752
cfg = "exec",
746753
executable = True,
754+
allow_files = True,
747755
default = Label("//cargo/private:no_ar"),
748756
),
749757
"_fallback_cc": attr.label(
750758
cfg = "exec",
751759
executable = True,
760+
allow_files = True,
752761
default = Label("//cargo/private:no_cc"),
753762
),
754763
"_fallback_cxx": attr.label(
755764
cfg = "exec",
756765
executable = True,
766+
allow_files = True,
757767
default = Label("//cargo/private:no_cxx"),
758768
),
759769
"_incompatible_runfiles_cargo_manifest_dir": attr.label(

crate_universe/extensions.bzl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ bazel_dep(name = "rules_rust", version = "0.68.1")
3232
You find the latest version on the [release page](https://github.com/bazelbuild/rules_rust/releases).
3333
3434
35-
After adding `rules_rust` in your `MODULE.bazel, set the following to begin using `crate_universe`:
35+
After adding `rules_rust` in your `MODULE.bazel`, set the following to begin using `crate_universe`:
3636
3737
```python
3838
crate = use_extension("@rules_rust//crate_universe:extensions.bzl", "crate")
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
8.4.2
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
8.4.2

examples/android/.bazelversion

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
8.4.2

examples/bazel_env/.bazelversion

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
8.4.2

examples/compile_opt/.bazelversion

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
8.4.2
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
8.4.2

0 commit comments

Comments
 (0)