diff --git a/main/src/check.rs b/main/src/check.rs index 9cbb534..92c4863 100644 --- a/main/src/check.rs +++ b/main/src/check.rs @@ -120,7 +120,8 @@ impl CheckConfig { let toolchain_file_path = PathBuf::from(".").as_path().join(TOOLCHAIN_FILE_NAME); let toolchain_channel = extract_toolchain_channel(&toolchain_file_path)?; let rust_stable = !toolchain_channel.contains("nightly"); - let cfg = BuildConfig::new(rust_stable); + let mut cfg = BuildConfig::new(rust_stable); + cfg.features = self.common_cfg.features; let wasm = project::build_dylib(cfg.clone())?; let project_hash = project::hash_project(self.common_cfg.source_files_for_project_hash.clone(), cfg)?; diff --git a/main/src/main.rs b/main/src/main.rs index 5cd0baa..b8bf51e 100644 --- a/main/src/main.rs +++ b/main/src/main.rs @@ -126,6 +126,9 @@ struct CommonConfig { #[arg(long)] /// Optional max fee per gas in gwei units. max_fee_per_gas_gwei: Option, + /// Specifies the features to use when building the Stylus binary. + #[arg(long)] + features: Option, } #[derive(Subcommand, Clone, Debug)] @@ -687,7 +690,7 @@ async fn replay(args: ReplayArgs) -> Result<()> { let provider = sys::new_provider(&args.trace.endpoint)?; let trace = Trace::new(provider, args.trace.tx, args.trace.use_native_tracer).await?; - build_shared_library(&args.trace.project, args.package, args.feature)?; + build_shared_library(&args.trace.project, args.package, args.features)?; let library_extension = if macos { ".dylib" } else { ".so" }; let shared_library = find_shared_library(&args.trace.project, library_extension)?; diff --git a/main/src/project.rs b/main/src/project.rs index 95f34c8..33be8ad 100644 --- a/main/src/project.rs +++ b/main/src/project.rs @@ -38,6 +38,7 @@ pub enum OptLevel { pub struct BuildConfig { pub opt_level: OptLevel, pub stable: bool, + pub features: Option, } impl BuildConfig { @@ -74,6 +75,10 @@ pub fn build_dylib(cfg: BuildConfig) -> Result { cmd.arg("--lib"); cmd.arg("--locked"); + if cfg.features.is_some() { + cmd.arg(format!("--features={}", cfg.features.clone().unwrap())); + } + if !cfg.stable { cmd.arg("-Z"); cmd.arg("build-std=std,panic_abort"); diff --git a/main/src/verify.rs b/main/src/verify.rs index c8087f2..82165ae 100644 --- a/main/src/verify.rs +++ b/main/src/verify.rs @@ -64,6 +64,7 @@ pub async fn verify(cfg: VerifyConfig) -> eyre::Result<()> { let build_cfg = project::BuildConfig { opt_level: project::OptLevel::default(), stable: rust_stable, + features: cfg.common_cfg.features.clone(), }; let wasm_file: PathBuf = project::build_dylib(build_cfg.clone()) .map_err(|e| eyre!("could not build project to WASM: {e}"))?;