Skip to content

Commit 4037197

Browse files
authored
Rollup merge of #127161 - GuillaumeGomez:improve-run-make-args, r=Kobzol
Improve `run-make-support` library `args` API It allows to pass both `Vec` and slices, which makes it much better (for me at least 😉). r? ``@Kobzol``
2 parents 6335b83 + 4b516f5 commit 4037197

File tree

8 files changed

+15
-18
lines changed

8 files changed

+15
-18
lines changed

src/tools/run-make-support/src/lib.rs

+3-2
Original file line numberDiff line numberDiff line change
@@ -525,11 +525,12 @@ macro_rules! impl_common_helpers {
525525
/// Generic command arguments provider. Prefer specific helper methods if possible.
526526
/// Note that for some executables, arguments might be platform specific. For C/C++
527527
/// compilers, arguments might be platform *and* compiler specific.
528-
pub fn args<S>(&mut self, args: &[S]) -> &mut Self
528+
pub fn args<V, S>(&mut self, args: V) -> &mut Self
529529
where
530+
V: AsRef<[S]>,
530531
S: AsRef<::std::ffi::OsStr>,
531532
{
532-
self.cmd.args(args);
533+
self.cmd.args(args.as_ref());
533534
self
534535
}
535536

tests/run-make/arguments-non-c-like-enum/rmake.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ pub fn main() {
1010
cc().input("test.c")
1111
.input(static_lib_name("nonclike"))
1212
.out_exe("test")
13-
.args(&extra_c_flags())
14-
.args(&extra_cxx_flags())
13+
.args(extra_c_flags())
14+
.args(extra_cxx_flags())
1515
.inspect(|cmd| eprintln!("{cmd:?}"))
1616
.run();
1717
run("test");

tests/run-make/c-link-to-rust-staticlib/rmake.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ use std::fs;
99

1010
fn main() {
1111
rustc().input("foo.rs").run();
12-
cc().input("bar.c").input(static_lib_name("foo")).out_exe("bar").args(&extra_c_flags()).run();
12+
cc().input("bar.c").input(static_lib_name("foo")).out_exe("bar").args(extra_c_flags()).run();
1313
run("bar");
1414
remove_file(static_lib_name("foo"));
1515
run("bar");

tests/run-make/c-link-to-rust-va-list-fn/rmake.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ fn main() {
1212
cc().input("test.c")
1313
.input(static_lib_name("checkrust"))
1414
.out_exe("test")
15-
.args(&extra_c_flags())
15+
.args(extra_c_flags())
1616
.run();
1717
run("test");
1818
}

tests/run-make/glibc-staticlib-args/rmake.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ fn main() {
1111
cc().input("program.c")
1212
.arg(static_lib_name("library"))
1313
.out_exe("program")
14-
.args(&extra_c_flags())
15-
.args(&extra_cxx_flags())
14+
.args(extra_c_flags())
15+
.args(extra_cxx_flags())
1616
.run();
1717
run(&bin_name("program"));
1818
}

tests/run-make/print-check-cfg/rmake.rs

+2-6
Original file line numberDiff line numberDiff line change
@@ -86,12 +86,8 @@ fn main() {
8686
}
8787

8888
fn check(CheckCfg { args, contains }: CheckCfg) {
89-
let output = rustc()
90-
.input("lib.rs")
91-
.arg("-Zunstable-options")
92-
.arg("--print=check-cfg")
93-
.args(&*args)
94-
.run();
89+
let output =
90+
rustc().input("lib.rs").arg("-Zunstable-options").arg("--print=check-cfg").args(args).run();
9591

9692
let stdout = output.stdout_utf8();
9793

tests/run-make/return-non-c-like-enum/rmake.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ fn main() {
1111
cc().input("test.c")
1212
.arg(&static_lib_name("nonclike"))
1313
.out_exe("test")
14-
.args(&extra_c_flags())
15-
.args(&extra_cxx_flags())
14+
.args(extra_c_flags())
15+
.args(extra_cxx_flags())
1616
.run();
1717
run("test");
1818
}

tests/run-make/textrel-on-minimal-lib/rmake.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@ fn main() {
2020
.out_exe(&dynamic_lib_name("bar"))
2121
.arg("-fPIC")
2222
.arg("-shared")
23-
.args(&extra_c_flags())
24-
.args(&extra_cxx_flags())
23+
.args(extra_c_flags())
24+
.args(extra_cxx_flags())
2525
.run();
2626
llvm_readobj()
2727
.input(dynamic_lib_name("bar"))

0 commit comments

Comments
 (0)