Skip to content

Commit

Permalink
support for evm-version
Browse files Browse the repository at this point in the history
  • Loading branch information
chandrakananandi committed Apr 22, 2024
1 parent a97670e commit b990247
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 7 deletions.
4 changes: 4 additions & 0 deletions src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,10 @@ pub struct MutateParams {
#[serde(default = "default_solc_optimize")]
pub solc_optimize: bool,

/// Run solc with the `--evm-version` flag
#[arg(long)]
pub solc_evm_version: Option<String>,

/// Specify function names to mutate
#[arg(long, num_args(1..))]
pub functions: Option<Vec<String>>,
Expand Down
20 changes: 13 additions & 7 deletions src/compile.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ static INCLUDEPATH: &str = "--include-path";
static BASEPATH: &str = "--base-path";
static OPTIMIZE: &str = "--optimize";
static DOT_JSON: &str = ".json";
static EVM_VERSION: &str = "--evm-version";

/// Compilation configurations. This exists across compilations of individual
/// files
Expand All @@ -33,6 +34,7 @@ pub struct Solc {
include_path: Option<String>,
remappings: Option<Vec<String>>,
optimize: bool,
evm_version: Option<String>,
}

impl Solc {
Expand All @@ -45,20 +47,14 @@ impl Solc {
include_path: None,
remappings: None,
optimize: false,
evm_version: None,
}
}

pub fn output_directory(&self) -> &Path {
&self.output_directory
}

pub fn basepath(&self) -> Option<&String> {
match &self.basepath {
Some(bp) => Some(bp),
None => None,
}
}

pub fn with_basepath(&mut self, basepath: String) -> &Self {
self.basepath = Some(basepath);
self
Expand All @@ -83,6 +79,11 @@ impl Solc {
self.optimize = optimize;
self
}

pub fn with_evm_version(&mut self, evm_version: String) -> &Self {
self.evm_version = Some(evm_version);
self
}
}

impl Solc {
Expand Down Expand Up @@ -320,6 +321,11 @@ impl Solc {
flags.push(OPTIMIZE.into());
}

if let Some(evm_version) = &self.evm_version {
flags.push(EVM_VERSION.into());
flags.push(evm_version.clone());
}

flags
}
}
4 changes: 4 additions & 0 deletions src/mutator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,10 @@ impl From<&MutateParams> for Mutator {
.into(),
);
solc.with_optimize(value.solc_optimize);

if let Some(evm_version) = value.solc_evm_version.clone() {
solc.with_evm_version(evm_version);
}
if let Some(basepath) = value.solc_base_path.clone() {
solc.with_basepath(basepath);
}
Expand Down

0 comments on commit b990247

Please sign in to comment.