Skip to content

Commit

Permalink
new helper functions + arg_path generic
Browse files Browse the repository at this point in the history
  • Loading branch information
Oneirical committed Mar 30, 2024
1 parent e473b04 commit 11676be
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 10 deletions.
22 changes: 19 additions & 3 deletions src/tools/run-make-support/src/rustc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -106,9 +106,25 @@ impl Rustc {
}

/// Generic file path provider.
pub fn arg_path(&mut self, path: &[&str]) -> &mut Self {
let path_buf = path.iter().collect::<PathBuf>();
self.cmd.arg(path_buf.to_str().unwrap());
pub fn arg_path<P>(&mut self, path: P) -> &mut Self
where
P: AsRef<Path>,
{
self.cmd.arg(path.as_ref());
self
}

/// Specify the crate type.
pub fn crate_type(&mut self, crate_type: &str) -> &mut Self {
self.cmd.arg("--crate-type");
self.cmd.arg(crate_type);
self
}

/// Specify the edition year.
pub fn edition(&mut self, edition: &str) -> &mut Self {
self.cmd.arg("--edition");
self.cmd.arg(edition);
self
}

Expand Down
11 changes: 4 additions & 7 deletions tests/run-make/core-no-fp-fmt-parse/rmake.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,10 @@ use std::path::PathBuf;

fn main() {
rustc()
.arg("--edition")
.arg("2021")
.edition("2021")
.arg("-Dwarnings")
.arg("--crate-type")
.arg("rlib")
.arg_path(&["..", "..", "..", "library", "core", "src", "lib.rs"])
.arg("--cfg")
.arg("no_fp_fmt_parse")
.crate_type("rlib")
.arg_path("../../../library/core/src/lib.rs")
.cfg("no_fp_fmt_parse")
.run();
}

0 comments on commit 11676be

Please sign in to comment.