Skip to content

dash in flags #771

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Nov 23, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ jobs:
- { rust: stable, vendor: Spansion, options: "--atomics" }
- { rust: stable, vendor: STMicro, options: "" }
- { rust: stable, vendor: STMicro, options: "--atomics" }
- { rust: stable, vendor: STM32-patched, options: "--strict --pascal_enum_values --max_cluster_size --atomics --atomics_feature atomics --impl_debug --impl-defmt defmt" }
- { rust: stable, vendor: STM32-patched, options: "--strict --pascal-enum-values --max-cluster-size --atomics --atomics-feature atomics --impl-debug --impl-defmt defmt" }
- { rust: stable, vendor: Toshiba, options: all }
- { rust: stable, vendor: Toshiba, options: "" }
# Test MSRV
Expand Down
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/).
- Support of default value for `EnumeratedValues`
- move `Config` to `config` module
- add `impl-defmt` config flag
- Use dash instead of underscore in flag names

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

Expand Down
2 changes: 1 addition & 1 deletion ci/script.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ test_svd_for_target() {

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

mv lib.rs src/lib.rs

Expand Down
23 changes: 19 additions & 4 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,11 @@
//! rt = ["cortex-m-rt/device"]
//! ```
//!
//! ## the `--reexport-core-peripherals` flag
//!
//! With `--reexport-core-peripherals` flag enabled peripherals from `cortex-m` crate
//! be reexported by peripheral access crate.
//!
//! ## target = msp430
//!
//! MSP430 does not natively use the SVD format. However, SVD files can be generated using the
Expand Down Expand Up @@ -341,7 +346,7 @@
//! Usage looks like this:
//!
//! ```ignore
//! if i2c1.c2r().write().reset()
//! if i2c1.c2r().reset()
//! ```
//!
//! ## `write`
Expand Down Expand Up @@ -495,6 +500,11 @@
//!
//! [`interrupt`]: https://docs.rs/cortex-m-rt-macros/0.1/cortex_m_rt_macros/attr.interrupt.html
//!
//! ## the `--reexport-interrupt` flag (deprecated)
//!
//! With `--reexport-interrupt` flag passed `interrupt` macro from `cortex-m-rt` or `riscv-rt`
//! be reexported by peripheral access crate.
//!
//! ## the `--atomics` flag
//!
//! The `--atomics` flag can be passed to `svd2rust` to extends the register API with operations to
Expand All @@ -503,21 +513,21 @@
//! concurrently called on different bits in the same register without data races. This flag won't
//! work for RISCV chips without the atomic extension.
//!
//! The `--atomics_feature` flag can also be specified to include atomics implementations conditionally
//! The `--atomics-feature` flag can also be specified to include atomics implementations conditionally
//! behind the supplied feature name.
//!
//! `portable-atomic` v0.3.16 must be added to the dependencies, with default features off to
//! disable the `fallback` feature.
//!
//! ## the `--impl_debug` flag
//! ## the `--impl-debug` flag
//!
//! The `--impl_debug` option will cause svd2rust to generate `core::fmt::Debug` implementations for
//! all registers and blocks. If a register is readable and has fields defined then each field value
//! will be printed - if no fields are defined then the value of the register will be printed. Any
//! register that has read actions will not be read and printed as `(not read/has read action!)`.
//! Registers that are not readable will have `(write only register)` printed as the value.
//!
//! The `--impl_debug_feature` flag can also be specified to include debug implementations conditionally
//! The `--impl-debug-feature` flag can also be specified to include debug implementations conditionally
//! behind the supplied feature name.
//!
//! Usage examples:
Expand All @@ -533,6 +543,11 @@
//! // print all registers for peripheral
//! println!("RTC_CNT {:#?}", unsafe { &*esp32s3::RTC_CNTL::ptr() });
//! ```
//!
//! ## the `--impl-defmt` flag
//!
//! The `--impl-defmt` flag can also be specified to include `defmt::Format` implementations conditionally
//! behind the supplied feature name.
#![recursion_limit = "128"]

use quote::quote;
Expand Down
43 changes: 29 additions & 14 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ fn run() -> Result<()> {
.arg(
Arg::new("output_dir")
.long("output-dir")
.alias("output_dir")
.help("Directory to place generated files")
.short('o')
.action(ArgAction::Set)
Expand Down Expand Up @@ -75,58 +76,67 @@ fn run() -> Result<()> {
)
.arg(
Arg::new("atomics_feature")
.long("atomics_feature")
.long("atomics-feature")
.alias("atomics_feature")
.help("add feature gating for atomic register modification API")
.action(ArgAction::Set)
.value_name("FEATURE"),
)
.arg(
Arg::new("ignore_groups")
.long("ignore_groups")
.long("ignore-groups")
.alias("ignore_groups")
.action(ArgAction::SetTrue)
.help("Don't add alternateGroup name as prefix to register name"),
)
.arg(
Arg::new("keep_list")
.long("keep_list")
.long("keep-list")
.alias("keep_list")
.action(ArgAction::SetTrue)
.help(
"Keep lists when generating code of dimElement, instead of trying to generate arrays",
))
.arg(
Arg::new("generic_mod")
.long("generic_mod")
.long("generic-mod")
.alias("generic_mod")
.short('g')
.action(ArgAction::SetTrue)
.help("Push generic mod in separate file"),
)
.arg(
Arg::new("feature_group")
.long("feature_group")
.long("feature-group")
.alias("feature_group")
.action(ArgAction::SetTrue)
.help("Use group_name of peripherals as feature"),
)
.arg(
Arg::new("feature_peripheral")
.long("feature_peripheral")
.long("feature-peripheral")
.alias("feature_peripheral")
.action(ArgAction::SetTrue)
.help("Use independent cfg feature flags for each peripheral"),
)
.arg(
Arg::new("max_cluster_size")
.long("max_cluster_size")
.long("max-cluster-size")
.alias("max_cluster_size")
.action(ArgAction::SetTrue)
.help("Use array increment for cluster size"),
)
.arg(
Arg::new("impl_debug")
.long("impl_debug")
.long("impl-debug")
.alias("impl_debug")
.action(ArgAction::SetTrue)
.help("implement Debug for readable blocks and registers"),
)
.arg(
Arg::new("impl_debug_feature")
.long("impl_debug_feature")
.long("impl-debug-feature")
.alias("impl_debug_feature")
.help("Add feature gating for block and register debug implementation")
.action(ArgAction::Set)
.value_name("FEATURE"),
Expand All @@ -141,7 +151,8 @@ fn run() -> Result<()> {
)
.arg(
Arg::new("make_mod")
.long("make_mod")
.long("make-mod")
.alias("make_mod")
.short('m')
.action(ArgAction::SetTrue)
.help("Create mod.rs instead of lib.rs, without inner attributes"),
Expand All @@ -155,24 +166,28 @@ fn run() -> Result<()> {
)
.arg(
Arg::new("pascal_enum_values")
.long("pascal_enum_values")
.long("pascal-enum-values")
.alias("pascal_enum_values")
.action(ArgAction::SetTrue)
.help("Use PascalCase in stead of UPPER_CASE for enumerated values"),
)
.arg(
Arg::new("source_type")
.long("source_type")
.long("source-type")
.alias("source_type")
.help("Specify file/stream format"),
)
.arg(
Arg::new("reexport_core_peripherals")
.long("reexport_core_peripherals")
.long("reexport-core-peripherals")
.alias("reexport_core_peripherals")
.action(ArgAction::SetTrue)
.help("For Cortex-M target reexport peripherals from cortex-m crate"),
)
.arg(
Arg::new("reexport_interrupt")
.long("reexport_interrupt")
.long("reexport-interrupt")
.alias("reexport_interrupt")
.action(ArgAction::SetTrue)
.help("Reexport interrupt macro from cortex-m-rt like crates"),
)
Expand Down