Skip to content

Commit

Permalink
Merge pull request #29 from tock/metadata-updates
Browse files Browse the repository at this point in the history
Add flags to TAB metadata.toml file
  • Loading branch information
bradjc authored Sep 2, 2022
2 parents 4600fd1 + 1f193b3 commit aee52da
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 2 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ OPTIONS:
--read_ids <read_ids>... Storage IDs that this app is allowed to read
--stack <stack-size> in bytes [default: 2048]
--write_id <write_id> A storage ID used for writing data
--supported-boards <supported-boards> Comma separated list of boards this app is compatible with
ARGS:
<elf[,architecture]>... application file(s) to package
Expand Down
7 changes: 7 additions & 0 deletions src/cmdline.rs
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,13 @@ pub struct Opt {
help = "The minimum kernel minor version that the app requires"
)]
pub kernel_minor: Option<u16>,

#[structopt(
long = "supported-boards",
name = "supported-boards",
help = "comma separated list of boards this app is compatible with"
)]
pub supported_boards: Option<String>,
}

mod test {
Expand Down
12 changes: 10 additions & 2 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ use elf2tab::convert;
fn main() {
let opt = cmdline::Opt::from_args();

// Get app name from command line arguments or use empty string as default.
let package_name = opt
.package_name
.as_ref()
Expand All @@ -31,8 +32,6 @@ fn main() {
writeln!(&mut metadata_toml, "tab-version = 1").unwrap();
// Name is always set by elf2tab (even if it is empty).
writeln!(&mut metadata_toml, "name = \"{}\"", package_name).unwrap();
// We don't currently tell elf2tab if this app only runs on certain boards.
writeln!(&mut metadata_toml, "only-for-boards = \"\"").unwrap();
// Include "minimum-tock-kernel-version" key if a necessary kernel version
// was specified.
minimum_tock_kernel_version.map(|(major, minor)| {
Expand All @@ -43,6 +42,15 @@ fn main() {
)
.unwrap();
});
// Include "only-for-boards" key if specific boards were specified.
opt.supported_boards.as_ref().map(|supported_boards| {
writeln!(
&mut metadata_toml,
"only-for-boards = \"{}\"",
supported_boards.as_str()
)
.unwrap();
});
// Add build-date metadata unless a deterministic build is desired.
if !opt.deterministic {
let build_date = chrono::Utc::now().to_rfc3339_opts(chrono::SecondsFormat::Secs, true);
Expand Down

0 comments on commit aee52da

Please sign in to comment.