@@ -5,7 +5,7 @@ use std::fs::File;
5
5
use std:: io:: { self , Read , Seek } ;
6
6
use std:: path:: { Path , PathBuf } ;
7
7
8
- use rustc_codegen_ssa:: back:: archive:: ArchiveBuilder ;
8
+ use rustc_codegen_ssa:: back:: archive:: { ArchiveBuilder , ArchiveBuilderBuilder } ;
9
9
use rustc_session:: Session ;
10
10
11
11
use object:: read:: archive:: ArchiveFile ;
@@ -17,6 +17,32 @@ enum ArchiveEntry {
17
17
File ( PathBuf ) ,
18
18
}
19
19
20
+ pub ( crate ) struct ArArchiveBuilderBuilder ;
21
+
22
+ impl ArchiveBuilderBuilder for ArArchiveBuilderBuilder {
23
+ fn new_archive_builder < ' a > ( & self , sess : & ' a Session ) -> Box < dyn ArchiveBuilder < ' a > + ' a > {
24
+ Box :: new ( ArArchiveBuilder {
25
+ sess,
26
+ use_gnu_style_archive : sess. target . archive_format == "gnu" ,
27
+ // FIXME fix builtin ranlib on macOS
28
+ no_builtin_ranlib : sess. target . is_like_osx ,
29
+
30
+ src_archives : vec ! [ ] ,
31
+ entries : vec ! [ ] ,
32
+ } )
33
+ }
34
+
35
+ fn create_dll_import_lib (
36
+ & self ,
37
+ _sess : & Session ,
38
+ _lib_name : & str ,
39
+ _dll_imports : & [ rustc_session:: cstore:: DllImport ] ,
40
+ _tmpdir : & Path ,
41
+ ) -> PathBuf {
42
+ bug ! ( "creating dll imports is not supported" ) ;
43
+ }
44
+ }
45
+
20
46
pub ( crate ) struct ArArchiveBuilder < ' a > {
21
47
sess : & ' a Session ,
22
48
use_gnu_style_archive : bool ,
@@ -29,29 +55,18 @@ pub(crate) struct ArArchiveBuilder<'a> {
29
55
}
30
56
31
57
impl < ' a > ArchiveBuilder < ' a > for ArArchiveBuilder < ' a > {
32
- fn new ( sess : & ' a Session ) -> Self {
33
- ArArchiveBuilder {
34
- sess,
35
- use_gnu_style_archive : sess. target . archive_format == "gnu" ,
36
- // FIXME fix builtin ranlib on macOS
37
- no_builtin_ranlib : sess. target . is_like_osx ,
38
-
39
- src_archives : vec ! [ ] ,
40
- entries : vec ! [ ] ,
41
- }
42
- }
43
-
44
58
fn add_file ( & mut self , file : & Path ) {
45
59
self . entries . push ( (
46
60
file. file_name ( ) . unwrap ( ) . to_str ( ) . unwrap ( ) . to_string ( ) . into_bytes ( ) ,
47
61
ArchiveEntry :: File ( file. to_owned ( ) ) ,
48
62
) ) ;
49
63
}
50
64
51
- fn add_archive < F > ( & mut self , archive_path : & Path , mut skip : F ) -> std:: io:: Result < ( ) >
52
- where
53
- F : FnMut ( & str ) -> bool + ' static ,
54
- {
65
+ fn add_archive (
66
+ & mut self ,
67
+ archive_path : & Path ,
68
+ mut skip : Box < dyn FnMut ( & str ) -> bool + ' static > ,
69
+ ) -> std:: io:: Result < ( ) > {
55
70
let read_cache = ReadCache :: new ( std:: fs:: File :: open ( & archive_path) ?) ;
56
71
let archive = ArchiveFile :: parse ( & read_cache) . unwrap ( ) ;
57
72
let archive_index = self . src_archives . len ( ) ;
@@ -72,7 +87,7 @@ impl<'a> ArchiveBuilder<'a> for ArArchiveBuilder<'a> {
72
87
Ok ( ( ) )
73
88
}
74
89
75
- fn build ( mut self , output : & Path ) -> bool {
90
+ fn build ( mut self : Box < Self > , output : & Path ) -> bool {
76
91
enum BuilderKind {
77
92
Bsd ( ar:: Builder < File > ) ,
78
93
Gnu ( ar:: GnuBuilder < File > ) ,
@@ -218,13 +233,4 @@ impl<'a> ArchiveBuilder<'a> for ArArchiveBuilder<'a> {
218
233
219
234
any_members
220
235
}
221
-
222
- fn create_dll_import_lib (
223
- _sess : & Session ,
224
- _lib_name : & str ,
225
- _dll_imports : & [ rustc_session:: cstore:: DllImport ] ,
226
- _tmpdir : & Path ,
227
- ) -> PathBuf {
228
- bug ! ( "creating dll imports is not supported" ) ;
229
- }
230
236
}
0 commit comments