Skip to content

Commit 86aae8a

Browse files
committed
framework_lib: Update regex for no-std support
Signed-off-by: Daniel Schaefer <dhs@frame.work>
1 parent fa3ee6d commit 86aae8a

3 files changed

Lines changed: 22 additions & 36 deletions

File tree

Cargo.lock

Lines changed: 20 additions & 8 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

framework_lib/Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ linux = ["linux_pio", "unix"]
1313
# Windows does not have the cros_ec driver nor raw port I/O access to userspace
1414
windows = ["std", "smbios", "dep:windows", "win_driver"]
1515
smbios = ["dep:smbios-lib"]
16-
std = ["dep:regex", "dep:clap", "dep:clap-verbosity-flag", "dep:env_logger", "smbios-lib?/std", "dep:hidapi", "dep:rusb"]
16+
std = ["dep:clap", "dep:clap-verbosity-flag", "dep:env_logger", "smbios-lib?/std", "dep:hidapi", "dep:rusb"]
1717
uefi = ["dep:plain", "raw_pio", "smbios", "lazy_static/spin_no_std", "dep:uefi", "dep:uefi-services"]
1818

1919
# EC communication via Port I/O on Linux
@@ -31,7 +31,7 @@ built = { version = "0.5", features = ["chrono", "git2"] }
3131

3232
[dependencies]
3333
lazy_static = "1.4.0"
34-
regex = { version = "1.6.0", optional = true } # TODO: Can update to 1.7.0
34+
regex = { version = "1.10.0", default-features = false }
3535
redox_hwio = { version = "0.1.5", default_features = false }
3636
libc = { version = "0.2.137", optional = true }
3737
clap = { version = "4.0", features = ["derive"], optional = true }

framework_lib/src/ec_binary.rs

Lines changed: 0 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,6 @@ const EC_RO_VER_OFFSET_ZEPHYR: usize = 0x00180;
1515
const EC_RW_VER_OFFSET_ZEPHYR: usize = 0x40140;
1616
pub const EC_LEN: usize = 0x8_0000;
1717

18-
#[cfg(not(feature = "uefi"))]
19-
#[cfg(feature = "std")]
2018
use regex;
2119

2220
#[cfg(feature = "uefi")]
@@ -75,29 +73,6 @@ pub fn print_ec_version(ver: &ImageVersionData, ro: bool) {
7573
println!(" Size: {:>20} KB", ver.size / 1024);
7674
}
7775

78-
#[cfg(feature = "uefi")]
79-
fn parse_ec_version(data: &_ImageVersionData) -> Option<ImageVersionData> {
80-
let version = std::str::from_utf8(&data.version)
81-
.ok()?
82-
.trim_end_matches(char::from(0));
83-
84-
// TODO: regex crate does not support no_std
85-
86-
Some(ImageVersionData {
87-
version: version.to_string(),
88-
size: data.size,
89-
rollback_version: data.rollback_version,
90-
details: ImageVersionDetails {
91-
platform: "".to_string(),
92-
major: 0,
93-
minor: 0,
94-
patch: 0,
95-
commit: "".to_string(),
96-
},
97-
})
98-
}
99-
100-
#[cfg(not(feature = "uefi"))]
10176
fn parse_ec_version(data: &_ImageVersionData) -> Option<ImageVersionData> {
10277
let version = std::str::from_utf8(&data.version)
10378
.ok()?
@@ -146,7 +121,6 @@ fn parse_ec_version(data: &_ImageVersionData) -> Option<ImageVersionData> {
146121
/// commit: "c6c7ac3".to_string(),
147122
/// }));
148123
/// ```
149-
#[cfg(not(feature = "uefi"))]
150124
pub fn parse_ec_version_str(version: &str) -> Option<ImageVersionDetails> {
151125
debug!("Trying to parse version: {:?}", version);
152126
let re = regex::Regex::new(r"([a-z0-9]+)(_v|-)([0-9])\.([0-9])\.([0-9]+)-(ec:)?([0-9a-f]+)")

0 commit comments

Comments
 (0)