Skip to content

Commit c6fbca1

Browse files
authored
Merge pull request #771 from rust-embedded/flags
dash in flags
2 parents 10ea58b + 5aafd70 commit c6fbca1

File tree

5 files changed

+52
-21
lines changed

5 files changed

+52
-21
lines changed

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ jobs:
7575
- { rust: stable, vendor: Spansion, options: "--atomics" }
7676
- { rust: stable, vendor: STMicro, options: "" }
7777
- { rust: stable, vendor: STMicro, options: "--atomics" }
78-
- { rust: stable, vendor: STM32-patched, options: "--strict --pascal_enum_values --max_cluster_size --atomics --atomics_feature atomics --impl_debug --impl-defmt defmt" }
78+
- { rust: stable, vendor: STM32-patched, options: "--strict --pascal-enum-values --max-cluster-size --atomics --atomics-feature atomics --impl-debug --impl-defmt defmt" }
7979
- { rust: stable, vendor: Toshiba, options: all }
8080
- { rust: stable, vendor: Toshiba, options: "" }
8181
# Test MSRV

CHANGELOG.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/).
99

1010
- Use methods to access any register or cluster
1111
- Remove all deny lints from generated crate
12-
- Add `reexport_core_peripherals` and `reexport_interrupt` features disabled by default
12+
- Add `reexport-core-peripherals` and `reexport-interrupt` features disabled by default
1313
- ~~rename `const-generic` feature to `array_proxy`~~ remove `ArrayProxy`
1414
- `FieldWriter` takes offset as struct field instead of const generic.
1515
Improves SVD field array access
@@ -18,6 +18,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/).
1818
- Support of default value for `EnumeratedValues`
1919
- move `Config` to `config` module
2020
- add `impl-defmt` config flag
21+
- Use dash instead of underscore in flag names
2122

2223
## [v0.30.3] - 2023-11-19
2324

