@@ -30,50 +30,19 @@ pub(crate) struct ArArchiveBuilder<'a> {
30
30
}
31
31
32
32
impl < ' a > ArchiveBuilder < ' a > for ArArchiveBuilder < ' a > {
33
- fn new ( sess : & ' a Session , output : & Path , input : Option < & Path > ) -> Self {
34
- let ( src_archives, entries) = if let Some ( input) = input {
35
- let read_cache = ReadCache :: new ( File :: open ( input) . unwrap ( ) ) ;
36
- let archive = ArchiveFile :: parse ( & read_cache) . unwrap ( ) ;
37
- let mut entries = Vec :: new ( ) ;
38
-
39
- for entry in archive. members ( ) {
40
- let entry = entry. unwrap ( ) ;
41
- entries. push ( (
42
- entry. name ( ) . to_vec ( ) ,
43
- ArchiveEntry :: FromArchive { archive_index : 0 , file_range : entry. file_range ( ) } ,
44
- ) ) ;
45
- }
46
-
47
- ( vec ! [ read_cache. into_inner( ) ] , entries)
48
- } else {
49
- ( vec ! [ ] , Vec :: new ( ) )
50
- } ;
51
-
33
+ fn new ( sess : & ' a Session , output : & Path ) -> Self {
52
34
ArArchiveBuilder {
53
35
sess,
54
36
dst : output. to_path_buf ( ) ,
55
37
use_gnu_style_archive : sess. target . archive_format == "gnu" ,
56
38
// FIXME fix builtin ranlib on macOS
57
39
no_builtin_ranlib : sess. target . is_like_osx ,
58
40
59
- src_archives,
60
- entries,
41
+ src_archives : vec ! [ ] ,
42
+ entries : vec ! [ ] ,
61
43
}
62
44
}
63
45
64
- fn src_files ( & mut self ) -> Vec < String > {
65
- self . entries . iter ( ) . map ( |( name, _) | String :: from_utf8 ( name. clone ( ) ) . unwrap ( ) ) . collect ( )
66
- }
67
-
68
- fn remove_file ( & mut self , name : & str ) {
69
- let index = self
70
- . entries
71
- . iter ( )
72
- . position ( |( entry_name, _) | entry_name == name. as_bytes ( ) )
73
- . expect ( "Tried to remove file not existing in src archive" ) ;
74
- self . entries . remove ( index) ;
75
- }
76
-
77
46
fn add_file ( & mut self , file : & Path ) {
78
47
self . entries . push ( (
79
48
file. file_name ( ) . unwrap ( ) . to_str ( ) . unwrap ( ) . to_string ( ) . into_bytes ( ) ,
@@ -105,7 +74,7 @@ impl<'a> ArchiveBuilder<'a> for ArArchiveBuilder<'a> {
105
74
Ok ( ( ) )
106
75
}
107
76
108
- fn build ( mut self ) {
77
+ fn build ( mut self ) -> bool {
109
78
enum BuilderKind {
110
79
Bsd ( ar:: Builder < File > ) ,
111
80
Gnu ( ar:: GnuBuilder < File > ) ,
@@ -204,6 +173,8 @@ impl<'a> ArchiveBuilder<'a> for ArArchiveBuilder<'a> {
204
173
)
205
174
} ;
206
175
176
+ let any_members = !entries. is_empty ( ) ;
177
+
207
178
// Add all files
208
179
for ( entry_name, data) in entries. into_iter ( ) {
209
180
let header = ar:: Header :: new ( entry_name, data. len ( ) as u64 ) ;
@@ -229,6 +200,8 @@ impl<'a> ArchiveBuilder<'a> for ArArchiveBuilder<'a> {
229
200
self . sess . fatal ( & format ! ( "Ranlib exited with code {:?}" , status. code( ) ) ) ;
230
201
}
231
202
}
203
+
204
+ any_members
232
205
}
233
206
234
207
fn inject_dll_import_lib (
0 commit comments