Skip to content

Commit 9d5b607

Browse files
committed
Emit code to bring generic module into scope when using -g option.
1 parent 5f8c24e commit 9d5b607

File tree

3 files changed

+13
-0
lines changed

3 files changed

+13
-0
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
2626

2727
- Ignore default enumeratedValues.
2828

29+
- Bring `generic` module into scope in `lib.rs` when using `-g` option.
30+
2931
### Changed
3032

3133
- [breaking-change] remove `Variant<U, ENUM_A>`, use `Option<ENUM_A>` instead

src/generate/device.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,13 @@ pub fn render(
146146
let generic_file = std::str::from_utf8(include_bytes!("generic.rs"))?;
147147
if generic_mod {
148148
writeln!(File::create("generic.rs")?, "{}", generic_file)?;
149+
150+
out.extend(quote! {
151+
#[allow(unused_imports)]
152+
use generic::*;
153+
///Common register and bit access and modify traits
154+
pub mod generic;
155+
});
149156
} else {
150157
let tokens = syn::parse_file(generic_file)?.into_token_stream();
151158

src/lib.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,10 @@
2626
//!
2727
//! If the `--target` flag is omitted `svd2rust` assumes the target is the Cortex-M architecture.
2828
//!
29+
//! If using the `--generic_mod` option, the emitted `generic.rs` needs to be moved to `src`, and
30+
//! [`form`](https://github.com/djmcgill/form) commit fcb397a or newer is required for splitting
31+
//! the emitted `lib.rs`.
32+
//!
2933
//! ## target = cortex-m
3034
//!
3135
//! When targeting the Cortex-M architecture, `svd2rust` will generate three files in the current

0 commit comments

Comments
 (0)