diff --git a/CHANGELOG.md b/CHANGELOG.md index fd7877b3..7d826cb7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -26,6 +26,8 @@ and this project adheres to [Semantic Versioning](http://semver.org/). - Ignore default enumeratedValues. +- Bring `generic` module into scope in `lib.rs` when using `-g` option. + ### Changed - [breaking-change] remove `Variant`, use `Option` instead diff --git a/src/generate/device.rs b/src/generate/device.rs index 00453828..dce87bd4 100644 --- a/src/generate/device.rs +++ b/src/generate/device.rs @@ -146,6 +146,13 @@ pub fn render( let generic_file = std::str::from_utf8(include_bytes!("generic.rs"))?; if generic_mod { writeln!(File::create("generic.rs")?, "{}", generic_file)?; + + out.extend(quote! { + #[allow(unused_imports)] + use generic::*; + #[doc="Common register and bit access and modify traits"] + pub mod generic; + }); } else { let tokens = syn::parse_file(generic_file)?.into_token_stream(); diff --git a/src/lib.rs b/src/lib.rs index 424e72c0..a1a4e8a3 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -26,6 +26,10 @@ //! //! If the `--target` flag is omitted `svd2rust` assumes the target is the Cortex-M architecture. //! +//! If using the `--generic_mod` option, the emitted `generic.rs` needs to be moved to `src`, and +//! [`form`](https://github.com/djmcgill/form) commit fcb397a or newer is required for splitting +//! the emitted `lib.rs`. +//! //! ## target = cortex-m //! //! When targeting the Cortex-M architecture, `svd2rust` will generate three files in the current