11#![ recursion_limit = "128" ]
22
33use log:: { debug, error, info, warn} ;
4+ #[ cfg( feature = "unstable-riscv" ) ]
5+ use svd2rust:: config:: RiscvConfig ;
46use svd2rust:: config:: { IdentFormatError , IdentFormats , IdentFormatsTheme } ;
57use svd2rust:: util:: IdentFormat ;
68
@@ -18,6 +20,8 @@ use svd2rust::{
1820} ;
1921
2022fn parse_configs ( app : Command ) -> Result < Config > {
23+ #[ cfg( feature = "unstable-riscv" ) ]
24+ use irx_config:: parsers:: yaml;
2125 use irx_config:: parsers:: { cmd, toml} ;
2226 use irx_config:: ConfigBuilder ;
2327 let ident_formats = app. clone ( ) . get_matches ( ) ;
@@ -29,10 +33,24 @@ fn parse_configs(app: Command) -> Result<Config> {
2933 . path_option ( "config" )
3034 . ignore_missing_file ( true )
3135 . 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 ( ) ?;
3446
3547 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+
3654 let mut idf = match config. ident_formats_theme {
3755 Some ( IdentFormatsTheme :: Legacy ) => IdentFormats :: legacy_theme ( ) ,
3856 _ => IdentFormats :: default_theme ( ) ,
@@ -290,6 +308,15 @@ Ignore this option if you are not building your own FPGA based soft-cores."),
290308 env!( "CARGO_PKG_VERSION" ) ,
291309 include_str!( concat!( env!( "OUT_DIR" ) , "/commit-info.txt" ) )
292310 ) ) ;
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+ ) ;
293320
294321 let mut config = match parse_configs ( app) {
295322 Ok ( config) => {
0 commit comments