Skip to content
This repository was archived by the owner on May 28, 2025. It is now read-only.

Commit 7c70651

Browse files
committed
run_make_support: move ar into own module
1 parent 52eb4ee commit 7c70651

File tree

2 files changed

+30
-14
lines changed

2 files changed

+30
-14
lines changed

src/tools/run-make-support/src/ar.rs

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
use std::fs;
2+
use std::path::Path;
3+
4+
/// Archive utility.
5+
///
6+
/// # Notes
7+
///
8+
/// This *currently* uses the [ar][rust-ar] crate, but this is subject to changes. We may need to
9+
/// use `llvm-ar`, and if that is the case, this should be moved under `external_deps`.
10+
///
11+
/// [rust-ar]: https://github.com/mdsteele/rust-ar
12+
#[track_caller]
13+
pub fn ar(inputs: &[impl AsRef<Path>], output_path: impl AsRef<Path>) {
14+
let output = fs::File::create(&output_path).expect(&format!(
15+
"the file in path `{}` could not be created",
16+
output_path.as_ref().display()
17+
));
18+
let mut builder = ar::Builder::new(output);
19+
for input in inputs {
20+
builder.append_path(input).unwrap();
21+
}
22+
}

src/tools/run-make-support/src/lib.rs

Lines changed: 8 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
mod command;
77
mod macros;
88

9+
pub mod ar;
910
pub mod diff;
1011
pub mod env_checked;
1112
pub mod external_deps;
@@ -40,7 +41,13 @@ pub use python::python_command;
4041
pub use rustc::{aux_build, bare_rustc, rustc, Rustc};
4142
pub use rustdoc::{bare_rustdoc, rustdoc, Rustdoc};
4243

43-
/// [`diff`] is implemented in terms of the [similar] library.
44+
/// [`ar`][mod@ar] currently uses the [ar][rust-ar] rust library, but that is subject to changes, we
45+
/// may switch to `llvm-ar` subject to experimentation.
46+
///
47+
/// [rust-ar]: https://github.com/mdsteele/rust-ar
48+
pub use ar::ar;
49+
50+
/// [`diff`][mod@diff] is implemented in terms of the [similar] library.
4451
///
4552
/// [similar]: https://github.com/mitsuhiko/similar
4653
pub use diff::{diff, Diff};
@@ -56,19 +63,6 @@ pub use targets::{is_darwin, is_msvc, is_windows, target, uname};
5663

5764
use command::{Command, CompletedProcess};
5865

59-
/// `AR`
60-
#[track_caller]
61-
pub fn ar(inputs: &[impl AsRef<Path>], output_path: impl AsRef<Path>) {
62-
let output = fs::File::create(&output_path).expect(&format!(
63-
"the file in path \"{}\" could not be created",
64-
output_path.as_ref().display()
65-
));
66-
let mut builder = ar::Builder::new(output);
67-
for input in inputs {
68-
builder.append_path(input).unwrap();
69-
}
70-
}
71-
7266
/// Returns the path for a local test file.
7367
pub fn path<P: AsRef<Path>>(p: P) -> PathBuf {
7468
cwd().join(p.as_ref())

0 commit comments

Comments
 (0)