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