Skip to content

Commit d4b0ac7

Browse files
committed
use protocol version instead of crate version
1 parent 1a472d7 commit d4b0ac7

4 files changed

Lines changed: 75 additions & 1 deletion

File tree

Cargo.lock

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

Cargo.toml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@ edition = "2024"
33
name = "archer"
44
version = "1.3.3"
55

6+
[package.metadata]
7+
ProtocolVersion = "1.3.3"
8+
69
[[bin]]
710
name = "archer"
811
test = false
@@ -34,6 +37,9 @@ thiserror = { version = "2.0", default-features = false }
3437
embedded-io = "0.7.1"
3538
esp-bootloader-esp-idf = { version = "0.4.0", features = ["esp32"] }
3639

40+
[build-dependencies]
41+
cargo_metadata = "0.23.1"
42+
3743
[profile.dev]
3844
# Rust debug is too slow.
3945
# For debug builds always builds with some optimization

build.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
use cargo_metadata::MetadataCommand;
2+
13
fn main() {
4+
let metadata = MetadataCommand::new().no_deps().exec().unwrap();
5+
let protocol_version = metadata.root_package().unwrap().metadata["ProtocolVersion"].as_str().expect("ProtocolVersion must be a string in the format of X.X.X");
6+
println!("cargo:rustc-env=PROTOCOL_VERSION={}", protocol_version);
27
println!("cargo:rustc-link-arg=-Tlinkall.x");
38
}

src/commands.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@ pub async fn parse_command<I: embedded_hal::i2c::I2c>(
177177
return Ok(is_calibrated.to_string());
178178
}
179179
"VERS" => {
180-
return Ok(env!("CARGO_PKG_VERSION").to_string());
180+
return Ok(env!("PROTOCOL_VERSION").to_string());
181181
}
182182
"SSPD" => match arguments.next() {
183183
Some("VER") => {

0 commit comments

Comments
 (0)