Skip to content

Commit

Permalink
Add slop
Browse files Browse the repository at this point in the history
  • Loading branch information
Arrowana committed Sep 12, 2021
1 parent e763b72 commit e7ff543
Showing 1 changed file with 18 additions and 3 deletions.
21 changes: 18 additions & 3 deletions cli/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,8 @@ pub enum Command {
/// only.
#[clap(short, long)]
solana_version: Option<String>,
#[clap(required = false, takes_value = true, multiple_values = true, last = true)]
slop: Vec<String>,
},
/// Verifies the on-chain bytecode matches the locally compiled artifact.
/// Run this command inside a program subdirectory, i.e., in the dir
Expand Down Expand Up @@ -255,6 +257,7 @@ pub fn entry(opts: Opts) -> Result<()> {
verifiable,
program_name,
solana_version,
slop,
} => build(
&opts.cfg_override,
idl,
Expand All @@ -263,6 +266,7 @@ pub fn entry(opts: Opts) -> Result<()> {
solana_version,
None,
None,
Some(slop),
),
Command::Verify {
program_id,
Expand Down Expand Up @@ -433,6 +437,7 @@ pub fn build(
solana_version: Option<String>,
stdout: Option<File>, // Used for the package registry server.
stderr: Option<File>, // Used for the package registry server.
slop: Option<Vec<String>>,
) -> Result<()> {
// Change to the workspace member directory, if needed.
if let Some(program_name) = program_name.as_ref() {
Expand Down Expand Up @@ -469,6 +474,7 @@ pub fn build(
solana_version,
stdout,
stderr,
slop,
)?,
// If the Cargo.toml is at the root, build the entire workspace.
Some(cargo) if cargo.path().parent() == cfg.path().parent() => build_all(
Expand All @@ -479,6 +485,7 @@ pub fn build(
solana_version,
stdout,
stderr,
slop,
)?,
// Cargo.toml represents a single package. Build it.
Some(cargo) => build_cwd(
Expand All @@ -489,6 +496,7 @@ pub fn build(
solana_version,
stdout,
stderr,
slop,
)?,
}

Expand All @@ -505,6 +513,7 @@ fn build_all(
solana_version: Option<String>,
stdout: Option<File>, // Used for the package registry server.
stderr: Option<File>, // Used for the package registry server.
slop: Option<Vec<String>>,
) -> Result<()> {
let cur_dir = std::env::current_dir()?;
let r = match cfg_path.parent() {
Expand All @@ -519,6 +528,7 @@ fn build_all(
solana_version.clone(),
stdout.as_ref().map(|f| f.try_clone()).transpose()?,
stderr.as_ref().map(|f| f.try_clone()).transpose()?,
slop.clone(),
)?;
}
Ok(())
Expand All @@ -537,13 +547,14 @@ fn build_cwd(
solana_version: Option<String>,
stdout: Option<File>,
stderr: Option<File>,
slop: Option<Vec<String>>,
) -> Result<()> {
match cargo_toml.parent() {
None => return Err(anyhow!("Unable to find parent")),
Some(p) => std::env::set_current_dir(&p)?,
};
match verifiable {
false => _build_cwd(idl_out),
false => _build_cwd(idl_out, slop),
true => build_cwd_verifiable(cfg, cargo_toml, solana_version, stdout, stderr),
}
}
Expand Down Expand Up @@ -772,9 +783,11 @@ fn docker_build(
Ok(())
}

fn _build_cwd(idl_out: Option<PathBuf>) -> Result<()> {
fn _build_cwd(idl_out: Option<PathBuf>, slop: Option<Vec<String>>) -> Result<()> {
let exit = std::process::Command::new("cargo")
.arg("build-bpf")
//.arg("--")
.args(slop.unwrap_or(vec![]))
.stdout(Stdio::inherit())
.stderr(Stdio::inherit())
.output()
Expand Down Expand Up @@ -824,6 +837,7 @@ fn verify(
},
None,
None,
None,
)?;
std::env::set_current_dir(&cur_dir)?;

Expand Down Expand Up @@ -1313,7 +1327,7 @@ fn test(
with_workspace(cfg_override, |cfg| {
// Build if needed.
if !skip_build {
build(cfg_override, None, false, None, None, None, None)?;
build(cfg_override, None, false, None, None, None, None, None)?;
}

// Run the deploy against the cluster in two cases:
Expand Down Expand Up @@ -2009,6 +2023,7 @@ fn publish(cfg_override: &ConfigOverride, program_name: String) -> Result<()> {
cfg.solana_version.clone(),
None,
None,
None,
)?;

// Set directory to top of the workspace.
Expand Down

0 comments on commit e7ff543

Please sign in to comment.