Skip to content

Commit

Permalink
Unrolled build for rust-lang#127161
Browse files Browse the repository at this point in the history
Rollup merge of rust-lang#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``
  • Loading branch information
rust-timer authored Jun 30, 2024
2 parents ef3d6fd + 4b516f5 commit 5096860
Show file tree
Hide file tree
Showing 8 changed files with 15 additions and 18 deletions.
5 changes: 3 additions & 2 deletions src/tools/run-make-support/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -525,11 +525,12 @@ macro_rules! impl_common_helpers {
/// 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
}

Expand Down
4 changes: 2 additions & 2 deletions tests/run-make/arguments-non-c-like-enum/rmake.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down
2 changes: 1 addition & 1 deletion tests/run-make/c-link-to-rust-staticlib/rmake.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use std::fs;

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");
Expand Down
2 changes: 1 addition & 1 deletion tests/run-make/c-link-to-rust-va-list-fn/rmake.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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");
}
4 changes: 2 additions & 2 deletions tests/run-make/glibc-staticlib-args/rmake.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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"));
}
8 changes: 2 additions & 6 deletions tests/run-make/print-check-cfg/rmake.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand Down
4 changes: 2 additions & 2 deletions tests/run-make/return-non-c-like-enum/rmake.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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");
}
4 changes: 2 additions & 2 deletions tests/run-make/textrel-on-minimal-lib/rmake.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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"))
Expand Down

0 comments on commit 5096860

Please sign in to comment.