Skip to content

Commit e7d66ed

Browse files
committed
Add patching example
1 parent ae674a8 commit e7d66ed

File tree

18 files changed

+939
-0
lines changed

18 files changed

+939
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# Ignore everything but the `BUILD` files within the vendored directories
2+
vendor/*/*
3+
!vendor/*/BUILD.bazel
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
load("@rules_rust//crate_universe:defs.bzl", "crate", "crates_vendor")
2+
load("@rules_rust//rust:defs.bzl", "rust_binary", "rust_test")
3+
4+
crates_vendor(
5+
name = "vendor",
6+
cargo_lockfile = ":Cargo.lock",
7+
manifests = [":Cargo.toml"],
8+
mode = "local",
9+
# We don't support wasi
10+
supported_platform_triples = [
11+
"x86_64-unknown-linux-gnu",
12+
"aarch64-unknown-linux-gnu",
13+
"x86_64-apple-darwin",
14+
"x86_64-pc-windows-msvc",
15+
"x86_64-fuchsia",
16+
"aarch64-fuchsia",
17+
],
18+
vendor_path = "vendor",
19+
)
20+
21+
rust_binary(
22+
name = "bin",
23+
srcs = ["src/main.rs"],
24+
deps = ["//vendor_local_patching/vendor:rand"],
25+
edition = "2021",
26+
)

examples/crate_universe/vendor_local_patching/Cargo.lock

+73
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
[package]
2+
name = "my_third_party"
3+
version = "0.1.0"
4+
5+
[dependencies]
6+
rand = "0.8.5"
7+
8+
[patch.crates-io]
9+
wasi = { path = "empty_wasi" }
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
filegroup(
2+
name = "wasi",
3+
srcs = glob(["**/*.rs"]),
4+
visibility = ["//visibility:public"],
5+
)
6+
7+
exports_files(["src/lib.rs"])
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[package]
2+
name = "wasi"
3+
version = "0.11.0+wasi-snapshot-preview1"

examples/crate_universe/vendor_local_patching/empty_wasi/src/lib.rs

Whitespace-only changes.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
fn main() {
2+
println!("random number: {}", rand::random::<f32>());
3+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
###############################################################################
2+
# @generated
3+
# DO NOT MODIFY: This file is auto-generated by a crate_universe tool. To
4+
# regenerate this file, run the following:
5+
#
6+
# bazel run @//vendor_local_patching:vendor
7+
###############################################################################
8+
9+
package(default_visibility = ["//visibility:public"])
10+
11+
exports_files(
12+
[
13+
"cargo-bazel.json",
14+
"defs.bzl",
15+
] + glob(["*.bazel"]),
16+
)
17+
18+
filegroup(
19+
name = "srcs",
20+
srcs = glob([
21+
"*.bazel",
22+
"*.bzl",
23+
]),
24+
)
25+
26+
# Workspace Member Dependencies
27+
alias(
28+
name = "rand",
29+
actual = "//vendor_local_patching/vendor/rand-0.8.5:rand",
30+
tags = ["manual"],
31+
)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
###############################################################################
2+
# @generated
3+
# DO NOT MODIFY: This file is auto-generated by a crate_universe tool. To
4+
# regenerate this file, run the following:
5+
#
6+
# bazel run @//vendor_local_patching:vendor
7+
###############################################################################
8+
9+
load("@rules_rust//rust:defs.bzl", "rust_library")
10+
11+
package(default_visibility = ["//visibility:public"])
12+
13+
# licenses([
14+
# "TODO", # MIT/Apache-2.0
15+
# ])
16+
17+
rust_library(
18+
name = "cfg_if",
19+
srcs = glob(["**/*.rs"]),
20+
compile_data = glob(
21+
include = ["**"],
22+
exclude = [
23+
"**/* *",
24+
"BUILD",
25+
"BUILD.bazel",
26+
"WORKSPACE",
27+
"WORKSPACE.bazel",
28+
],
29+
),
30+
crate_root = "src/lib.rs",
31+
edition = "2018",
32+
rustc_flags = ["--cap-lints=allow"],
33+
tags = [
34+
"cargo-bazel",
35+
"crate-name=cfg-if",
36+
"manual",
37+
"noclippy",
38+
"norustfmt",
39+
],
40+
version = "1.0.0",
41+
)

0 commit comments

Comments
 (0)