Skip to content

Commit 4cb2db7

Browse files
authored
Use cargo-raze's gen_buildrs for trusted crates. (#53)
Signed-off-by: Piotr Sikora <piotrsikora@google.com>
1 parent 39d49d8 commit 4cb2db7

File tree

5 files changed

+130
-28
lines changed

5 files changed

+130
-28
lines changed

.github/workflows/rust.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ jobs:
7575
7676
- name: Format (cargo raze)
7777
run: |
78-
cargo install cargo-raze --git https://github.com/google/cargo-raze --rev cb9f85d22b1c81cceb9acaf1fa4336c5fc4e6bff
78+
cargo install cargo-raze --version 0.7.0
7979
cp -p bazel/cargo/Cargo.lock .
8080
rm -rf bazel/cargo/
8181
cargo raze --output=bazel/cargo

Cargo.toml

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -32,19 +32,14 @@ panic = "abort"
3232
workspace_path = "//bazel/cargo"
3333
genmode = "Remote"
3434

35-
[package.metadata.raze.crates.libc.'0.2.80']
36-
additional_flags = [
37-
"--cfg=libc_priv_mod_use",
38-
"--cfg=libc_union",
39-
"--cfg=libc_const_size_of",
40-
"--cfg=libc_align",
41-
"--cfg=libc_core_cvoid",
42-
"--cfg=libc_packedN",
43-
"--cfg=libc_cfg_target_vendor",
44-
]
35+
[package.metadata.raze.crates.getrandom.'=0.2.0']
36+
gen_buildrs = true
4537

46-
[package.metadata.raze.crates.log.'0.4.11']
47-
additional_flags = ["--cfg=atomic_cas"]
38+
[package.metadata.raze.crates.libc.'=0.2.80']
39+
gen_buildrs = true
40+
41+
[package.metadata.raze.crates.log.'=0.4.11']
42+
gen_buildrs = true
4843

4944
[[example]]
5045
name = "hello_world"

bazel/cargo/remote/BUILD.getrandom-0.2.0.bazel

Lines changed: 64 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,71 @@ licenses([
2828
"notice", # MIT from expression "MIT OR Apache-2.0"
2929
])
3030

31-
# Generated Targets
31+
# Generated Targets# buildifier: disable=load-on-top
32+
load(
33+
"@io_bazel_rules_rust//cargo:cargo_build_script.bzl",
34+
"cargo_build_script",
35+
)
3236

33-
# Unsupported target "mod" with type "bench" omitted
37+
cargo_build_script(
38+
name = "getrandom_build_script",
39+
srcs = glob(["**/*.rs"]),
40+
build_script_env = {
41+
},
42+
crate_features = [
43+
],
44+
crate_root = "build.rs",
45+
data = glob(["**"]),
46+
edition = "2018",
47+
rustc_flags = [
48+
"--cap-lints=allow",
49+
],
50+
tags = [
51+
"cargo-raze",
52+
"manual",
53+
],
54+
version = "0.2.0",
55+
visibility = ["//visibility:private"],
56+
deps = [
57+
] + selects.with_or({
58+
# cfg(all(target_arch = "wasm32", target_os = "unknown", not(cargo_web)))
59+
(
60+
"@io_bazel_rules_rust//rust/platform:wasm32-unknown-unknown",
61+
): [
62+
],
63+
"//conditions:default": [],
64+
}) + selects.with_or({
65+
# cfg(target_os = "wasi")
66+
(
67+
"@io_bazel_rules_rust//rust/platform:wasm32-wasi",
68+
): [
69+
],
70+
"//conditions:default": [],
71+
}) + selects.with_or({
72+
# cfg(unix)
73+
(
74+
"@io_bazel_rules_rust//rust/platform:aarch64-apple-ios",
75+
"@io_bazel_rules_rust//rust/platform:aarch64-linux-android",
76+
"@io_bazel_rules_rust//rust/platform:aarch64-unknown-linux-gnu",
77+
"@io_bazel_rules_rust//rust/platform:arm-unknown-linux-gnueabi",
78+
"@io_bazel_rules_rust//rust/platform:i686-apple-darwin",
79+
"@io_bazel_rules_rust//rust/platform:i686-linux-android",
80+
"@io_bazel_rules_rust//rust/platform:i686-unknown-freebsd",
81+
"@io_bazel_rules_rust//rust/platform:i686-unknown-linux-gnu",
82+
"@io_bazel_rules_rust//rust/platform:powerpc-unknown-linux-gnu",
83+
"@io_bazel_rules_rust//rust/platform:s390x-unknown-linux-gnu",
84+
"@io_bazel_rules_rust//rust/platform:x86_64-apple-darwin",
85+
"@io_bazel_rules_rust//rust/platform:x86_64-apple-ios",
86+
"@io_bazel_rules_rust//rust/platform:x86_64-linux-android",
87+
"@io_bazel_rules_rust//rust/platform:x86_64-unknown-freebsd",
88+
"@io_bazel_rules_rust//rust/platform:x86_64-unknown-linux-gnu",
89+
): [
90+
],
91+
"//conditions:default": [],
92+
}),
93+
)
3494

