1
1
#![ recursion_limit = "128" ]
2
2
3
3
use log:: { debug, error, info, warn} ;
4
+ #[ cfg( feature = "unstable-riscv" ) ]
5
+ use svd2rust:: config:: RiscvConfig ;
4
6
use svd2rust:: config:: { IdentFormatError , IdentFormats , IdentFormatsTheme } ;
5
7
use svd2rust:: util:: IdentFormat ;
6
8
@@ -18,6 +20,8 @@ use svd2rust::{
18
20
} ;
19
21
20
22
fn parse_configs ( app : Command ) -> Result < Config > {
23
+ #[ cfg( feature = "unstable-riscv" ) ]
24
+ use irx_config:: parsers:: yaml;
21
25
use irx_config:: parsers:: { cmd, toml} ;
22
26
use irx_config:: ConfigBuilder ;
23
27
let ident_formats = app. clone ( ) . get_matches ( ) ;
@@ -29,10 +33,24 @@ fn parse_configs(app: Command) -> Result<Config> {
29
33
. path_option ( "config" )
30
34
. ignore_missing_file ( true )
31
35
. build ( ) ?,
32
- )
33
- . load ( ) ?;
36
+ ) ;
37
+ #[ cfg( feature = "unstable-riscv" ) ]
38
+ let irxconfig = irxconfig. append_parser (
39
+ yaml:: ParserBuilder :: default ( )
40
+ . default_path ( "riscv.yaml" )
41
+ . path_option ( "riscv_cfg" )
42
+ . ignore_missing_file ( true )
43
+ . build ( ) ?,
44
+ ) ;
45
+ let irxconfig = irxconfig. load ( ) ?;
34
46
35
47
let mut config: Config = irxconfig. get ( ) ?;
48
+
49
+ #[ cfg( feature = "unstable-riscv" ) ]
50
+ if let Ok ( riscv_config) = irxconfig. get :: < RiscvConfig > ( ) {
51
+ config. riscv_config = Some ( riscv_config) ;
52
+ }
53
+
36
54
let mut idf = match config. ident_formats_theme {
37
55
Some ( IdentFormatsTheme :: Legacy ) => IdentFormats :: legacy_theme ( ) ,
38
56
_ => IdentFormats :: default_theme ( ) ,
@@ -290,6 +308,15 @@ Ignore this option if you are not building your own FPGA based soft-cores."),
290
308
env!( "CARGO_PKG_VERSION" ) ,
291
309
include_str!( concat!( env!( "OUT_DIR" ) , "/commit-info.txt" ) )
292
310
) ) ;
311
+ #[ cfg( feature = "unstable-riscv" ) ]
312
+ let app = app. arg (
313
+ Arg :: new ( "riscv_cfg" )
314
+ . long ( "riscv_config" )
315
+ . help ( "RISC-V Config YAML file" )
316
+ . short ( 'r' )
317
+ . action ( ArgAction :: Set )
318
+ . value_name ( "YAML_FILE" ) ,
319
+ ) ;
293
320
294
321
let mut config = match parse_configs ( app) {
295
322
Ok ( config) => {
0 commit comments