Skip to content

Commit 99e68c7

Browse files
authored
Merge pull request #779 from fortify-iq/include-compatible
Add `include-compatible` config flag
2 parents 0b76da7 + cf16e8d commit 99e68c7

File tree

4 files changed

+28
-16
lines changed

4 files changed

+28
-16
lines changed

CHANGELOG.md

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

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

12+
- Add `skip-crate-attributes` config flag
1213
- Add iterators for register/cluster/field arrays
1314
- Use parentheses instead of square brackets in docs for field arrays
1415
- Better display parsing errors

src/config.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ pub struct Config {
1010
pub atomics_feature: Option<String>,
1111
pub generic_mod: bool,
1212
pub make_mod: bool,
13+
pub skip_crate_attributes: bool,
1314
pub ignore_groups: bool,
1415
pub keep_list: bool,
1516
pub strict: bool,

src/generate/device.rs

Lines changed: 19 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -29,28 +29,31 @@ pub fn render(d: &Device, config: &Config, device_x: &mut String) -> Result<Toke
2929
}
3030
};
3131

32-
let doc = format!(
33-
"Peripheral access API for {0} microcontrollers \
34-
(generated using svd2rust v{1}{commit_info})\n\n\
35-
You can find an overview of the generated API [here].\n\n\
36-
API features to be included in the [next] svd2rust \
37-
release can be generated by cloning the svd2rust [repository], \
38-
checking out the above commit, and running `cargo doc --open`.\n\n\
39-
[here]: https://docs.rs/svd2rust/{1}/svd2rust/#peripheral-api\n\
40-
[next]: https://github.com/rust-embedded/svd2rust/blob/master/CHANGELOG.md#unreleased\n\
41-
[repository]: https://github.com/rust-embedded/svd2rust",
42-
d.name.to_uppercase(),
43-
env!("CARGO_PKG_VERSION"),
44-
);
45-
4632
if config.target == Target::Msp430 {
4733
out.extend(quote! {
4834
#![feature(abi_msp430_interrupt)]
4935
});
5036
}
5137

52-
out.extend(quote! { #![doc = #doc] });
53-
if !config.make_mod {
38+
if !config.skip_crate_attributes {
39+
let doc = format!(
40+
"Peripheral access API for {0} microcontrollers \
41+
(generated using svd2rust v{1}{commit_info})\n\n\
42+
You can find an overview of the generated API [here].\n\n\
43+
API features to be included in the [next] svd2rust \
44+
release can be generated by cloning the svd2rust [repository], \
45+
checking out the above commit, and running `cargo doc --open`.\n\n\
46+
[here]: https://docs.rs/svd2rust/{1}/svd2rust/#peripheral-api\n\
47+
[next]: https://github.com/rust-embedded/svd2rust/blob/master/CHANGELOG.md#unreleased\n\
48+
[repository]: https://github.com/rust-embedded/svd2rust",
49+
d.name.to_uppercase(),
50+
env!("CARGO_PKG_VERSION"),
51+
);
52+
53+
out.extend(quote! { #![doc = #doc] });
54+
}
55+
56+
if !config.make_mod && !config.skip_crate_attributes {
5457
out.extend(quote! {
5558
// Explicitly allow a few warnings that may be verbose
5659
#![allow(non_camel_case_types)]

src/main.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,13 @@ fn run() -> Result<()> {
157157
.action(ArgAction::SetTrue)
158158
.help("Create mod.rs instead of lib.rs, without inner attributes"),
159159
)
160+
.arg(
161+
Arg::new("skip_crate_attributes")
162+
.long("skip-crate-attributes")
163+
.alias("skip_crate_attributes")
164+
.action(ArgAction::SetTrue)
165+
.help("Do not generate crate attributes"),
166+
)
160167
.arg(
161168
Arg::new("strict")
162169
.long("strict")

0 commit comments

Comments
 (0)