@@ -8,7 +8,6 @@ use rustc_session::cstore::DllImport;
8
8
9
9
struct ArchiveConfig < ' a > {
10
10
sess : & ' a Session ,
11
- dst : PathBuf ,
12
11
use_native_ar : bool ,
13
12
use_gnu_style_archive : bool ,
14
13
}
@@ -31,10 +30,9 @@ pub struct ArArchiveBuilder<'a> {
31
30
}
32
31
33
32
impl < ' a > ArchiveBuilder < ' a > for ArArchiveBuilder < ' a > {
34
- fn new ( sess : & ' a Session , output : & Path ) -> Self {
33
+ fn new ( sess : & ' a Session ) -> Self {
35
34
let config = ArchiveConfig {
36
35
sess,
37
- dst : output. to_path_buf ( ) ,
38
36
use_native_ar : false ,
39
37
// FIXME test for linux and System V derivatives instead
40
38
use_gnu_style_archive : sess. target . options . archive_format == "gnu" ,
@@ -77,7 +75,7 @@ impl<'a> ArchiveBuilder<'a> for ArArchiveBuilder<'a> {
77
75
Ok ( ( ) )
78
76
}
79
77
80
- fn build ( mut self ) -> bool {
78
+ fn build ( mut self , output : & Path ) -> bool {
81
79
use std:: process:: Command ;
82
80
83
81
fn add_file_using_ar ( archive : & Path , file : & Path ) {
@@ -97,17 +95,17 @@ impl<'a> ArchiveBuilder<'a> for ArArchiveBuilder<'a> {
97
95
}
98
96
99
97
let mut builder = if self . config . use_native_ar {
100
- BuilderKind :: NativeAr ( & self . config . dst )
98
+ BuilderKind :: NativeAr ( output )
101
99
} else if self . config . use_gnu_style_archive {
102
100
BuilderKind :: Gnu ( ar:: GnuBuilder :: new (
103
- File :: create ( & self . config . dst ) . unwrap ( ) ,
101
+ File :: create ( output ) . unwrap ( ) ,
104
102
self . entries
105
103
. iter ( )
106
104
. map ( |( name, _) | name. as_bytes ( ) . to_vec ( ) )
107
105
. collect ( ) ,
108
106
) )
109
107
} else {
110
- BuilderKind :: Bsd ( ar:: Builder :: new ( File :: create ( & self . config . dst ) . unwrap ( ) ) )
108
+ BuilderKind :: Bsd ( ar:: Builder :: new ( File :: create ( output ) . unwrap ( ) ) )
111
109
} ;
112
110
113
111
let any_members = !self . entries . is_empty ( ) ;
@@ -164,10 +162,8 @@ impl<'a> ArchiveBuilder<'a> for ArArchiveBuilder<'a> {
164
162
std:: mem:: drop ( builder) ;
165
163
166
164
// 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" ) ;
171
167
172
168
if !status. success ( ) {
173
169
self . config . sess . fatal ( & format ! ( "Ranlib exited with code {:?}" , status. code( ) ) ) ;
0 commit comments