@@ -8,7 +8,6 @@ use rustc_session::cstore::DllImport;
88
99struct ArchiveConfig < ' a > {
1010 sess : & ' a Session ,
11- dst : PathBuf ,
1211 use_native_ar : bool ,
1312 use_gnu_style_archive : bool ,
1413}
@@ -31,10 +30,9 @@ pub struct ArArchiveBuilder<'a> {
3130}
3231
3332impl < ' a > ArchiveBuilder < ' a > for ArArchiveBuilder < ' a > {
34- fn new ( sess : & ' a Session , output : & Path ) -> Self {
33+ fn new ( sess : & ' a Session ) -> Self {
3534 let config = ArchiveConfig {
3635 sess,
37- dst : output. to_path_buf ( ) ,
3836 use_native_ar : false ,
3937 // FIXME test for linux and System V derivatives instead
4038 use_gnu_style_archive : sess. target . options . archive_format == "gnu" ,
@@ -77,7 +75,7 @@ impl<'a> ArchiveBuilder<'a> for ArArchiveBuilder<'a> {
7775 Ok ( ( ) )
7876 }
7977
80- fn build ( mut self ) -> bool {
78+ fn build ( mut self , output : & Path ) -> bool {
8179 use std:: process:: Command ;
8280
8381 fn add_file_using_ar ( archive : & Path , file : & Path ) {
@@ -97,17 +95,17 @@ impl<'a> ArchiveBuilder<'a> for ArArchiveBuilder<'a> {
9795 }
9896
9997 let mut builder = if self . config . use_native_ar {
100- BuilderKind :: NativeAr ( & self . config . dst )
98+ BuilderKind :: NativeAr ( output )
10199 } else if self . config . use_gnu_style_archive {
102100 BuilderKind :: Gnu ( ar:: GnuBuilder :: new (
103- File :: create ( & self . config . dst ) . unwrap ( ) ,
101+ File :: create ( output ) . unwrap ( ) ,
104102 self . entries
105103 . iter ( )
106104 . map ( |( name, _) | name. as_bytes ( ) . to_vec ( ) )
107105 . collect ( ) ,
108106 ) )
109107 } else {
110- BuilderKind :: Bsd ( ar:: Builder :: new ( File :: create ( & self . config . dst ) . unwrap ( ) ) )
108+ BuilderKind :: Bsd ( ar:: Builder :: new ( File :: create ( output ) . unwrap ( ) ) )
111109 } ;
112110
113111 let any_members = !self . entries . is_empty ( ) ;
@@ -164,10 +162,8 @@ impl<'a> ArchiveBuilder<'a> for ArArchiveBuilder<'a> {
164162 std:: mem:: drop ( builder) ;
165163
166164 // Run ranlib to be able to link the archive
167- let status = std:: process:: Command :: new ( "ranlib" )
168- . arg ( self . config . dst )
169- . status ( )
170- . expect ( "Couldn't run ranlib" ) ;
165+ let status =
166+ std:: process:: Command :: new ( "ranlib" ) . arg ( output) . status ( ) . expect ( "Couldn't run ranlib" ) ;
171167
172168 if !status. success ( ) {
173169 self . config . sess . fatal ( & format ! ( "Ranlib exited with code {:?}" , status. code( ) ) ) ;
0 commit comments