Skip to content

Commit

Permalink
Merge pull request #779 from fortify-iq/include-compatible
Browse files Browse the repository at this point in the history
Add `include-compatible` config flag
  • Loading branch information
burrbull authored Nov 29, 2023
2 parents 0b76da7 + cf16e8d commit 99e68c7
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 16 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/).

## [v0.31.2] - 2023-11-29

- Add `skip-crate-attributes` config flag
- Add iterators for register/cluster/field arrays
- Use parentheses instead of square brackets in docs for field arrays
- Better display parsing errors
Expand Down
1 change: 1 addition & 0 deletions src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ pub struct Config {
pub atomics_feature: Option<String>,
pub generic_mod: bool,
pub make_mod: bool,
pub skip_crate_attributes: bool,
pub ignore_groups: bool,
pub keep_list: bool,
pub strict: bool,
Expand Down
35 changes: 19 additions & 16 deletions src/generate/device.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,28 +29,31 @@ pub fn render(d: &Device, config: &Config, device_x: &mut String) -> Result<Toke
}
};

let doc = format!(
"Peripheral access API for {0} microcontrollers \
(generated using svd2rust v{1}{commit_info})\n\n\
You can find an overview of the generated API [here].\n\n\
API features to be included in the [next] svd2rust \
release can be generated by cloning the svd2rust [repository], \
checking out the above commit, and running `cargo doc --open`.\n\n\
[here]: https://docs.rs/svd2rust/{1}/svd2rust/#peripheral-api\n\
[next]: https://github.com/rust-embedded/svd2rust/blob/master/CHANGELOG.md#unreleased\n\
[repository]: https://github.com/rust-embedded/svd2rust",
d.name.to_uppercase(),
env!("CARGO_PKG_VERSION"),
);

if config.target == Target::Msp430 {
out.extend(quote! {
#![feature(abi_msp430_interrupt)]
});
}

out.extend(quote! { #![doc = #doc] });
if !config.make_mod {
if !config.skip_crate_attributes {
let doc = format!(
"Peripheral access API for {0} microcontrollers \
(generated using svd2rust v{1}{commit_info})\n\n\
You can find an overview of the generated API [here].\n\n\
API features to be included in the [next] svd2rust \
release can be generated by cloning the svd2rust [repository], \
checking out the above commit, and running `cargo doc --open`.\n\n\
[here]: https://docs.rs/svd2rust/{1}/svd2rust/#peripheral-api\n\
[next]: https://github.com/rust-embedded/svd2rust/blob/master/CHANGELOG.md#unreleased\n\
[repository]: https://github.com/rust-embedded/svd2rust",
d.name.to_uppercase(),
env!("CARGO_PKG_VERSION"),
);

out.extend(quote! { #![doc = #doc] });
}

if !config.make_mod && !config.skip_crate_attributes {
out.extend(quote! {
// Explicitly allow a few warnings that may be verbose
#![allow(non_camel_case_types)]
Expand Down
7 changes: 7 additions & 0 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,13 @@ fn run() -> Result<()> {
.action(ArgAction::SetTrue)
.help("Create mod.rs instead of lib.rs, without inner attributes"),
)
.arg(
Arg::new("skip_crate_attributes")
.long("skip-crate-attributes")
.alias("skip_crate_attributes")
.action(ArgAction::SetTrue)
.help("Do not generate crate attributes"),
)
.arg(
Arg::new("strict")
.long("strict")
Expand Down

0 comments on commit 99e68c7

Please sign in to comment.