@@ -32,7 +32,7 @@ pub struct ArArchiveBuilder<'a> {
3232}
3333
3434impl < ' 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 {
3636 let config = ArchiveConfig {
3737 sess,
3838 dst : output. to_path_buf ( ) ,
@@ -41,48 +41,13 @@ impl<'a> ArchiveBuilder<'a> for ArArchiveBuilder<'a> {
4141 use_gnu_style_archive : sess. target . options . archive_format == "gnu" ,
4242 } ;
4343
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-
6644 ArArchiveBuilder {
6745 config,
68- src_archives,
69- entries,
46+ src_archives : vec ! [ ] ,
47+ entries : vec ! [ ] ,
7048 }
7149 }
7250
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-
8651 fn add_file ( & mut self , file : & Path ) {
8752 self . entries . push ( (
8853 file. file_name ( ) . unwrap ( ) . to_str ( ) . unwrap ( ) . to_string ( ) ,
@@ -113,7 +78,7 @@ impl<'a> ArchiveBuilder<'a> for ArArchiveBuilder<'a> {
11378 Ok ( ( ) )
11479 }
11580
116- fn build ( mut self ) {
81+ fn build ( mut self ) -> bool {
11782 use std:: process:: Command ;
11883
11984 fn add_file_using_ar ( archive : & Path , file : & Path ) {
@@ -146,6 +111,8 @@ impl<'a> ArchiveBuilder<'a> for ArArchiveBuilder<'a> {
146111 BuilderKind :: Bsd ( ar:: Builder :: new ( File :: create ( & self . config . dst ) . unwrap ( ) ) )
147112 } ;
148113
114+ let any_members = !self . entries . is_empty ( ) ;
115+
149116 // Add all files
150117 for ( entry_name, entry) in self . entries . into_iter ( ) {
151118 match entry {
@@ -206,6 +173,8 @@ impl<'a> ArchiveBuilder<'a> for ArArchiveBuilder<'a> {
206173 if !status. success ( ) {
207174 self . config . sess . fatal ( & format ! ( "Ranlib exited with code {:?}" , status. code( ) ) ) ;
208175 }
176+
177+ any_members
209178 }
210179
211180 fn inject_dll_import_lib ( & mut self , _lib_name : & str , _dll_imports : & [ DllImport ] , _tmpdir : & MaybeTempDir ) {
0 commit comments