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``
This commit is contained in:
Matthias Krüger 2024-06-30 18:25:35 +02:00 committed by GitHub
commit 4037197353
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
8 changed files with 15 additions and 18 deletions

View File

@ -525,11 +525,12 @@ pub fn arg<S>(&mut self, arg: S) -> &mut Self
/// Generic command arguments provider. Prefer specific helper methods if possible.
/// Note that for some executables, arguments might be platform specific. For C/C++
/// compilers, arguments might be platform *and* compiler specific.
pub fn args<S>(&mut self, args: &[S]) -> &mut Self
pub fn args<V, S>(&mut self, args: V) -> &mut Self
where
V: AsRef<[S]>,
S: AsRef<::std::ffi::OsStr>,
{
self.cmd.args(args);
self.cmd.args(args.as_ref());
self
}

View File

@ -10,8 +10,8 @@ pub fn main() {
cc().input("test.c")
.input(static_lib_name("nonclike"))
.out_exe("test")
.args(&extra_c_flags())
.args(&extra_cxx_flags())
.args(extra_c_flags())
.args(extra_cxx_flags())
.inspect(|cmd| eprintln!("{cmd:?}"))
.run();
run("test");

View File

@ -9,7 +9,7 @@
fn main() {
rustc().input("foo.rs").run();
cc().input("bar.c").input(static_lib_name("foo")).out_exe("bar").args(&extra_c_flags()).run();
cc().input("bar.c").input(static_lib_name("foo")).out_exe("bar").args(extra_c_flags()).run();
run("bar");
remove_file(static_lib_name("foo"));
run("bar");

View File

@ -12,7 +12,7 @@ fn main() {
cc().input("test.c")
.input(static_lib_name("checkrust"))
.out_exe("test")
.args(&extra_c_flags())
.args(extra_c_flags())
.run();
run("test");
}

View File

@ -11,8 +11,8 @@ fn main() {
cc().input("program.c")
.arg(static_lib_name("library"))
.out_exe("program")
.args(&extra_c_flags())
.args(&extra_cxx_flags())
.args(extra_c_flags())
.args(extra_cxx_flags())
.run();
run(&bin_name("program"));
}

View File

@ -86,12 +86,8 @@ fn main() {
}
fn check(CheckCfg { args, contains }: CheckCfg) {
let output = rustc()
.input("lib.rs")
.arg("-Zunstable-options")
.arg("--print=check-cfg")
.args(&*args)
.run();
let output =
rustc().input("lib.rs").arg("-Zunstable-options").arg("--print=check-cfg").args(args).run();
let stdout = output.stdout_utf8();

View File

@ -11,8 +11,8 @@ fn main() {
cc().input("test.c")
.arg(&static_lib_name("nonclike"))
.out_exe("test")
.args(&extra_c_flags())
.args(&extra_cxx_flags())
.args(extra_c_flags())
.args(extra_cxx_flags())
.run();
run("test");
}

View File

@ -20,8 +20,8 @@ fn main() {
.out_exe(&dynamic_lib_name("bar"))
.arg("-fPIC")
.arg("-shared")
.args(&extra_c_flags())
.args(&extra_cxx_flags())
.args(extra_c_flags())
.args(extra_cxx_flags())
.run();
llvm_readobj()
.input(dynamic_lib_name("bar"))