1
1
use std:: fs:: File ;
2
2
use std:: path:: { Path , PathBuf } ;
3
3
4
- use rustc_codegen_ssa:: back:: archive:: ArchiveBuilder ;
4
+ use rustc_codegen_ssa:: back:: archive:: { ArchiveBuilder , ArchiveBuilderBuilder } ;
5
5
use rustc_session:: Session ;
6
6
7
7
use rustc_session:: cstore:: DllImport ;
@@ -21,41 +21,56 @@ enum ArchiveEntry {
21
21
File ( PathBuf ) ,
22
22
}
23
23
24
- pub struct ArArchiveBuilder < ' a > {
25
- config : ArchiveConfig < ' a > ,
26
- src_archives : Vec < ( PathBuf , ar:: Archive < File > ) > ,
27
- // Don't use `HashMap` here, as the order is important. `rust.metadata.bin` must always be at
28
- // the end of an archive for linkers to not get confused.
29
- entries : Vec < ( String , ArchiveEntry ) > ,
30
- }
24
+ pub struct ArArchiveBuilderBuilder ;
31
25
32
- impl < ' a > ArchiveBuilder < ' a > for ArArchiveBuilder < ' a > {
33
- fn new ( sess : & ' a Session ) -> Self {
26
+ impl ArchiveBuilderBuilder for ArArchiveBuilderBuilder {
27
+ fn new_archive_builder < ' a > ( & self , sess : & ' a Session ) -> Box < dyn ArchiveBuilder < ' a > + ' a > {
34
28
let config = ArchiveConfig {
35
29
sess,
36
30
use_native_ar : false ,
37
31
// FIXME test for linux and System V derivatives instead
38
32
use_gnu_style_archive : sess. target . options . archive_format == "gnu" ,
39
33
} ;
40
34
41
- ArArchiveBuilder {
35
+ Box :: new ( ArArchiveBuilder {
42
36
config,
43
37
src_archives : vec ! [ ] ,
44
38
entries : vec ! [ ] ,
45
- }
39
+ } )
46
40
}
47
41
42
+ fn create_dll_import_lib (
43
+ & self ,
44
+ _sess : & Session ,
45
+ _lib_name : & str ,
46
+ _dll_imports : & [ DllImport ] ,
47
+ _tmpdir : & Path ,
48
+ ) -> PathBuf {
49
+ unimplemented ! ( ) ;
50
+ }
51
+ }
52
+
53
+ pub struct ArArchiveBuilder < ' a > {
54
+ config : ArchiveConfig < ' a > ,
55
+ src_archives : Vec < ( PathBuf , ar:: Archive < File > ) > ,
56
+ // Don't use `HashMap` here, as the order is important. `rust.metadata.bin` must always be at
57
+ // the end of an archive for linkers to not get confused.
58
+ entries : Vec < ( String , ArchiveEntry ) > ,
59
+ }
60
+
61
+ impl < ' a > ArchiveBuilder < ' a > for ArArchiveBuilder < ' a > {
48
62
fn add_file ( & mut self , file : & Path ) {
49
63
self . entries . push ( (
50
64
file. file_name ( ) . unwrap ( ) . to_str ( ) . unwrap ( ) . to_string ( ) ,
51
65
ArchiveEntry :: File ( file. to_owned ( ) ) ,
52
66
) ) ;
53
67
}
54
68
55
- fn add_archive < F > ( & mut self , archive_path : & Path , mut skip : F ) -> std:: io:: Result < ( ) >
56
- where
57
- F : FnMut ( & str ) -> bool + ' static ,
58
- {
69
+ fn add_archive (
70
+ & mut self ,
71
+ archive_path : & Path ,
72
+ mut skip : Box < dyn FnMut ( & str ) -> bool + ' static > ,
73
+ ) -> std:: io:: Result < ( ) > {
59
74
let mut archive = ar:: Archive :: new ( std:: fs:: File :: open ( & archive_path) ?) ;
60
75
let archive_index = self . src_archives . len ( ) ;
61
76
@@ -75,7 +90,7 @@ impl<'a> ArchiveBuilder<'a> for ArArchiveBuilder<'a> {
75
90
Ok ( ( ) )
76
91
}
77
92
78
- fn build ( mut self , output : & Path ) -> bool {
93
+ fn build ( mut self : Box < Self > , output : & Path ) -> bool {
79
94
use std:: process:: Command ;
80
95
81
96
fn add_file_using_ar ( archive : & Path , file : & Path ) {
@@ -171,13 +186,4 @@ impl<'a> ArchiveBuilder<'a> for ArArchiveBuilder<'a> {
171
186
172
187
any_members
173
188
}
174
-
175
- fn create_dll_import_lib (
176
- _sess : & Session ,
177
- _lib_name : & str ,
178
- _dll_imports : & [ DllImport ] ,
179
- _tmpdir : & Path ,
180
- ) -> PathBuf {
181
- unimplemented ! ( ) ;
182
- }
183
189
}
0 commit comments