Skip to content

Commit

Permalink
Use cargo-raze's gen_buildrs for trusted crates. (proxy-wasm#53)
Browse files Browse the repository at this point in the history
Signed-off-by: Piotr Sikora <[email protected]>
  • Loading branch information
PiotrSikora authored Nov 12, 2020
1 parent c1edb21 commit 76f240a
Show file tree
Hide file tree
Showing 5 changed files with 130 additions and 28 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ jobs:
- name: Format (cargo raze)
run: |
cargo install cargo-raze --git https://github.com/google/cargo-raze --rev cb9f85d22b1c81cceb9acaf1fa4336c5fc4e6bff
cargo install cargo-raze --version 0.7.0
cp -p bazel/cargo/Cargo.lock .
rm -rf bazel/cargo/
cargo raze --output=bazel/cargo
Expand Down
19 changes: 7 additions & 12 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -32,19 +32,14 @@ panic = "abort"
workspace_path = "//bazel/cargo"
genmode = "Remote"

[package.metadata.raze.crates.libc.'0.2.80']
additional_flags = [
"--cfg=libc_priv_mod_use",
"--cfg=libc_union",
"--cfg=libc_const_size_of",
"--cfg=libc_align",
"--cfg=libc_core_cvoid",
"--cfg=libc_packedN",
"--cfg=libc_cfg_target_vendor",
]
[package.metadata.raze.crates.getrandom.'=0.2.0']
gen_buildrs = true

[package.metadata.raze.crates.log.'0.4.11']
additional_flags = ["--cfg=atomic_cas"]
[package.metadata.raze.crates.libc.'=0.2.80']
gen_buildrs = true

[package.metadata.raze.crates.log.'=0.4.11']
gen_buildrs = true

[[example]]
name = "hello_world"
Expand Down
67 changes: 64 additions & 3 deletions bazel/cargo/remote/BUILD.getrandom-0.2.0.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,71 @@ licenses([
"notice", # MIT from expression "MIT OR Apache-2.0"
])

# Generated Targets
# Generated Targets# buildifier: disable=load-on-top
load(
"@io_bazel_rules_rust//cargo:cargo_build_script.bzl",
"cargo_build_script",
)

# Unsupported target "mod" with type "bench" omitted
cargo_build_script(
name = "getrandom_build_script",
srcs = glob(["**/*.rs"]),
build_script_env = {
},
crate_features = [
],
crate_root = "build.rs",
data = glob(["**"]),
edition = "2018",
rustc_flags = [
"--cap-lints=allow",
],
tags = [
"cargo-raze",
"manual",
],
version = "0.2.0",
visibility = ["//visibility:private"],
deps = [
] + selects.with_or({
# cfg(all(target_arch = "wasm32", target_os = "unknown", not(cargo_web)))
(
"@io_bazel_rules_rust//rust/platform:wasm32-unknown-unknown",
): [
],
"//conditions:default": [],
}) + selects.with_or({
# cfg(target_os = "wasi")
(
"@io_bazel_rules_rust//rust/platform:wasm32-wasi",
): [
],
"//conditions:default": [],
}) + selects.with_or({
# cfg(unix)
(
"@io_bazel_rules_rust//rust/platform:aarch64-apple-ios",
"@io_bazel_rules_rust//rust/platform:aarch64-linux-android",
"@io_bazel_rules_rust//rust/platform:aarch64-unknown-linux-gnu",
"@io_bazel_rules_rust//rust/platform:arm-unknown-linux-gnueabi",
"@io_bazel_rules_rust//rust/platform:i686-apple-darwin",
"@io_bazel_rules_rust//rust/platform:i686-linux-android",
"@io_bazel_rules_rust//rust/platform:i686-unknown-freebsd",
"@io_bazel_rules_rust//rust/platform:i686-unknown-linux-gnu",
"@io_bazel_rules_rust//rust/platform:powerpc-unknown-linux-gnu",
"@io_bazel_rules_rust//rust/platform:s390x-unknown-linux-gnu",
"@io_bazel_rules_rust//rust/platform:x86_64-apple-darwin",
"@io_bazel_rules_rust//rust/platform:x86_64-apple-ios",
"@io_bazel_rules_rust//rust/platform:x86_64-linux-android",
"@io_bazel_rules_rust//rust/platform:x86_64-unknown-freebsd",
"@io_bazel_rules_rust//rust/platform:x86_64-unknown-linux-gnu",
): [
],
"//conditions:default": [],
}),
)

