diff --git a/src/tools/run-make-support/src/ar.rs b/src/tools/run-make-support/src/ar.rs new file mode 100644 index 00000000000..6f46a1dad34 --- /dev/null +++ b/src/tools/run-make-support/src/ar.rs @@ -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], output_path: impl AsRef) { + 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(); + } +} diff --git a/src/tools/run-make-support/src/lib.rs b/src/tools/run-make-support/src/lib.rs index e7ac23f6310..cb9d5ff90a7 100644 --- a/src/tools/run-make-support/src/lib.rs +++ b/src/tools/run-make-support/src/lib.rs @@ -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], output_path: impl AsRef) { - 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: P) -> PathBuf { cwd().join(p.as_ref())