@@ -19,91 +19,95 @@ fn run() -> Result<()> {
1919 use clap_conf:: prelude:: * ;
2020 use std:: io:: Read ;
2121
22- let matches =
23- App :: new ( "svd2rust ")
24- . about ( "Generate a Rust API from SVD files" )
25- . arg (
26- Arg :: with_name ( "input ")
27- . help ( "Input SVD file ")
28- . short ( "i" )
29- . takes_value ( true )
30- . value_name ( "FILE" ) ,
31- )
32- . arg (
33- Arg :: with_name ( "output" )
34- . long ( "output-dir ")
35- . help ( "Directory to place generated files ")
36- . short ( "o" )
37- . takes_value ( true )
38- . value_name ( "PATH" ) ,
39- )
40- . arg (
41- Arg :: with_name ( "config" )
42- . long ( "config ")
43- . help ( "Config TOML file ")
44- . short ( "c" )
45- . takes_value ( true )
46- . value_name ( "TOML_FILE" ) ,
47- )
48- . arg (
49- Arg :: with_name ( "target" )
50- . long ( "target ")
51- . help ( "Target architecture" )
52- . takes_value ( true )
53- . value_name ( "ARCH" ) ,
54- )
55- . arg (
56- Arg :: with_name ( "nightly_features ")
57- . long ( " nightly" )
58- . help ( "Enable features only available to nightly rustc" ) ,
59- )
60- . arg ( Arg :: with_name ( "const_generic" ) . long ( "const_generic" ) . help (
22+ let matches = App :: new ( "svd2rust" )
23+ . about ( "Generate a Rust API from SVD files ")
24+ . arg (
25+ Arg :: with_name ( "input" )
26+ . help ( "Input SVD file ")
27+ . short ( "i ")
28+ . takes_value ( true )
29+ . value_name ( "FILE" ) ,
30+ )
31+ . arg (
32+ Arg :: with_name ( "output" )
33+ . long ( "output-dir " )
34+ . help ( "Directory to place generated files ")
35+ . short ( "o ")
36+ . takes_value ( true )
37+ . value_name ( "PATH" ) ,
38+ )
39+ . arg (
40+ Arg :: with_name ( "config" )
41+ . long ( "config" )
42+ . help ( "Config TOML file ")
43+ . short ( "c ")
44+ . takes_value ( true )
45+ . value_name ( "TOML_FILE" ) ,
46+ )
47+ . arg (
48+ Arg :: with_name ( "target" )
49+ . long ( "target" )
50+ . help ( "Target architecture ")
51+ . takes_value ( true )
52+ . value_name ( "ARCH" ) ,
53+ )
54+ . arg (
55+ Arg :: with_name ( "nightly_features" )
56+ . long ( "nightly ")
57+ . help ( "Enable features only available to nightly rustc" ) ,
58+ )
59+ . arg (
60+ Arg :: with_name ( "const_generic" ) . long ( "const_generic" ) . help (
6161 "Use const generics to generate writers for same fields with different offsets" ,
62- ) )
63- . arg (
64- Arg :: with_name ( "ignore_groups" )
65- . long ( "ignore_groups" )
66- . help ( "Don't add alternateGroup name as prefix to register name" ) ,
67- )
68- . arg (
69- Arg :: with_name ( "generic_mod" )
70- . long ( "generic_mod" )
71- . short ( "g" )
72- . help ( "Push generic mod in separate file" ) ,
73- )
74- . arg (
75- Arg :: with_name ( "make_mod" )
76- . long ( "make_mod" )
77- . short ( "m" )
78- . help ( "Create mod.rs instead of lib.rs, without inner attributes" ) ,
79- )
80- . arg (
81- Arg :: with_name ( "strict" )
82- . long ( "strict" )
83- . short ( "s" )
84- . help ( "Make advanced checks due to parsing SVD" ) ,
85- )
86- . arg (
87- Arg :: with_name ( "source_type" )
88- . long ( "source_type" )
89- . help ( "Specify file/stream format" ) ,
90- )
91- . arg (
92- Arg :: with_name ( "log_level" )
93- . long ( "log" )
94- . short ( "l" )
95- . help ( & format ! (
96- "Choose which messages to log (overrides {})" ,
97- env_logger:: DEFAULT_FILTER_ENV
98- ) )
99- . takes_value ( true )
100- . possible_values ( & [ "off" , "error" , "warn" , "info" , "debug" , "trace" ] ) ,
101- )
102- . version ( concat ! (
103- env!( "CARGO_PKG_VERSION" ) ,
104- include_str!( concat!( env!( "OUT_DIR" ) , "/commit-info.txt" ) )
105- ) )
106- . get_matches ( ) ;
62+ ) ,
63+ )
64+ . arg (
65+ Arg :: with_name ( "ignore_groups" )
66+ . long ( "ignore_groups" )
67+ . help ( "Don't add alternateGroup name as prefix to register name" ) ,
68+ )
69+ . arg ( Arg :: with_name ( "keep_list" ) . long ( "keep_list" ) . help (
70+ "Keep lists when generating code of dimElement, instead of trying to generate arrays" ,
71+ ) )
72+ . arg (
73+ Arg :: with_name ( "generic_mod" )
74+ . long ( "generic_mod" )
75+ . short ( "g" )
76+ . help ( "Push generic mod in separate file" ) ,
77+ )
78+ . arg (
79+ Arg :: with_name ( "make_mod" )
80+ . long ( "make_mod" )
81+ . short ( "m" )
82+ . help ( "Create mod.rs instead of lib.rs, without inner attributes" ) ,
83+ )
84+ . arg (
85+ Arg :: with_name ( "strict" )
86+ . long ( "strict" )
87+ . short ( "s" )
88+ . help ( "Make advanced checks due to parsing SVD" ) ,
89+ )
90+ . arg (
91+ Arg :: with_name ( "source_type" )
92+ . long ( "source_type" )
93+ . help ( "Specify file/stream format" ) ,
94+ )
95+ . arg (
96+ Arg :: with_name ( "log_level" )
97+ . long ( "log" )
98+ . short ( "l" )
99+ . help ( & format ! (
100+ "Choose which messages to log (overrides {})" ,
101+ env_logger:: DEFAULT_FILTER_ENV
102+ ) )
103+ . takes_value ( true )
104+ . possible_values ( & [ "off" , "error" , "warn" , "info" , "debug" , "trace" ] ) ,
105+ )
106+ . version ( concat ! (
107+ env!( "CARGO_PKG_VERSION" ) ,
108+ include_str!( concat!( env!( "OUT_DIR" ) , "/commit-info.txt" ) )
109+ ) )
110+ . get_matches ( ) ;
107111
108112 let input = & mut String :: new ( ) ;
109113 match matches. value_of ( "input" ) {
@@ -148,6 +152,8 @@ fn run() -> Result<()> {
148152 cfg. bool_flag ( "const_generic" , Filter :: Arg ) || cfg. bool_flag ( "const_generic" , Filter :: Conf ) ;
149153 let ignore_groups =
150154 cfg. bool_flag ( "ignore_groups" , Filter :: Arg ) || cfg. bool_flag ( "ignore_groups" , Filter :: Conf ) ;
155+ let keep_list =
156+ cfg. bool_flag ( "keep_list" , Filter :: Arg ) || cfg. bool_flag ( "keep_list" , Filter :: Conf ) ;
151157 let strict = cfg. bool_flag ( "strict" , Filter :: Arg ) || cfg. bool_flag ( "strict" , Filter :: Conf ) ;
152158
153159 let mut source_type = cfg
@@ -169,6 +175,7 @@ fn run() -> Result<()> {
169175 make_mod,
170176 const_generic,
171177 ignore_groups,
178+ keep_list,
172179 strict,
173180 output_dir : path. clone ( ) ,
174181 source_type,
0 commit comments