Skip to content

Commit

Permalink
Remove option to use wasm-opt CLI
Browse files Browse the repository at this point in the history
  • Loading branch information
brson committed Oct 4, 2022
1 parent 91b6dc5 commit bf32d90
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 327 deletions.
12 changes: 6 additions & 6 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 2 additions & 4 deletions crates/cargo-contract/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,7 @@ serde_json = "1.0.85"
tempfile = "3.3.0"
url = { version = "2.3.1", features = ["serde"] }
impl-serde = "0.4.0"
regex = "1.6.0"
wasm-opt = { version = "0.110.0", optional = true }
wasm-opt = "0.110.0"

# dependencies for extrinsics (deploying and calling a contract)
async-std = { version = "1.12.0", features = ["attributes", "tokio1"] }
Expand Down Expand Up @@ -71,9 +70,8 @@ predicates = "2.1.1"
[features]
# This `std` feature is required for testing using an inline contract's metadata, because `ink!` annotates the metadata
# generation code with `#[cfg(feature = "std")]`.
default = ["std", "integrated-wasm-opt"]
default = ["std"]
std = []
integrated-wasm-opt = ["wasm-opt"]

# Enable this to execute long running tests, which usually are only run on the CI server
#
Expand Down
23 changes: 23 additions & 0 deletions crates/cargo-contract/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ use std::{
str::FromStr,
};

use ::wasm_opt::OptimizationOptions;
use anyhow::{
anyhow,
Error,
Expand All @@ -71,6 +72,12 @@ use assert_cmd as _;
#[cfg(test)]
use predicates as _;

#[cfg(test)]
use regex as _;

// Only used on windows.
use which as _;

#[derive(Debug, Parser)]
#[clap(bin_name = "cargo")]
#[clap(version = env!("CARGO_CONTRACT_CLI_IMPL_VERSION"))]
Expand Down Expand Up @@ -158,6 +165,22 @@ impl From<String> for OptimizationPasses {
}
}

impl From<OptimizationPasses> for OptimizationOptions {
fn from(passes: OptimizationPasses) -> OptimizationOptions {
match passes {
OptimizationPasses::Zero => OptimizationOptions::new_opt_level_0(),
OptimizationPasses::One => OptimizationOptions::new_opt_level_1(),
OptimizationPasses::Two => OptimizationOptions::new_opt_level_2(),
OptimizationPasses::Three => OptimizationOptions::new_opt_level_3(),
OptimizationPasses::Four => OptimizationOptions::new_opt_level_4(),
OptimizationPasses::S => OptimizationOptions::new_optimize_for_size(),
OptimizationPasses::Z => {
OptimizationOptions::new_optimize_for_size_aggressively()
}
}
}
}

#[derive(Default, Clone, Debug, Args)]
pub struct VerbosityFlags {
/// No output printed to stdout
Expand Down
Loading

0 comments on commit bf32d90

Please sign in to comment.