Skip to content

Commit 210c378

Browse files
committed
Switch to busybox style /bin/false
1 parent 38b2373 commit 210c378

File tree

2 files changed

+22
-19
lines changed

2 files changed

+22
-19
lines changed

cargo/private/BUILD.bazel

Lines changed: 17 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
load("@bazel_skylib//:bzl_library.bzl", "bzl_library")
2+
load("@bazel_skylib//rules:copy_file.bzl", "copy_file")
23
load("//rust:defs.bzl", "rust_binary")
34

45
rust_binary(
@@ -9,33 +10,31 @@ rust_binary(
910
)
1011

1112
rust_binary(
12-
name = "no_ar",
13+
name = "no_binary",
1314
srcs = ["no_binary.rs"],
1415
edition = "2021",
15-
rustc_env = {
16-
"BINARY_ENV": "AR",
17-
},
1816
visibility = ["//visibility:public"],
1917
)
2018

21-
rust_binary(
19+
copy_file(
20+
name = "no_ar",
21+
src = ":no_binary",
22+
out = "no_ar.exe",
23+
is_executable = True,
24+
)
25+
26+
copy_file(
2227
name = "no_cc",
23-
srcs = ["no_binary.rs"],
24-
edition = "2021",
25-
rustc_env = {
26-
"BINARY_ENV": "CC",
27-
},
28-
visibility = ["//visibility:public"],
28+
src = ":no_binary",
29+
out = "no_cc.exe",
30+
is_executable = True,
2931
)
3032

31-
rust_binary(
33+
copy_file(
3234
name = "no_cxx",
33-
srcs = ["no_binary.rs"],
34-
edition = "2021",
35-
rustc_env = {
36-
"BINARY_ENV": "CXX",
37-
},
38-
visibility = ["//visibility:public"],
35+
src = ":no_binary",
36+
out = "no_cxx.exe",
37+
is_executable = True,
3938
)
4039

4140
bzl_library(

cargo/private/no_binary.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
//! A cross platform implementation of `/bin/false`
22
33
fn main() {
4-
eprintln!(concat!("No binary provided for ", env!("BINARY_ENV")));
4+
let program_name = std::env::args()
5+
.next()
6+
.unwrap_or_else(|| "unknown".to_string());
7+
8+
eprintln!("No binary provided for {}", program_name);
59
std::process::exit(1);
610
}

0 commit comments

Comments
 (0)