run_make_support: move ar
into own module
This commit is contained in:
parent
f042e72d1e
commit
439c6f60c7
2 changed files with 30 additions and 14 deletions
22
src/tools/run-make-support/src/ar.rs
Normal file
22
src/tools/run-make-support/src/ar.rs
Normal file
|
@ -0,0 +1,22 @@
|
|||
use std::fs;
|
||||
use std::path::Path;
|
||||
|
||||
/// Archive utility.
|
||||
///
|
||||
/// # Notes
|
||||
///
|
||||
/// This *currently* uses the [ar][rust-ar] crate, but this is subject to changes. We may need to
|
||||
/// use `llvm-ar`, and if that is the case, this should be moved under `external_deps`.
|
||||
///
|
||||
/// [rust-ar]: https://github.com/mdsteele/rust-ar
|
||||
#[track_caller]
|
||||
pub fn ar(inputs: &[impl AsRef<Path>], output_path: impl AsRef<Path>) {
|
||||
let output = fs::File::create(&output_path).expect(&format!(
|
||||
"the file in path `{}` could not be created",
|
||||
output_path.as_ref().display()
|
||||
));
|
||||
let mut builder = ar::Builder::new(output);
|
||||
for input in inputs {
|
||||
builder.append_path(input).unwrap();
|
||||
}
|
||||
}
|
|
@ -6,6 +6,7 @@
|
|||
mod command;
|
||||
mod macros;
|
||||
|
||||
pub mod ar;
|
||||
pub mod diff;
|
||||
pub mod env_checked;
|
||||
pub mod external_deps;
|
||||
|
@ -40,7 +41,13 @@ pub use python::python_command;
|
|||
pub use rustc::{aux_build, bare_rustc, rustc, Rustc};
|
||||
pub use rustdoc::{bare_rustdoc, rustdoc, Rustdoc};
|
||||
|
||||
/// [`diff`] is implemented in terms of the [similar] library.
|
||||
/// [`ar`][mod@ar] currently uses the [ar][rust-ar] rust library, but that is subject to changes, we
|
||||
/// may switch to `llvm-ar` subject to experimentation.
|
||||
///
|
||||
/// [rust-ar]: https://github.com/mdsteele/rust-ar
|
||||
pub use ar::ar;
|
||||
|
||||
/// [`diff`][mod@diff] is implemented in terms of the [similar] library.
|
||||
///
|
||||
/// [similar]: https://github.com/mitsuhiko/similar
|
||||
pub use diff::{diff, Diff};
|
||||
|
@ -56,19 +63,6 @@ pub use targets::{is_darwin, is_msvc, is_windows, target, uname};
|
|||
|
||||
use command::{Command, CompletedProcess};
|
||||
|
||||
/// `AR`
|
||||
#[track_caller]
|
||||
pub fn ar(inputs: &[impl AsRef<Path>], output_path: impl AsRef<Path>) {
|
||||
let output = fs::File::create(&output_path).expect(&format!(
|
||||
"the file in path \"{}\" could not be created",
|
||||
output_path.as_ref().display()
|
||||
));
|
||||
let mut builder = ar::Builder::new(output);
|
||||
for input in inputs {
|
||||
builder.append_path(input).unwrap();
|
||||
}
|
||||
}
|
||||
|
||||
/// Returns the path for a local test file.
|
||||
pub fn path<P: AsRef<Path>>(p: P) -> PathBuf {
|
||||
cwd().join(p.as_ref())
|
||||
|
|
Loading…
Add table
Reference in a new issue