35-
# Unsupported target "build-script-build" with type "custom-build" omitted
95+
# Unsupported target "mod" with type "bench" omitted
3696

3797
rust_library(
3898
name = "getrandom",
@@ -54,6 +114,7 @@ rust_library(
54114
version = "0.2.0",
55115
# buildifier: leave-alone
56116
deps = [
117+
":getrandom_build_script",
57118
"@raze__cfg_if__0_1_10//:cfg_if",
58119
] + selects.with_or({
59120
# cfg(all(target_arch = "wasm32", target_os = "unknown", not(cargo_web)))

bazel/cargo/remote/BUILD.libc-0.2.80.bazel

Lines changed: 30 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,36 @@ licenses([
2828
"notice", # MIT from expression "MIT OR Apache-2.0"
2929
])
3030

31-
# Generated Targets
31+
# Generated Targets# buildifier: disable=load-on-top
32+
load(
33+
"@io_bazel_rules_rust//cargo:cargo_build_script.bzl",
34+
"cargo_build_script",
35+
)
3236

33-
# Unsupported target "build-script-build" with type "custom-build" omitted
37+
cargo_build_script(
38+
name = "libc_build_script",
39+
srcs = glob(["**/*.rs"]),
40+
build_script_env = {
41+
},
42+
crate_features = [
43+
"default",
44+
"std",
45+
],
46+
crate_root = "build.rs",
47+
data = glob(["**"]),
48+
edition = "2015",
49+
rustc_flags = [
50+
"--cap-lints=allow",
51+
],
52+
tags = [
53+
"cargo-raze",
54+
"manual",
55+
],
56+
version = "0.2.80",
57+
visibility = ["//visibility:private"],
58+
deps = [
59+
],
60+
)
3461

3562
rust_library(
3663
name = "libc",
@@ -44,13 +71,6 @@ rust_library(
4471
edition = "2015",
4572
rustc_flags = [
4673
"--cap-lints=allow",
47-
"--cfg=libc_priv_mod_use",
48-
"--cfg=libc_union",
49-
"--cfg=libc_const_size_of",
50-
"--cfg=libc_align",
51-
"--cfg=libc_core_cvoid",
52-
"--cfg=libc_packedN",
53-
"--cfg=libc_cfg_target_vendor",
5474
],
5575
tags = [
5676
"cargo-raze",
@@ -59,6 +79,7 @@ rust_library(
5979
version = "0.2.80",
6080
# buildifier: leave-alone
6181
deps = [
82+
":libc_build_script",
6283
],
6384
)
6485

bazel/cargo/remote/BUILD.log-0.4.11.bazel

Lines changed: 28 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,34 @@ licenses([
2828
"notice", # MIT from expression "MIT OR Apache-2.0"
2929
])
3030

31-
# Generated Targets
31+
# Generated Targets# buildifier: disable=load-on-top
32+
load(
33+
"@io_bazel_rules_rust//cargo:cargo_build_script.bzl",
34+
"cargo_build_script",
35+
)
3236

33-
# Unsupported target "build-script-build" with type "custom-build" omitted
37+
cargo_build_script(
38+
name = "log_build_script",
39+
srcs = glob(["**/*.rs"]),
40+
build_script_env = {
41+
},
42+
crate_features = [
43+
],
44+
crate_root = "build.rs",
45+
data = glob(["**"]),
46+
edition = "2015",
47+
rustc_flags = [
48+
"--cap-lints=allow",
49+
],
50+
tags = [
51+
"cargo-raze",
52+
"manual",
53+
],
54+
version = "0.4.11",
55+
visibility = ["//visibility:private"],
56+
deps = [
57+
],
58+
)
3459

3560
rust_library(
3661
name = "log",
@@ -42,7 +67,6 @@ rust_library(
4267
edition = "2015",
4368
rustc_flags = [
4469
"--cap-lints=allow",
45-
"--cfg=atomic_cas",
4670
],
4771
tags = [
4872
"cargo-raze",
@@ -51,6 +75,7 @@ rust_library(
5175
version = "0.4.11",
5276
# buildifier: leave-alone
5377
deps = [
78+
":log_build_script",
5479
"@raze__cfg_if__0_1_10//:cfg_if",
5580
],
5681
)

0 commit comments

Comments
 (0)