Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(cli): elf name requires output directory #1982

Open
wants to merge 2 commits into
base: dev
Choose a base branch
from
Open
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
14 changes: 6 additions & 8 deletions crates/build/src/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,15 +44,15 @@ pub fn execute_build_program(
create_local_command(args, &program_dir, &program_metadata)
};

execute_command(cmd, args.docker)?;

let target_elf_paths = generate_elf_paths(&program_metadata, Some(args))?;

if let Some(output_directory) = &args.output_directory {
if target_elf_paths.len() > 1 && args.elf_name.is_some() {
anyhow::bail!("--elf-name is not supported when --output-directory is used and multiple ELFs are built.");
}
if target_elf_paths.len() > 1 && args.elf_name.is_some() {
anyhow::bail!("--elf-name is not supported when --output-directory is used and multiple ELFs are built.");
}

execute_command(cmd, args.docker)?;

if let Some(output_directory) = &args.output_directory {
// The path to the output directory, maybe relative or absolute.
let output_directory = PathBuf::from(output_directory);

Expand All @@ -72,8 +72,6 @@ pub fn execute_build_program(

std::fs::copy(&elf_path, &output_path)?;
}
} else if args.elf_name.is_some() {
println!("cargo:warning=ELF name is set but --output-directory is not used, the ELF will be place in the `target/` directory");
}

print_elf_paths_cargo_directives(&target_elf_paths);
Expand Down
2 changes: 1 addition & 1 deletion crates/build/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ pub struct BuildArgs {
num_args = 1..
)]
pub binaries: Vec<String>,
#[clap(long, action, help = "ELF binary name")]
#[clap(long, action, requires = "output_directory", help = "ELF binary name")]
pub elf_name: Option<String>,
#[clap(alias = "out-dir", long, action, help = "Copy the compiled ELF to this directory")]
pub output_directory: Option<String>,
Expand Down
Loading