Skip to content

Commit

Permalink
Add --version and --serial flags to the host runner (#653)
Browse files Browse the repository at this point in the history
  • Loading branch information
ia0 authored Oct 24, 2024
1 parent a03cbb3 commit 6b99b3c
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 2 deletions.
6 changes: 4 additions & 2 deletions crates/runner-host/src/board/platform.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ use data_encoding::HEXLOWER_PERMISSIVE;
use wasefire_board_api::platform::Api;
use wasefire_board_api::Error;

use crate::FLAGS;

pub mod protocol;
mod update;

Expand All @@ -29,11 +31,11 @@ impl Api for Impl {
type Update = update::Impl;

fn serial() -> Cow<'static, [u8]> {
from_hex(option_env!("WASEFIRE_HOST_SERIAL"))
from_hex(FLAGS.serial.as_deref())
}

fn version() -> Cow<'static, [u8]> {
from_hex(option_env!("WASEFIRE_HOST_VERSION"))
from_hex(FLAGS.version.as_deref())
}

fn reboot() -> Result<!, Error> {
Expand Down
8 changes: 8 additions & 0 deletions crates/runner-host/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,14 @@ struct Flags {
/// Socket address to bind to when --interface=web (ignored otherwise).
#[arg(long, default_value = "127.0.0.1:5000")]
web_addr: SocketAddr,

/// Platform version (in hexadecimal).
#[arg(long, default_value = option_env!("WASEFIRE_HOST_VERSION").unwrap_or_default())]
version: Option<String>,

/// Platform serial (in hexadecimal).
#[arg(long, default_value = option_env!("WASEFIRE_HOST_SERIAL").unwrap_or_default())]
serial: Option<String>,
}

#[test]
Expand Down
9 changes: 9 additions & 0 deletions crates/xtask/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,12 @@ struct RunnerOptions {
#[clap(long)]
version: Option<String>,

/// Host platform serial.
///
/// This is only used for the host runner. It must be an hexadecimal byte sequence.
#[clap(long)]
serial: Option<String>,

/// Cargo no-default-features.
#[clap(long)]
no_default_features: bool,
Expand Down Expand Up @@ -466,6 +472,9 @@ impl RunnerOptions {
if let Some(version) = &self.version {
cargo.env("WASEFIRE_HOST_VERSION", version);
}
if let Some(serial) = &self.serial {
cargo.env("WASEFIRE_HOST_SERIAL", serial);
}
cmd::execute(Command::new("make").current_dir("crates/runner-host/crates/web-client"))
.await?;
}
Expand Down

0 comments on commit 6b99b3c

Please sign in to comment.