# Unsupported target "build-script-build" with type "custom-build" omitted
# Unsupported target "mod" with type "bench" omitted

rust_library(
name = "getrandom",
Expand All @@ -54,6 +114,7 @@ rust_library(
version = "0.2.0",
# buildifier: leave-alone
deps = [
":getrandom_build_script",
"@raze__cfg_if__0_1_10//:cfg_if",
] + selects.with_or({
# cfg(all(target_arch = "wasm32", target_os = "unknown", not(cargo_web)))
Expand Down
39 changes: 30 additions & 9 deletions bazel/cargo/remote/BUILD.libc-0.2.80.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,36 @@ licenses([
"notice", # MIT from expression "MIT OR Apache-2.0"
])

# Generated Targets
# Generated Targets# buildifier: disable=load-on-top
load(
"@io_bazel_rules_rust//cargo:cargo_build_script.bzl",
"cargo_build_script",
)

# Unsupported target "build-script-build" with type "custom-build" omitted
cargo_build_script(
name = "libc_build_script",
srcs = glob(["**/*.rs"]),
build_script_env = {
},
crate_features = [
"default",
"std",
],
crate_root = "build.rs",
data = glob(["**"]),
edition = "2015",
rustc_flags = [
"--cap-lints=allow",
],
tags = [
"cargo-raze",
"manual",
],
version = "0.2.80",
visibility = ["//visibility:private"],
deps = [
],
)

rust_library(
name = "libc",
Expand All @@ -44,13 +71,6 @@ rust_library(
edition = "2015",
rustc_flags = [
"--cap-lints=allow",
"--cfg=libc_priv_mod_use",
"--cfg=libc_union",
"--cfg=libc_const_size_of",
"--cfg=libc_align",
"--cfg=libc_core_cvoid",
"--cfg=libc_packedN",
"--cfg=libc_cfg_target_vendor",
],
tags = [
"cargo-raze",
Expand All @@ -59,6 +79,7 @@ rust_library(
version = "0.2.80",
# buildifier: leave-alone
deps = [
":libc_build_script",
],
)

Expand Down
31 changes: 28 additions & 3 deletions bazel/cargo/remote/BUILD.log-0.4.11.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,34 @@ licenses([
"notice", # MIT from expression "MIT OR Apache-2.0"
])

# Generated Targets
# Generated Targets# buildifier: disable=load-on-top
load(
"@io_bazel_rules_rust//cargo:cargo_build_script.bzl",
"cargo_build_script",
)

# Unsupported target "build-script-build" with type "custom-build" omitted
cargo_build_script(
name = "log_build_script",
srcs = glob(["**/*.rs"]),
build_script_env = {
},
crate_features = [
],
crate_root = "build.rs",
data = glob(["**"]),
edition = "2015",
rustc_flags = [
"--cap-lints=allow",
],
tags = [
"cargo-raze",
"manual",
],
version = "0.4.11",
visibility = ["//visibility:private"],
deps = [
],
)

rust_library(
name = "log",
Expand All @@ -42,7 +67,6 @@ rust_library(
edition = "2015",
rustc_flags = [
"--cap-lints=allow",
"--cfg=atomic_cas",
],
tags = [
"cargo-raze",
Expand All @@ -51,6 +75,7 @@ rust_library(
version = "0.4.11",
# buildifier: leave-alone
deps = [
":log_build_script",
"@raze__cfg_if__0_1_10//:cfg_if",
],
)
Expand Down

0 comments on commit 76f240a

Please sign in to comment.