Skip to content

Commit

Permalink
chore: Move build comments to CLI help descriptors (#1016)
Browse files Browse the repository at this point in the history
  • Loading branch information
stephenh-axiom-xyz authored Dec 13, 2024
1 parent af15760 commit 2857d92
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 27 deletions.
52 changes: 30 additions & 22 deletions crates/cli/src/commands/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,57 +34,65 @@ impl BuildCmd {

#[derive(Clone, Parser)]
pub struct BuildArgs {
/// Location of the directory containing the Cargo.toml for the guest code.
///
/// This path is relative to the current directory.
#[arg(long)]
#[arg(
long,
help = "Path to the directory containing the Cargo.toml file for the guest code (relative to the current directory)"
)]
pub manifest_dir: Option<PathBuf>,

/// Feature flags passed to cargo.
#[arg(long, value_delimiter = ',')]
#[arg(long, value_delimiter = ',', help = "Feature flags passed to cargo")]
pub features: Vec<String>,

#[clap(flatten)]
#[clap(flatten, help = "Filter the target to build")]
pub bin_type_filter: BinTypeFilter,

/// Target name substring filter
#[arg(long)]
#[arg(long, help = "Target name substring filter")]
pub name: Option<String>,

/// Transpile the program after building
#[arg(long, default_value = "false")]
#[arg(
long,
default_value = "false",
help = "Transpiles the program after building when set"
)]
pub transpile: bool,

/// Path to the SDK config .toml file that specifies the transpiler extensions
#[arg(long)]
#[arg(
long,
help = "Path to the SDK config .toml file that specifies the transpiler extensions"
)]
pub transpiler_config: Option<PathBuf>,

/// Output path for the transpiled program (default: <ELF base path>.openvmexe)
#[arg(long)]
#[arg(
long,
help = "Output path for the transpiled program (default: <ELF base path>.vmexe)"
)]
pub transpile_to: Option<PathBuf>,

/// Build profile
#[arg(long, default_value = "release")]
#[arg(long, default_value = "release", help = "Build profile")]
pub profile: String,
}

impl BuildArgs {
pub fn exe_path(&self, elf_path: &Path) -> PathBuf {
self.transpile_to
.clone()
.unwrap_or_else(|| elf_path.with_extension("openvmexe"))
.unwrap_or_else(|| elf_path.with_extension("vmexe"))
}
}

#[derive(Clone, clap::Args)]
#[group(required = false, multiple = false)]
pub struct BinTypeFilter {
/// Specify that the target should be a binary kind
#[arg(long)]
#[arg(
long,
help = "Specifies that the target should be a binary kind when set"
)]
pub bin: bool,

/// Specify that the target should be an example kind
#[arg(long)]
#[arg(
long,
help = "Specifies that the target should be an example kind when set"
)]
pub example: bool,
}

Expand Down
3 changes: 0 additions & 3 deletions crates/cli/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,3 @@ pub fn is_supported_target() -> bool {
pub fn get_target() -> String {
target_lexicon::HOST.to_string()
}

#[cfg(test)]
mod tests;
4 changes: 2 additions & 2 deletions crates/cli/src/tests.rs → crates/cli/tests/app_e2e.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use eyre::Result;
use tempfile::tempdir;

#[test]
fn test_cli_e2e() -> Result<()> {
fn test_cli_app_e2e() -> Result<()> {
let temp_dir = tempdir()?;
let package_dir = env::current_dir()?;
let prefix = "[test cli e2e]";
Expand All @@ -21,7 +21,7 @@ fn test_cli_e2e() -> Result<()> {
println!("{}", std::str::from_utf8(&output.stderr).unwrap());
};
run_cmd("cargo", &["install", "--path", ".", "--force"]);
let temp_exe = temp_dir.path().join("example.openvmexe");
let temp_exe = temp_dir.path().join("example.vmexe");
let temp_pk = temp_dir.path().join("example.pk");
let temp_vk = temp_dir.path().join("example.vk");
let temp_proof = temp_dir.path().join("example.apppf");
Expand Down

0 comments on commit 2857d92

Please sign in to comment.