ci/script.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ test_svd_for_target() {
1313

1414
# NOTE we care about errors in svd2rust, but not about errors / warnings in rustfmt
1515
pushd $td
16-
RUST_BACKTRACE=1 svd2rust $options --target $1 --source_type xml -i input.svd
16+
RUST_BACKTRACE=1 svd2rust $options --target $1 --source-type xml -i input.svd
1717

1818
mv lib.rs src/lib.rs
1919

src/lib.rs

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,11 @@
7777
//! rt = ["cortex-m-rt/device"]
7878
//! ```
7979
//!
80+
//! ## the `--reexport-core-peripherals` flag
81+
//!
82+
//! With `--reexport-core-peripherals` flag enabled peripherals from `cortex-m` crate
83+
//! be reexported by peripheral access crate.
84+
//!
8085
//! ## target = msp430
8186
//!
8287
//! MSP430 does not natively use the SVD format. However, SVD files can be generated using the
@@ -341,7 +346,7 @@
341346
//! Usage looks like this:
342347
//!
343348
//! ```ignore
344-
//! if i2c1.c2r().write().reset()
349+
//! if i2c1.c2r().reset()
345350
//! ```
346351
//!
347352
//! ## `write`
@@ -495,6 +500,11 @@
495500
//!
496501
//! [`interrupt`]: https://docs.rs/cortex-m-rt-macros/0.1/cortex_m_rt_macros/attr.interrupt.html
497502
//!
503+
//! ## the `--reexport-interrupt` flag (deprecated)
504+
//!
505+
//! With `--reexport-interrupt` flag passed `interrupt` macro from `cortex-m-rt` or `riscv-rt`
506+
//! be reexported by peripheral access crate.
507+
//!
498508
//! ## the `--atomics` flag
499509
//!
500510
//! The `--atomics` flag can be passed to `svd2rust` to extends the register API with operations to
@@ -503,21 +513,21 @@
503513
//! concurrently called on different bits in the same register without data races. This flag won't
504514
//! work for RISCV chips without the atomic extension.
505515
//!
506-
//! The `--atomics_feature` flag can also be specified to include atomics implementations conditionally
516+
//! The `--atomics-feature` flag can also be specified to include atomics implementations conditionally
507517
//! behind the supplied feature name.
508518
//!
509519
//! `portable-atomic` v0.3.16 must be added to the dependencies, with default features off to
510520
//! disable the `fallback` feature.
511521
//!
512-
//! ## the `--impl_debug` flag
522+
//! ## the `--impl-debug` flag
513523
//!
514524
//! The `--impl_debug` option will cause svd2rust to generate `core::fmt::Debug` implementations for
515525
//! all registers and blocks. If a register is readable and has fields defined then each field value
516526
//! will be printed - if no fields are defined then the value of the register will be printed. Any
517527
//! register that has read actions will not be read and printed as `(not read/has read action!)`.
518528
//! Registers that are not readable will have `(write only register)` printed as the value.
519529
//!
520-
//! The `--impl_debug_feature` flag can also be specified to include debug implementations conditionally
530+
//! The `--impl-debug-feature` flag can also be specified to include debug implementations conditionally
521531
//! behind the supplied feature name.
522532
//!
523533
//! Usage examples:
@@ -533,6 +543,11 @@
533543
//! // print all registers for peripheral
534544
//! println!("RTC_CNT {:#?}", unsafe { &*esp32s3::RTC_CNTL::ptr() });
535545
//! ```
546+
//!
547+
//! ## the `--impl-defmt` flag
548+
//!
549+
//! The `--impl-defmt` flag can also be specified to include `defmt::Format` implementations conditionally
550+
//! behind the supplied feature name.
536551
#![recursion_limit = "128"]
537552

538553
use quote::quote;

src/main.rs

Lines changed: 29 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ fn run() -> Result<()> {
4747
.arg(
4848
Arg::new("output_dir")
4949
.long("output-dir")
50+
.alias("output_dir")
5051
.help("Directory to place generated files")
5152
.short('o')
5253
.action(ArgAction::Set)
@@ -75,58 +76,67 @@ fn run() -> Result<()> {
7576
)
7677
.arg(
7778
Arg::new("atomics_feature")
78-
.long("atomics_feature")
79+
.long("atomics-feature")
80+
.alias("atomics_feature")
7981
.help("add feature gating for atomic register modification API")
8082
.action(ArgAction::Set)
8183
.value_name("FEATURE"),
8284
)
8385
.arg(
8486
Arg::new("ignore_groups")
85-
.long("ignore_groups")
87+
.long("ignore-groups")
88+
.alias("ignore_groups")
8689
.action(ArgAction::SetTrue)
8790
.help("Don't add alternateGroup name as prefix to register name"),
8891
)
8992
.arg(
9093
Arg::new("keep_list")
91-
.long("keep_list")
94+
.long("keep-list")
95+
.alias("keep_list")
9296
.action(ArgAction::SetTrue)
9397
.help(
9498
"Keep lists when generating code of dimElement, instead of trying to generate arrays",
9599
))
96100
.arg(
97101
Arg::new("generic_mod")
98-
.long("generic_mod")
102+
.long("generic-mod")
103+
.alias("generic_mod")
99104
.short('g')
100105
.action(ArgAction::SetTrue)
101106
.help("Push generic mod in separate file"),
102107
)
103108
.arg(
104109
Arg::new("feature_group")
105-
.long("feature_group")
110+
.long("feature-group")
111+
.alias("feature_group")
106112
.action(ArgAction::SetTrue)
107113
.help("Use group_name of peripherals as feature"),
108114
)
109115
.arg(
110116
Arg::new("feature_peripheral")
111-
.long("feature_peripheral")
117+
.long("feature-peripheral")
118+
.alias("feature_peripheral")
112119
.action(ArgAction::SetTrue)
113120
.help("Use independent cfg feature flags for each peripheral"),
114121
)
115122
.arg(
116123
Arg::new("max_cluster_size")
117-
.long("max_cluster_size")
124+
.long("max-cluster-size")
125+
.alias("max_cluster_size")
118126
.action(ArgAction::SetTrue)
119127
.help("Use array increment for cluster size"),
120128
)
121129
.arg(
122130
Arg::new("impl_debug")
123-
.long("impl_debug")
131+
.long("impl-debug")
132+
.alias("impl_debug")
124133
.action(ArgAction::SetTrue)
125134
.help("implement Debug for readable blocks and registers"),
126135
)
127136
.arg(
128137
Arg::new("impl_debug_feature")
129-
.long("impl_debug_feature")
138+
.long("impl-debug-feature")
139+
.alias("impl_debug_feature")
130140
.help("Add feature gating for block and register debug implementation")
131141
.action(ArgAction::Set)
132142
.value_name("FEATURE"),
@@ -141,7 +151,8 @@ fn run() -> Result<()> {
141151
)
142152
.arg(
143153
Arg::new("make_mod")
144-
.long("make_mod")
154+
.long("make-mod")
155+
.alias("make_mod")
145156
.short('m')
146157
.action(ArgAction::SetTrue)
147158
.help("Create mod.rs instead of lib.rs, without inner attributes"),
@@ -155,24 +166,28 @@ fn run() -> Result<()> {
155166
)
156167
.arg(
157168
Arg::new("pascal_enum_values")
158-
.long("pascal_enum_values")
169+
.long("pascal-enum-values")
170+
.alias("pascal_enum_values")
159171
.action(ArgAction::SetTrue)
160172
.help("Use PascalCase in stead of UPPER_CASE for enumerated values"),
161173
)
162174
.arg(
163175
Arg::new("source_type")
164-
.long("source_type")
176+
.long("source-type")
177+
.alias("source_type")
165178
.help("Specify file/stream format"),
166179
)
167180
.arg(
168181
Arg::new("reexport_core_peripherals")
169-
.long("reexport_core_peripherals")
182+
.long("reexport-core-peripherals")
183+
.alias("reexport_core_peripherals")
170184
.action(ArgAction::SetTrue)
171185
.help("For Cortex-M target reexport peripherals from cortex-m crate"),
172186
)
173187
.arg(
174188
Arg::new("reexport_interrupt")
175-
.long("reexport_interrupt")
189+
.long("reexport-interrupt")
190+
.alias("reexport_interrupt")
176191
.action(ArgAction::SetTrue)
177192
.help("Reexport interrupt macro from cortex-m-rt like crates"),
178193
)

0 commit comments

Comments
 (0)