Skip to content

Commit

Permalink
features
Browse files Browse the repository at this point in the history
  • Loading branch information
rauljordan committed Dec 12, 2024
2 parents 90f7f32 + 306a6d3 commit da7f1b1
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 2 deletions.
3 changes: 2 additions & 1 deletion main/src/check.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Check failure on line 124 in main/src/check.rs

View workflow job for this annotation

GitHub Actions / clippy

cannot move out of `self.common_cfg.features` which is behind a shared reference

error[E0507]: cannot move out of `self.common_cfg.features` which is behind a shared reference --> main/src/check.rs:124:24 | 124 | cfg.features = self.common_cfg.features; | ^^^^^^^^^^^^^^^^^^^^^^^^ move occurs because `self.common_cfg.features` has type `std::option::Option<std::string::String>`, which does not implement the `Copy` trait | help: consider cloning the value if the performance cost is acceptable | 124 | cfg.features = self.common_cfg.features.clone(); | ++++++++
let wasm = project::build_dylib(cfg.clone())?;
let project_hash =
project::hash_project(self.common_cfg.source_files_for_project_hash.clone(), cfg)?;
Expand Down
5 changes: 4 additions & 1 deletion main/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,9 @@ struct CommonConfig {
#[arg(long)]
/// Optional max fee per gas in gwei units.
max_fee_per_gas_gwei: Option<u128>,
/// Specifies the features to use when building the Stylus binary.
#[arg(long)]
features: Option<String>,
}

#[derive(Subcommand, Clone, Debug)]
Expand Down Expand Up @@ -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)?;

Expand Down
5 changes: 5 additions & 0 deletions main/src/project.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ pub enum OptLevel {
pub struct BuildConfig {
pub opt_level: OptLevel,
pub stable: bool,
pub features: Option<String>,
}

impl BuildConfig {
Expand Down Expand Up @@ -74,6 +75,10 @@ pub fn build_dylib(cfg: BuildConfig) -> Result<PathBuf> {
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");
Expand Down
1 change: 1 addition & 0 deletions main/src/verify.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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}"))?;
Expand Down

0 comments on commit da7f1b1

Please sign in to comment.