1
1
use gen_target_info:: { get_target_specs_from_json, write_target_tuple_mapping, RustcTargetSpecs } ;
2
- use std:: { fs:: File , io:: Write as _} ;
2
+ use std:: { collections :: BTreeMap , fs:: File , io:: Write as _} ;
3
3
4
4
const PRELUDE : & str = r#"//! This file is generated code. Please edit the generator
5
5
//! in dev-tools/gen-target-info if you need to make changes.
6
6
7
7
"# ;
8
8
9
9
fn generate_riscv_arch_mapping ( f : & mut File , target_specs : & RustcTargetSpecs ) {
10
- let mut riscv_target_mapping = target_specs
10
+ let riscv_target_mapping = target_specs
11
11
. 0
12
12
. iter ( )
13
13
. filter_map ( |( target, target_spec) | {
14
14
let arch = target. split_once ( '-' ) . unwrap ( ) . 0 ;
15
15
( arch. contains ( "riscv" ) && arch != target_spec. arch )
16
16
. then_some ( ( arch, & * target_spec. arch ) )
17
17
} )
18
- . collect :: < Vec < _ > > ( ) ;
19
- riscv_target_mapping. sort_unstable_by_key ( |( arch, _) | & * * arch) ;
20
- riscv_target_mapping. dedup ( ) ;
18
+ . collect :: < BTreeMap < _ , _ > > ( ) ;
21
19
write_target_tuple_mapping ( f, "RISCV_ARCH_MAPPING" , & riscv_target_mapping) ;
22
20
}
23
21
24
22
fn generate_windows_triple_mapping ( f : & mut File , target_specs : & RustcTargetSpecs ) {
25
- let mut windows_target_mapping = target_specs
23
+ let windows_target_mapping = target_specs
26
24
. 0
27
25
. iter ( )
28
26
. filter_map ( |( target, target_spec) | {
@@ -31,9 +29,7 @@ fn generate_windows_triple_mapping(f: &mut File, target_specs: &RustcTargetSpecs
31
29
( os. contains ( "windows" ) && target != & * target_spec. llvm_target )
32
30
. then_some ( ( & * * target, & * target_spec. llvm_target ) )
33
31
} )
34
- . collect :: < Vec < _ > > ( ) ;
35
- windows_target_mapping. sort_unstable_by_key ( |( triple, _) | & * * triple) ;
36
- windows_target_mapping. dedup ( ) ;
32
+ . collect :: < BTreeMap < _ , _ > > ( ) ;
37
33
write_target_tuple_mapping ( f, "WINDOWS_TRIPLE_MAPPING" , & windows_target_mapping) ;
38
34
}
39
35
0 commit comments