Skip to content

Commit

Permalink
Add patching example
Browse files Browse the repository at this point in the history
  • Loading branch information
P1n3appl3 committed Mar 31, 2023
1 parent ae674a8 commit e7d66ed
Show file tree
Hide file tree
Showing 18 changed files with 939 additions and 0 deletions.
3 changes: 3 additions & 0 deletions examples/crate_universe/vendor_local_patching/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Ignore everything but the `BUILD` files within the vendored directories
vendor/*/*
!vendor/*/BUILD.bazel
26 changes: 26 additions & 0 deletions examples/crate_universe/vendor_local_patching/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
load("@rules_rust//crate_universe:defs.bzl", "crate", "crates_vendor")
load("@rules_rust//rust:defs.bzl", "rust_binary", "rust_test")

crates_vendor(
name = "vendor",
cargo_lockfile = ":Cargo.lock",
manifests = [":Cargo.toml"],
mode = "local",
# We don't support wasi
supported_platform_triples = [
"x86_64-unknown-linux-gnu",
"aarch64-unknown-linux-gnu",
"x86_64-apple-darwin",
"x86_64-pc-windows-msvc",
"x86_64-fuchsia",
"aarch64-fuchsia",
],
vendor_path = "vendor",
)

rust_binary(
name = "bin",
srcs = ["src/main.rs"],
deps = ["//vendor_local_patching/vendor:rand"],
edition = "2021",
)
73 changes: 73 additions & 0 deletions examples/crate_universe/vendor_local_patching/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 9 additions & 0 deletions examples/crate_universe/vendor_local_patching/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
[package]
name = "my_third_party"
version = "0.1.0"

[dependencies]
rand = "0.8.5"

[patch.crates-io]
wasi = { path = "empty_wasi" }
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
filegroup(
name = "wasi",
srcs = glob(["**/*.rs"]),
visibility = ["//visibility:public"],
)

exports_files(["src/lib.rs"])
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[package]
name = "wasi"
version = "0.11.0+wasi-snapshot-preview1"
Empty file.
3 changes: 3 additions & 0 deletions examples/crate_universe/vendor_local_patching/src/main.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
fn main() {
println!("random number: {}", rand::random::<f32>());
}
31 changes: 31 additions & 0 deletions examples/crate_universe/vendor_local_patching/vendor/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
###############################################################################
# @generated
# DO NOT MODIFY: This file is auto-generated by a crate_universe tool. To
# regenerate this file, run the following:
#
# bazel run @//vendor_local_patching:vendor
###############################################################################

package(default_visibility = ["//visibility:public"])

exports_files(
[
"cargo-bazel.json",
"defs.bzl",
] + glob(["*.bazel"]),
)

filegroup(
name = "srcs",
srcs = glob([
"*.bazel",
"*.bzl",
]),
)

# Workspace Member Dependencies
alias(
name = "rand",
actual = "//vendor_local_patching/vendor/rand-0.8.5:rand",
tags = ["manual"],
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
###############################################################################
# @generated
# DO NOT MODIFY: This file is auto-generated by a crate_universe tool. To
# regenerate this file, run the following:
#
# bazel run @//vendor_local_patching:vendor
###############################################################################

load("@rules_rust//rust:defs.bzl", "rust_library")

package(default_visibility = ["//visibility:public"])

# licenses([
# "TODO", # MIT/Apache-2.0
# ])

rust_library(
name = "cfg_if",
srcs = glob(["**/*.rs"]),
compile_data = glob(
include = ["**"],
exclude = [
"**/* *",
"BUILD",
"BUILD.bazel",
"WORKSPACE",
"WORKSPACE.bazel",
],
),
crate_root = "src/lib.rs",
edition = "2018",
rustc_flags = ["--cap-lints=allow"],
tags = [
"cargo-bazel",
"crate-name=cfg-if",
"manual",
"noclippy",
"norustfmt",
],
version = "1.0.0",
)
Loading

0 comments on commit e7d66ed

Please sign in to comment.