Move output argument from ArchiveBuilder::new to .build()
This commit is contained in:
parent
48316dfea1
commit
7c93154a30
5 changed files with 29 additions and 44 deletions
|
@ -19,7 +19,6 @@ enum ArchiveEntry {
|
|||
|
||||
pub(crate) struct ArArchiveBuilder<'a> {
|
||||
sess: &'a Session,
|
||||
dst: PathBuf,
|
||||
use_gnu_style_archive: bool,
|
||||
no_builtin_ranlib: bool,
|
||||
|
||||
|
@ -30,10 +29,9 @@ pub(crate) struct ArArchiveBuilder<'a> {
|
|||
}
|
||||
|
||||
impl<'a> ArchiveBuilder<'a> for ArArchiveBuilder<'a> {
|
||||
fn new(sess: &'a Session, output: &Path) -> Self {
|
||||
fn new(sess: &'a Session) -> Self {
|
||||
ArArchiveBuilder {
|
||||
sess,
|
||||
dst: output.to_path_buf(),
|
||||
use_gnu_style_archive: sess.target.archive_format == "gnu",
|
||||
// FIXME fix builtin ranlib on macOS
|
||||
no_builtin_ranlib: sess.target.is_like_osx,
|
||||
|
@ -74,7 +72,7 @@ impl<'a> ArchiveBuilder<'a> for ArArchiveBuilder<'a> {
|
|||
Ok(())
|
||||
}
|
||||
|
||||
fn build(mut self) -> bool {
|
||||
fn build(mut self, output: &Path) -> bool {
|
||||
enum BuilderKind {
|
||||
Bsd(ar::Builder<File>),
|
||||
Gnu(ar::GnuBuilder<File>),
|
||||
|
@ -163,7 +161,7 @@ impl<'a> ArchiveBuilder<'a> for ArArchiveBuilder<'a> {
|
|||
let mut builder = if self.use_gnu_style_archive {
|
||||
BuilderKind::Gnu(
|
||||
ar::GnuBuilder::new(
|
||||
File::create(&self.dst).unwrap_or_else(|err| {
|
||||
File::create(output).unwrap_or_else(|err| {
|
||||
sess.fatal(&format!(
|
||||
"error opening destination during archive building: {}",
|
||||
err
|
||||
|
@ -178,7 +176,7 @@ impl<'a> ArchiveBuilder<'a> for ArArchiveBuilder<'a> {
|
|||
} else {
|
||||
BuilderKind::Bsd(
|
||||
ar::Builder::new(
|
||||
File::create(&self.dst).unwrap_or_else(|err| {
|
||||
File::create(output).unwrap_or_else(|err| {
|
||||
sess.fatal(&format!(
|
||||
"error opening destination during archive building: {}",
|
||||
err
|
||||
|
@ -209,7 +207,7 @@ impl<'a> ArchiveBuilder<'a> for ArArchiveBuilder<'a> {
|
|||
|
||||
// Run ranlib to be able to link the archive
|
||||
let status = std::process::Command::new(ranlib)
|
||||
.arg(self.dst)
|
||||
.arg(output)
|
||||
.status()
|
||||
.expect("Couldn't run ranlib");
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue