Skip to content

Commit e0697a3

Browse files
committed
Move output argument from ArchiveBuilder::new to .build()
1 parent a6260ec commit e0697a3

File tree

1 file changed

+5
-7
lines changed

1 file changed

+5
-7
lines changed

Diff for: src/archive.rs

+5-7
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ enum ArchiveEntry {
1919

2020
pub(crate) struct ArArchiveBuilder<'a> {
2121
sess: &'a Session,
22-
dst: PathBuf,
2322
use_gnu_style_archive: bool,
2423
no_builtin_ranlib: bool,
2524

@@ -30,10 +29,9 @@ pub(crate) struct ArArchiveBuilder<'a> {
3029
}
3130

3231
impl<'a> ArchiveBuilder<'a> for ArArchiveBuilder<'a> {
33-
fn new(sess: &'a Session, output: &Path) -> Self {
32+
fn new(sess: &'a Session) -> Self {
3433
ArArchiveBuilder {
3534
sess,
36-
dst: output.to_path_buf(),
3735
use_gnu_style_archive: sess.target.archive_format == "gnu",
3836
// FIXME fix builtin ranlib on macOS
3937
no_builtin_ranlib: sess.target.is_like_osx,
@@ -74,7 +72,7 @@ impl<'a> ArchiveBuilder<'a> for ArArchiveBuilder<'a> {
7472
Ok(())
7573
}
7674

77-
fn build(mut self) -> bool {
75+
fn build(mut self, output: &Path) -> bool {
7876
enum BuilderKind {
7977
Bsd(ar::Builder<File>),
8078
Gnu(ar::GnuBuilder<File>),
@@ -163,7 +161,7 @@ impl<'a> ArchiveBuilder<'a> for ArArchiveBuilder<'a> {
163161
let mut builder = if self.use_gnu_style_archive {
164162
BuilderKind::Gnu(
165163
ar::GnuBuilder::new(
166-
File::create(&self.dst).unwrap_or_else(|err| {
164+
File::create(output).unwrap_or_else(|err| {
167165
sess.fatal(&format!(
168166
"error opening destination during archive building: {}",
169167
err
@@ -178,7 +176,7 @@ impl<'a> ArchiveBuilder<'a> for ArArchiveBuilder<'a> {
178176
} else {
179177
BuilderKind::Bsd(
180178
ar::Builder::new(
181-
File::create(&self.dst).unwrap_or_else(|err| {
179+
File::create(output).unwrap_or_else(|err| {
182180
sess.fatal(&format!(
183181
"error opening destination during archive building: {}",
184182
err
@@ -209,7 +207,7 @@ impl<'a> ArchiveBuilder<'a> for ArArchiveBuilder<'a> {
209207

210208
// Run ranlib to be able to link the archive
211209
let status = std::process::Command::new(ranlib)
212-
.arg(self.dst)
210+
.arg(output)
213211
.status()
214212
.expect("Couldn't run ranlib");
215213

0 commit comments

Comments
 (0)