@@ -32,7 +32,7 @@ pub struct ArArchiveBuilder<'a> {
32
32
}
33
33
34
34
impl < ' a > ArchiveBuilder < ' a > for ArArchiveBuilder < ' a > {
35
- fn new ( sess : & ' a Session , output : & Path , input : Option < & Path > ) -> Self {
35
+ fn new ( sess : & ' a Session , output : & Path ) -> Self {
36
36
let config = ArchiveConfig {
37
37
sess,
38
38
dst : output. to_path_buf ( ) ,
@@ -41,48 +41,13 @@ impl<'a> ArchiveBuilder<'a> for ArArchiveBuilder<'a> {
41
41
use_gnu_style_archive : sess. target . options . archive_format == "gnu" ,
42
42
} ;
43
43
44
- let ( src_archives, entries) = if let Some ( input) = input {
45
- let mut archive = ar:: Archive :: new ( File :: open ( input) . unwrap ( ) ) ;
46
- let mut entries = Vec :: new ( ) ;
47
-
48
- let mut i = 0 ;
49
- while let Some ( entry) = archive. next_entry ( ) {
50
- let entry = entry. unwrap ( ) ;
51
- entries. push ( (
52
- String :: from_utf8 ( entry. header ( ) . identifier ( ) . to_vec ( ) ) . unwrap ( ) ,
53
- ArchiveEntry :: FromArchive {
54
- archive_index : 0 ,
55
- entry_index : i,
56
- } ,
57
- ) ) ;
58
- i += 1 ;
59
- }
60
-
61
- ( vec ! [ ( input. to_owned( ) , archive) ] , entries)
62
- } else {
63
- ( vec ! [ ] , Vec :: new ( ) )
64
- } ;
65
-
66
44
ArArchiveBuilder {
67
45
config,
68
- src_archives,
69
- entries,
46
+ src_archives : vec ! [ ] ,
47
+ entries : vec ! [ ] ,
70
48
}
71
49
}
72
50
73
- fn src_files ( & mut self ) -> Vec < String > {
74
- self . entries . iter ( ) . map ( |( name, _) | name. clone ( ) ) . collect ( )
75
- }
76
-
77
- fn remove_file ( & mut self , name : & str ) {
78
- let index = self
79
- . entries
80
- . iter ( )
81
- . position ( |( entry_name, _) | entry_name == name)
82
- . expect ( "Tried to remove file not existing in src archive" ) ;
83
- self . entries . remove ( index) ;
84
- }
85
-
86
51
fn add_file ( & mut self , file : & Path ) {
87
52
self . entries . push ( (
88
53
file. file_name ( ) . unwrap ( ) . to_str ( ) . unwrap ( ) . to_string ( ) ,
@@ -113,7 +78,7 @@ impl<'a> ArchiveBuilder<'a> for ArArchiveBuilder<'a> {
113
78
Ok ( ( ) )
114
79
}
115
80
116
- fn build ( mut self ) {
81
+ fn build ( mut self ) -> bool {
117
82
use std:: process:: Command ;
118
83
119
84
fn add_file_using_ar ( archive : & Path , file : & Path ) {
@@ -146,6 +111,8 @@ impl<'a> ArchiveBuilder<'a> for ArArchiveBuilder<'a> {
146
111
BuilderKind :: Bsd ( ar:: Builder :: new ( File :: create ( & self . config . dst ) . unwrap ( ) ) )
147
112
} ;
148
113
114
+ let any_members = !self . entries . is_empty ( ) ;
115
+
149
116
// Add all files
150
117
for ( entry_name, entry) in self . entries . into_iter ( ) {
151
118
match entry {
@@ -206,6 +173,8 @@ impl<'a> ArchiveBuilder<'a> for ArArchiveBuilder<'a> {
206
173
if !status. success ( ) {
207
174
self . config . sess . fatal ( & format ! ( "Ranlib exited with code {:?}" , status. code( ) ) ) ;
208
175
}
176
+
177
+ any_members
209
178
}
210
179
211
180
fn inject_dll_import_lib ( & mut self , _lib_name : & str , _dll_imports : & [ DllImport ] , _tmpdir : & MaybeTempDir ) {
0 commit comments