Skip to content

Commit

Permalink
Allow passing a bazel path to vendor explicitly (bazelbuild#1661)
Browse files Browse the repository at this point in the history
Co-authored-by: David Koloski <dkoloski@google.com>
Co-authored-by: UebelAndre <github@uebelandre.com>
  • Loading branch information
3 people authored Nov 30, 2022
1 parent d51bf9c commit d4b31a4
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
11 changes: 11 additions & 0 deletions crate_universe/private/crates_vendor.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,11 @@ def _crates_vendor_impl(ctx):
args.extend(["--buildifier", _runfiles_path(ctx.executable.buildifier, is_windows)])
cargo_bazel_runfiles.append(ctx.executable.buildifier)

# Optionally include an explicit `bazel` path
if ctx.attr.bazel:
args.extend(["--bazel", _runfiles_path(ctx.executable.bazel, is_windows)])
cargo_bazel_runfiles.append(ctx.executable.bazel)

# Determine platform specific settings
if is_windows:
extension = ".bat"
Expand Down Expand Up @@ -334,6 +339,12 @@ call against the generated workspace. The following table describes how to contr
"annotations": attr.string_list_dict(
doc = "Extra settings to apply to crates. See [crate.annotation](#crateannotation).",
),
"bazel": attr.label(
doc = "The path to a bazel binary used to locate the output_base for the current workspace.",
cfg = "exec",
executable = True,
allow_files = True,
),
"buildifier": attr.label(
doc = "The path to a [buildifier](https://github.com/bazelbuild/buildtools/blob/5.0.1/buildifier/README.md) binary used to format generated BUILD files.",
cfg = "exec",
Expand Down
3 changes: 2 additions & 1 deletion docs/crate_universe.md
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,7 @@ that is called behind the scenes to update dependencies.
## crates_vendor

<pre>
crates_vendor(<a href="#crates_vendor-name">name</a>, <a href="#crates_vendor-annotations">annotations</a>, <a href="#crates_vendor-buildifier">buildifier</a>, <a href="#crates_vendor-cargo_bazel">cargo_bazel</a>, <a href="#crates_vendor-cargo_config">cargo_config</a>, <a href="#crates_vendor-cargo_lockfile">cargo_lockfile</a>,
crates_vendor(<a href="#crates_vendor-name">name</a>, <a href="#crates_vendor-annotations">annotations</a>, <a href="#crates_vendor-bazel">bazel</a>, <a href="#crates_vendor-buildifier">buildifier</a>, <a href="#crates_vendor-cargo_bazel">cargo_bazel</a>, <a href="#crates_vendor-cargo_config">cargo_config</a>, <a href="#crates_vendor-cargo_lockfile">cargo_lockfile</a>,
<a href="#crates_vendor-generate_build_scripts">generate_build_scripts</a>, <a href="#crates_vendor-manifests">manifests</a>, <a href="#crates_vendor-mode">mode</a>, <a href="#crates_vendor-packages">packages</a>, <a href="#crates_vendor-repository_name">repository_name</a>, <a href="#crates_vendor-splicing_config">splicing_config</a>,
<a href="#crates_vendor-supported_platform_triples">supported_platform_triples</a>, <a href="#crates_vendor-vendor_path">vendor_path</a>)
</pre>
Expand Down Expand Up @@ -386,6 +386,7 @@ call against the generated workspace. The following table describes how to contr
| :------------- | :------------- | :------------- | :------------- | :------------- |
| <a id="crates_vendor-name"></a>name | A unique name for this target. | <a href="https://bazel.build/docs/build-ref.html#name">Name</a> | required | |
| <a id="crates_vendor-annotations"></a>annotations | Extra settings to apply to crates. See [crate.annotation](#crateannotation). | <a href="https://bazel.build/docs/skylark/lib/dict.html">Dictionary: String -> List of strings</a> | optional | {} |
| <a id="crates_vendor-bazel"></a>bazel | The path to a bazel binary used to locate the output_base for the current workspace. | <a href="https://bazel.build/docs/build-ref.html#labels">Label</a> | optional | None |
| <a id="crates_vendor-buildifier"></a>buildifier | The path to a [buildifier](https://github.com/bazelbuild/buildtools/blob/5.0.1/buildifier/README.md) binary used to format generated BUILD files. | <a href="https://bazel.build/docs/build-ref.html#labels">Label</a> | optional | //crate_universe/private/vendor:buildifier |
| <a id="crates_vendor-cargo_bazel"></a>cargo_bazel | The cargo-bazel binary to use for vendoring. If this attribute is not set, then a <code>CARGO_BAZEL_GENERATOR_PATH</code> action env will be used. | <a href="https://bazel.build/docs/build-ref.html#labels">Label</a> | optional | @cargo_bazel_bootstrap//:binary |
| <a id="crates_vendor-cargo_config"></a>cargo_config | A [Cargo configuration](https://doc.rust-lang.org/cargo/reference/config.html) file. | <a href="https://bazel.build/docs/build-ref.html#labels">Label</a> | optional | None |
Expand Down

0 comments on commit d4b31a4

Please sign in to comment.