Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ bytes = "1.6"
camino = { version = "1.1", features = ["serde1"] }
cfg-if = "1"
chrono = "0.4"
clap = { version = "4.5.21", features = ["derive"] }
colored = "2"
csv = "1.3"
curl = "0.4"
Expand Down
2 changes: 1 addition & 1 deletion xtask/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ search_path = "0.1.4"

camino.workspace = true
chrono.workspace = true
structopt.workspace = true
clap.workspace = true
anyhow.workspace = true
curl.workspace = true
omicron-zone-package.workspace = true
Expand Down
55 changes: 23 additions & 32 deletions xtask/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ use std::path::Path;
use std::str::FromStr;

use anyhow::{anyhow, Context, Result};
use structopt::*;
use clap::{Parser, ValueEnum};

mod codegen;

Expand All @@ -28,9 +28,10 @@ use linux as plat;

// Possible formats for a bundled dendrite distro. Currently the two "zone"
// package formats are helios-only.
#[derive(PartialEq, Debug)]
#[derive(Clone, Copy, PartialEq, Debug, Default, ValueEnum)]
pub enum DistFormat {
Native, // .deb or .p5p, depending on the platform
#[default]
Native, // .deb or .p5p, depending on the platform
Omicron, // package to be included in an omicron zone
Global, // package to run standalone in the global zone
}
Expand All @@ -53,49 +54,39 @@ impl FromStr for DistFormat {
}
}

#[derive(Debug, StructOpt)]
#[structopt(name = "xtask", about = "dendrite xtask support")]
#[derive(Debug, Parser)]
#[clap(name = "xtask", about = "dendrite xtask support")]
enum Xtasks {
#[structopt(about = "compile a p4 program")]
/// compile a p4 program
Codegen {
#[structopt(
short,
help = "name of p4 program to build",
default_value = "sidecar"
)]
/// name of p4 program to build
#[clap(short, default_value = "sidecar")]
name: String,

#[structopt(
long,
help = "location of the tofino SDE",
default_value = "/opt/oxide/tofino_sde"
)]
/// location of the tofino SDE
#[clap(long, default_value = "/opt/oxide/tofino_sde")]
sde: String,

#[structopt(long, help = "pipeline stages to build for")]
/// pipeline stages to build for
#[clap(long)]
stages: Option<u8>,
},
#[structopt(about = "build an installable dataplane controller package")]
/// build an installable dataplane controller package
Dist {
#[structopt(long, help = "tofino_asic, tofino_stub, or softnpu")]
/// tofino_asic, tofino_stub, or softnpu
#[clap(long)]
features: Option<String>,

#[structopt(
short,
help = "list of p4 programs to include",
default_value = "sidecar"
)]
/// list of p4 programs to include
#[clap(short, default_value = "sidecar")]
names: Vec<String>,

#[structopt(short, long, help = "package release bits ")]
/// package release bits
#[clap(short, long)]
release: bool,

#[structopt(
short,
long,
help = "package format: omicron, global, native",
default_value = "native"
)]
/// package format: omicron, global, native
#[clap(short, long, value_enum, default_value_t)]
format: DistFormat,
},
}
Expand Down Expand Up @@ -248,7 +239,7 @@ fn collect_binaries<T: ToString>(
)]
#[tokio::main]
async fn main() {
let task = Xtasks::from_args();
let task = Xtasks::parse();
if let Err(e) = match task {
Xtasks::Codegen { name, sde, stages } => {
codegen::build(name, sde, stages)
Expand Down