Skip to content

Commit c8be313

Browse files
bors[bot]Shatur
andauthored
Merge #619
619: Make binary dependencies optional r=burrbull,emilgardis a=Shatur Users can now disable binary dependencies if they don't need them, closes #618. I think we could also make JSON and YAML optional and keep them enabled by default. What do you think? Co-authored-by: Hennadii Chernyshchyk <genaloner@gmail.com>
2 parents 298f1f9 + 3e94c98 commit c8be313

File tree

6 files changed

+27
-9
lines changed

6 files changed

+27
-9
lines changed

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ jobs:
6969
options: all
7070
include:
7171
# Test MSRV
72-
- rust: 1.51.0
72+
- rust: 1.60.0
7373
vendor: Nordic
7474

7575
# Use nightly for architectures which don't support stable

CHANGELOG.md

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

88
## [Unreleased]
99

10+
- Make binary dependencies optional
11+
- Make JSON and YAML formats optional
12+
- Bump MSRV to 1.60
13+
1014
## [v0.24.0] - 2022-05-12
1115

1216
[commits][v0.24.0]

Cargo.toml

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ name = "svd2rust"
2525
repository = "https://github.com/rust-embedded/svd2rust/"
2626
version = "0.24.0"
2727
readme = "README.md"
28+
rust-version = "1.60"
2829

2930
[package.metadata.deb]
3031
section = "rust"
@@ -33,20 +34,27 @@ section = "rust"
3334
doc = false
3435
name = "svd2rust"
3536
path = "src/main.rs"
37+
required-features = ["bin"]
38+
39+
[features]
40+
default = ["bin", "json", "yaml"]
41+
bin = ["dep:clap", "dep:clap_conf", "dep:env_logger"]
42+
json = ["dep:serde_json"]
43+
yaml = ["dep:serde_yaml"]
3644

3745
[dependencies]
3846
cast = "0.3"
39-
clap = "2.33"
40-
clap_conf = "0.1.5"
41-
env_logger = "0.9"
47+
clap = { version = "2.33", optional = true }
48+
clap_conf = { version = "0.1.5", optional = true }
49+
env_logger = { version = "0.9", optional = true }
4250
inflections = "1.1"
4351
log = { version = "~0.4", features = ["std"] }
4452
quote = "1.0"
4553
proc-macro2 = "1.0"
4654
anyhow = "1.0"
4755
thiserror = "1.0"
48-
serde_json = "1.0.79"
49-
serde_yaml = "0.8.23"
56+
serde_json = { version = "1.0.79", optional = true }
57+
serde_yaml = { version = "0.8.23", optional = true }
5058

5159
[dependencies.svd-parser]
5260
features = ["expand"]

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,9 @@ This project is developed and maintained by the [Tools team][team].
1313

1414
## Minimum Supported Rust Version (MSRV)
1515

16-
The **generated code** is guaranteed to compile on stable Rust 1.51.0 and up.
16+
The **generated code** is guaranteed to compile on stable Rust 1.60.0 and up.
1717

18-
If you encounter compilation errors on any stable version newer than 1.51.0, please open an issue.
18+
If you encounter compilation errors on any stable version newer than 1.60.0, please open an issue.
1919

2020
# Testing Locally
2121

src/lib.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -582,8 +582,10 @@ pub fn load_from(input: &str, config: &crate::util::Config) -> Result<svd::Devic
582582
svd_parser::parse_with_config(input, &parser_config)
583583
.with_context(|| "Error parsing SVD XML file".to_string())?
584584
}
585+
#[cfg(feature = "yaml")]
585586
SourceType::Yaml => serde_yaml::from_str(input)
586587
.with_context(|| "Error parsing SVD YAML file".to_string())?,
588+
#[cfg(feature = "json")]
587589
SourceType::Json => serde_json::from_str(input)
588590
.with_context(|| "Error parsing SVD JSON file".to_string())?,
589591
};

src/util.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,9 @@ impl Default for Target {
8888
#[derive(Clone, Copy, PartialEq, Debug)]
8989
pub enum SourceType {
9090
Xml,
91+
#[cfg(feature = "yaml")]
9192
Yaml,
93+
#[cfg(feature = "json")]
9294
Json,
9395
}
9496

@@ -102,9 +104,11 @@ impl SourceType {
102104
/// Make a new [`Source`] from a given extension.
103105
pub fn from_extension(s: &str) -> Option<Self> {
104106
match s {
107+
"svd" | "xml" => Some(Self::Xml),
108+
#[cfg(feature = "yaml")]
105109
"yml" | "yaml" => Some(Self::Yaml),
110+
#[cfg(feature = "json")]
106111
"json" => Some(Self::Json),
107-
"svd" | "xml" => Some(Self::Xml),
108112
_ => None,
109113
}
110114
}

0 commit comments

Comments
 (0)