From 03c16dc3fb0694a1079d05950f85808700a33d77 Mon Sep 17 00:00:00 2001 From: Andrew Jones Date: Mon, 15 Jun 2020 12:14:20 +0100 Subject: [PATCH 01/11] Add preferred defaults to `[profile.release]` section --- Cargo.lock | 38 +++++++++ Cargo.toml | 1 + src/workspace.rs | 198 +++++++++++++++++++++++++++++++++++++++++++++-- 3 files changed, 230 insertions(+), 7 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index f5f93434..5aa64b12 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -304,6 +304,7 @@ dependencies = [ "log", "parity-scale-codec", "parity-wasm", + "pretty_assertions", "pwasm-utils", "rustc_version", "serde_json", @@ -513,6 +514,16 @@ dependencies = [ "subtle 1.0.0", ] +[[package]] +name = "ctor" +version = "0.1.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "39858aa5bac06462d4dd4b9164848eb81ffc4aa5c479746393598fd193afa227" +dependencies = [ + "quote", + "syn", +] + [[package]] name = "curve25519-dalek" version = "2.0.0" @@ -537,6 +548,12 @@ dependencies = [ "syn", ] +[[package]] +name = "difference" +version = "2.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "524cbf6897b527295dff137cec09ecf3a05f4fddffd7dfcd1585403449e74198" + [[package]] name = "digest" version = "0.8.1" @@ -1545,6 +1562,15 @@ version = "0.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2839e79665f131bdb5782e51f2c6c9599c133c6098982a54c794358bf432529c" +[[package]] +name = "output_vt100" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "53cdc5b785b7a58c5aad8216b3dfa114df64b0b06ae6e1501cef91df2fbdf8f9" +dependencies = [ + "winapi 0.3.8", +] + [[package]] name = "pallet-indices" version = "2.0.0-alpha.7" @@ -1756,6 +1782,18 @@ version = "0.2.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "74490b50b9fbe561ac330df47c08f3f33073d2d00c150f719147d7c54522fa1b" +[[package]] +name = "pretty_assertions" +version = "0.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3f81e1644e1b54f5a68959a29aa86cde704219254669da328ecfdf6a1f09d427" +dependencies = [ + "ansi_term", + "ctor", + "difference", + "output_vt100", +] + [[package]] name = "primitive-types" version = "0.7.2" diff --git a/Cargo.toml b/Cargo.toml index 025704ae..2fd654f5 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -49,6 +49,7 @@ walkdir = "2.3.1" [dev-dependencies] assert_matches = "1.3.0" +pretty_assertions = "0.6.1" wabt = "0.9.2" [features] diff --git a/src/workspace.rs b/src/workspace.rs index 1aa70865..734521e3 100644 --- a/src/workspace.rs +++ b/src/workspace.rs @@ -92,7 +92,7 @@ pub struct Manifest { } impl Manifest { - /// Create new CargoToml for the given manifest path. + /// Create new Manifest for the given manifest path. /// /// The path *must* be to a `Cargo.toml`. pub fn new

(path: P) -> Result @@ -137,6 +137,27 @@ impl Manifest { /// Set `[profile.release]` lto flag pub fn with_profile_release_lto(&mut self, enabled: bool) -> Result<&mut Self> { + let lto = self.get_profile_release_table_mut()? + .entry("lto") + .or_insert(enabled.into()); + *lto = enabled.into(); + Ok(self) + } + + /// Set preferred defaults for the `[profile.release]` section + /// + /// # Note + /// + /// Existing user defined settings for this section are preserved. Only if a setting is not + /// defined is the preferred default set. + pub fn with_profile_release_defaults(&mut self, defaults: Profile) -> Result<&mut Self> { + let profile_release = self.get_profile_release_table_mut()?; + defaults.merge(profile_release); + Ok(self) + } + + /// Get mutable reference to `[profile.release]` section + fn get_profile_release_table_mut(&mut self) -> Result<&mut value::Table> { let profile = self .toml .entry("profile") @@ -146,13 +167,9 @@ impl Manifest { .ok_or(anyhow::anyhow!("profile should be a table"))? .entry("release") .or_insert(value::Value::Table(Default::default())); - let lto = release + release .as_table_mut() - .ok_or(anyhow::anyhow!("release should be a table"))? - .entry("lto") - .or_insert(enabled.into()); - *lto = enabled.into(); - Ok(self) + .ok_or(anyhow::anyhow!("release should be a table")) } /// Remove a value from the `[lib] crate-types = []` section @@ -411,3 +428,170 @@ impl Workspace { f(root_manifest_path) } } + +/// Subset of cargo profile settings to configure defaults for building contracts +pub struct Profile { + opt_level: OptLevel, + lto: Lto, + // `None` means use rustc default. + codegen_units: Option, + overflow_checks: bool, + panic: PanicStrategy, +} + +impl Default for Profile { + fn default() -> Profile { + Profile { + opt_level: OptLevel::One, + lto: Lto::Bool(false), + codegen_units: None, + overflow_checks: false, + panic: PanicStrategy::Unwind, + } + } +} + +impl Profile { + /// The preferred set of defaults for compiling a release build of a contract + fn default_contract_build_release() -> Profile { + Profile { + opt_level: OptLevel::Z, + lto: Lto::Bool(true), + codegen_units: Some(1), + overflow_checks: true, + panic: PanicStrategy::Abort, + } + } + + /// Set any unset profile settings from the config. + /// + /// Therefore: + /// - If the user has explicitly defined a profile setting, it will not be overwritten. + /// - If a profile setting is not defined, the value from this profile instance will be added + fn merge(&self, profile: &mut value::Table) { + let mut set_value_if_vacant = |key: &'static str, value: value::Value| { + if !profile.contains_key(key) { + profile.insert(key.into(), value); + } + }; + set_value_if_vacant("opt-level", self.opt_level.to_toml_value()); + set_value_if_vacant("lto", self.lto.to_toml_value()); + if let Some(codegen_units) = self.codegen_units { + set_value_if_vacant("codegen-units", codegen_units.into()); + } + set_value_if_vacant("overflow-checks", self.overflow_checks.into()); + set_value_if_vacant("panic", self.panic.to_toml_value()); + } +} + +/// The [`opt-level`](https://doc.rust-lang.org/cargo/reference/profiles.html#opt-level) setting +#[derive(Clone, Copy, PartialEq, Eq, Debug, Hash, PartialOrd, Ord)] +#[allow(unused)] +pub enum OptLevel { + Zero, + One, + Two, + Three, + S, + Z, +} + +impl OptLevel { + fn to_toml_value(&self) -> value::Value { + match self { + OptLevel::Zero => 0.into(), + OptLevel::One => 1.into(), + OptLevel::Two => 2.into(), + OptLevel::Three => 3.into(), + OptLevel::S => "s".into(), + OptLevel::Z => "z".into(), + } + } +} + +/// The [`link-time-optimization`](https://doc.rust-lang.org/cargo/reference/profiles.html#lto) setting. +#[derive(Clone, Copy, PartialEq, Eq, Debug, Hash, PartialOrd, Ord)] +pub enum Lto { + /// False = no LTO + /// True = "Fat" LTO + Bool(bool), + /// Named LTO settings like "thin". + #[allow(unused)] + Named(&'static str), +} + +impl Lto { + fn to_toml_value(&self) -> value::Value { + match self { + Lto::Bool(b) => value::Value::Boolean(*b), + Lto::Named(n) => value::Value::String(n.to_string()), + } + } +} + +/// The `panic` setting. +#[derive(Clone, Copy, PartialEq, Eq, Debug, Hash, PartialOrd, Ord)] +pub enum PanicStrategy { + Unwind, + Abort, +} + +impl PanicStrategy { + fn to_toml_value(&self) -> value::Value { + match self { + PanicStrategy::Unwind => "unwind".into(), + PanicStrategy::Abort => "abort".into(), + } + } +} + +#[cfg(test)] +mod tests { + use super::*; + use pretty_assertions::assert_eq; + + #[test] + fn merge_profile_inserts_preferred_defaults() { + let profile = Profile::default_contract_build_release(); + + // no `[profile.release]` section specified + let manifest_toml = ""; + let mut expected = toml::value::Table::new(); + expected.insert("opt-level".into(), value::Value::String("z".into())); + expected.insert("lto".into(), value::Value::Boolean(true)); + expected.insert("codegen-units".into(), value::Value::Integer(1)); + expected.insert("overflow-checks".into(), value::Value::Boolean(true)); + expected.insert("panic".into(), value::Value::String("abort".into())); + + let mut manifest_profile = toml::from_str(manifest_toml).unwrap(); + + profile.merge(&mut manifest_profile); + + assert_eq!(expected, manifest_profile) + } + + #[test] + fn merge_profile_preserves_user_defined_settings() { + let profile = Profile::default_contract_build_release(); + + let manifest_toml = r#" +panic = "unwind" +lto = false +opt-level = 3 +overflow-checks = false +codegen-units = 256 + "#; + let mut expected = toml::value::Table::new(); + expected.insert("opt-level".into(), value::Value::Integer(3)); + expected.insert("lto".into(), value::Value::Boolean(false)); + expected.insert("codegen-units".into(), value::Value::Integer(256)); + expected.insert("overflow-checks".into(), value::Value::Boolean(false)); + expected.insert("panic".into(), value::Value::String("unwind".into())); + + let mut manifest_profile = toml::from_str(manifest_toml).unwrap(); + + profile.merge(&mut manifest_profile); + + assert_eq!(expected, manifest_profile) + } +} -- GitLab From fcb82de6d202905fd4b242c1c3e59dc0eaa143a0 Mon Sep 17 00:00:00 2001 From: Andrew Jones Date: Mon, 15 Jun 2020 12:17:41 +0100 Subject: [PATCH 02/11] Add preferred profile.release defaults for contract build --- src/cmd/build.rs | 4 ++-- src/workspace.rs | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/cmd/build.rs b/src/cmd/build.rs index ef100e4f..83bc6228 100644 --- a/src/cmd/build.rs +++ b/src/cmd/build.rs @@ -23,7 +23,7 @@ use std::{ use crate::{ util, - workspace::{ManifestPath, Workspace}, + workspace::{ManifestPath, Workspace, Profile}, UnstableFlags, Verbosity, }; use anyhow::{Context, Result}; @@ -160,7 +160,7 @@ fn build_cargo_project( .with_root_package_manifest(|manifest| { manifest .with_removed_crate_type("rlib")? - .with_profile_release_lto(true)?; + .with_profile_release_defaults(Profile::default_contract_release())?; Ok(()) })? .using_temp(xbuild)?; diff --git a/src/workspace.rs b/src/workspace.rs index 734521e3..ccaee497 100644 --- a/src/workspace.rs +++ b/src/workspace.rs @@ -453,7 +453,7 @@ impl Default for Profile { impl Profile { /// The preferred set of defaults for compiling a release build of a contract - fn default_contract_build_release() -> Profile { + pub fn default_contract_release() -> Profile { Profile { opt_level: OptLevel::Z, lto: Lto::Bool(true), @@ -552,7 +552,7 @@ mod tests { #[test] fn merge_profile_inserts_preferred_defaults() { - let profile = Profile::default_contract_build_release(); + let profile = Profile::default_contract_release(); // no `[profile.release]` section specified let manifest_toml = ""; @@ -572,7 +572,7 @@ mod tests { #[test] fn merge_profile_preserves_user_defined_settings() { - let profile = Profile::default_contract_build_release(); + let profile = Profile::default_contract_release(); let manifest_toml = r#" panic = "unwind" -- GitLab From 417ee601f03d28594deee6eeea9550b03ec83429 Mon Sep 17 00:00:00 2001 From: Andrew Jones Date: Mon, 15 Jun 2020 12:20:39 +0100 Subject: [PATCH 03/11] Remove [release.profile] section, update to scale-info release --- template/_Cargo.toml | 14 +------------- 1 file changed, 1 insertion(+), 13 deletions(-) diff --git a/template/_Cargo.toml b/template/_Cargo.toml index 12515285..4b97d22b 100644 --- a/template/_Cargo.toml +++ b/template/_Cargo.toml @@ -11,13 +11,7 @@ ink_core = { version = "2", git = "https://github.com/paritytech/ink", tag = "la ink_lang = { version = "2", git = "https://github.com/paritytech/ink", tag = "latest-v2", package = "ink_lang", default-features = false } scale = { package = "parity-scale-codec", version = "1.2", default-features = false, features = ["derive"] } - -[dependencies.type-metadata] -git = "https://github.com/type-metadata/type-metadata.git" -rev = "02eae9f35c40c943b56af5b60616219f2b72b47d" -default-features = false -features = ["derive"] -optional = true +scale-info = { version = "0.1", default-features = false, features = ["derive"], optional = true } [lib] name = "{{name}}" @@ -52,12 +46,6 @@ ink-generate-abi = [ ] ink-as-dependency = [] -[profile.release] -panic = "abort" -lto = true -opt-level = "z" -overflow-checks = true - [workspace] members = [ ".ink/abi_gen" -- GitLab From 37fdc28dbf30f64c396dc2d9e07f550cb366b1bb Mon Sep 17 00:00:00 2001 From: Andrew Jones Date: Mon, 15 Jun 2020 12:38:21 +0100 Subject: [PATCH 04/11] Fmt --- src/cmd/build.rs | 7 +++++-- src/workspace.rs | 3 ++- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/src/cmd/build.rs b/src/cmd/build.rs index 83bc6228..64984d68 100644 --- a/src/cmd/build.rs +++ b/src/cmd/build.rs @@ -23,7 +23,7 @@ use std::{ use crate::{ util, - workspace::{ManifestPath, Workspace, Profile}, + workspace::{ManifestPath, Profile, Workspace}, UnstableFlags, Verbosity, }; use anyhow::{Context, Result}; @@ -100,7 +100,10 @@ pub fn collect_crate_metadata(manifest_path: &ManifestPath) -> Result, diff --git a/src/workspace.rs b/src/workspace.rs index ccaee497..a469024c 100644 --- a/src/workspace.rs +++ b/src/workspace.rs @@ -137,7 +137,8 @@ impl Manifest { /// Set `[profile.release]` lto flag pub fn with_profile_release_lto(&mut self, enabled: bool) -> Result<&mut Self> { - let lto = self.get_profile_release_table_mut()? + let lto = self + .get_profile_release_table_mut()? .entry("lto") .or_insert(enabled.into()); *lto = enabled.into(); -- GitLab From 1df406b4239cf0a445f4a5d38398958e89dec388 Mon Sep 17 00:00:00 2001 From: Andrew Jones Date: Mon, 15 Jun 2020 13:24:18 +0100 Subject: [PATCH 05/11] Fix remaining type-metadata reference in template --- template/_Cargo.toml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/template/_Cargo.toml b/template/_Cargo.toml index 4b97d22b..289ece2f 100644 --- a/template/_Cargo.toml +++ b/template/_Cargo.toml @@ -31,7 +31,7 @@ std = [ "ink_core/std", "ink_primitives/std", "scale/std", - "type-metadata/std", + "scale-info/std", ] test-env = [ "std", @@ -40,7 +40,7 @@ test-env = [ ink-generate-abi = [ "std", "ink_abi", - "type-metadata", + "scale-info", "ink_core/ink-generate-abi", "ink_lang/ink-generate-abi", ] -- GitLab From a5ec70eb6d305efd5bb6860253798f91c714351d Mon Sep 17 00:00:00 2001 From: Andrew Jones Date: Mon, 15 Jun 2020 13:43:18 +0100 Subject: [PATCH 06/11] Remove unused default impl of Profile --- src/workspace.rs | 13 +------------ 1 file changed, 1 insertion(+), 12 deletions(-) diff --git a/src/workspace.rs b/src/workspace.rs index a469024c..7a25dab3 100644 --- a/src/workspace.rs +++ b/src/workspace.rs @@ -440,18 +440,6 @@ pub struct Profile { panic: PanicStrategy, } -impl Default for Profile { - fn default() -> Profile { - Profile { - opt_level: OptLevel::One, - lto: Lto::Bool(false), - codegen_units: None, - overflow_checks: false, - panic: PanicStrategy::Unwind, - } - } -} - impl Profile { /// The preferred set of defaults for compiling a release build of a contract pub fn default_contract_release() -> Profile { @@ -532,6 +520,7 @@ impl Lto { /// The `panic` setting. #[derive(Clone, Copy, PartialEq, Eq, Debug, Hash, PartialOrd, Ord)] +#[allow(unused)] pub enum PanicStrategy { Unwind, Abort, -- GitLab From 95f56cc5b9a896014f850d5ba80dafcfe03398c8 Mon Sep 17 00:00:00 2001 From: Andrew Jones Date: Mon, 15 Jun 2020 13:55:24 +0100 Subject: [PATCH 07/11] OptLevel refactoring --- src/workspace.rs | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/src/workspace.rs b/src/workspace.rs index 7a25dab3..b6250e0f 100644 --- a/src/workspace.rs +++ b/src/workspace.rs @@ -432,7 +432,7 @@ impl Workspace { /// Subset of cargo profile settings to configure defaults for building contracts pub struct Profile { - opt_level: OptLevel, + opt_level: Option, lto: Lto, // `None` means use rustc default. codegen_units: Option, @@ -444,7 +444,7 @@ impl Profile { /// The preferred set of defaults for compiling a release build of a contract pub fn default_contract_release() -> Profile { Profile { - opt_level: OptLevel::Z, + opt_level: Some(OptLevel::Z), lto: Lto::Bool(true), codegen_units: Some(1), overflow_checks: true, @@ -463,7 +463,9 @@ impl Profile { profile.insert(key.into(), value); } }; - set_value_if_vacant("opt-level", self.opt_level.to_toml_value()); + if let Some(opt_level) = self.opt_level { + set_value_if_vacant("opt-level", opt_level.to_toml_value()); + } set_value_if_vacant("lto", self.lto.to_toml_value()); if let Some(codegen_units) = self.codegen_units { set_value_if_vacant("codegen-units", codegen_units.into()); @@ -474,13 +476,12 @@ impl Profile { } /// The [`opt-level`](https://doc.rust-lang.org/cargo/reference/profiles.html#opt-level) setting -#[derive(Clone, Copy, PartialEq, Eq, Debug, Hash, PartialOrd, Ord)] #[allow(unused)] +#[derive(Clone, Copy)] pub enum OptLevel { - Zero, - One, - Two, - Three, + O1, + O2, + O3, S, Z, } @@ -488,10 +489,9 @@ pub enum OptLevel { impl OptLevel { fn to_toml_value(&self) -> value::Value { match self { - OptLevel::Zero => 0.into(), - OptLevel::One => 1.into(), - OptLevel::Two => 2.into(), - OptLevel::Three => 3.into(), + OptLevel::O1 => 1.into(), + OptLevel::O2 => 2.into(), + OptLevel::O3 => 3.into(), OptLevel::S => "s".into(), OptLevel::Z => "z".into(), } -- GitLab From d4771fe6c246281c517c54f818994516e307d7d0 Mon Sep 17 00:00:00 2001 From: Andrew Jones Date: Mon, 15 Jun 2020 13:56:37 +0100 Subject: [PATCH 08/11] Indent test toml for readability --- src/workspace.rs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/workspace.rs b/src/workspace.rs index b6250e0f..e04ee697 100644 --- a/src/workspace.rs +++ b/src/workspace.rs @@ -565,11 +565,11 @@ mod tests { let profile = Profile::default_contract_release(); let manifest_toml = r#" -panic = "unwind" -lto = false -opt-level = 3 -overflow-checks = false -codegen-units = 256 + panic = "unwind" + lto = false + opt-level = 3 + overflow-checks = false + codegen-units = 256 "#; let mut expected = toml::value::Table::new(); expected.insert("opt-level".into(), value::Value::Integer(3)); -- GitLab From 2814f4872bcdc4816cff8ceb698e958576167fd2 Mon Sep 17 00:00:00 2001 From: Andrew Jones Date: Mon, 15 Jun 2020 14:13:17 +0100 Subject: [PATCH 09/11] Specify exact Lto values --- src/workspace.rs | 27 ++++++++++++++++----------- 1 file changed, 16 insertions(+), 11 deletions(-) diff --git a/src/workspace.rs b/src/workspace.rs index e04ee697..a6589899 100644 --- a/src/workspace.rs +++ b/src/workspace.rs @@ -445,7 +445,7 @@ impl Profile { pub fn default_contract_release() -> Profile { Profile { opt_level: Some(OptLevel::Z), - lto: Lto::Bool(true), + lto: Lto::Fat, codegen_units: Some(1), overflow_checks: true, panic: PanicStrategy::Abort, @@ -499,21 +499,26 @@ impl OptLevel { } /// The [`link-time-optimization`](https://doc.rust-lang.org/cargo/reference/profiles.html#lto) setting. -#[derive(Clone, Copy, PartialEq, Eq, Debug, Hash, PartialOrd, Ord)] +#[derive(Clone, Copy)] +#[allow(unused)] pub enum Lto { - /// False = no LTO - /// True = "Fat" LTO - Bool(bool), - /// Named LTO settings like "thin". - #[allow(unused)] - Named(&'static str), + /// Sets `lto = false` + ThinLocal, + /// Sets `lto = "fat"`, the equivalent of `lto = true` + Fat, + /// Sets `lto = "thin"` + Thin, + /// Sets `lto = "off"` + Off, } impl Lto { fn to_toml_value(&self) -> value::Value { match self { - Lto::Bool(b) => value::Value::Boolean(*b), - Lto::Named(n) => value::Value::String(n.to_string()), + Lto::ThinLocal => value::Value::Boolean(false), + Lto::Fat => value::Value::String("fat".into()), + Lto::Thin => value::Value::String("thin".into()), + Lto::Off => value::Value::String("off".into()), } } } @@ -548,7 +553,7 @@ mod tests { let manifest_toml = ""; let mut expected = toml::value::Table::new(); expected.insert("opt-level".into(), value::Value::String("z".into())); - expected.insert("lto".into(), value::Value::Boolean(true)); + expected.insert("lto".into(), value::Value::String("fat".into())); expected.insert("codegen-units".into(), value::Value::Integer(1)); expected.insert("overflow-checks".into(), value::Value::Boolean(true)); expected.insert("panic".into(), value::Value::String("abort".into())); -- GitLab From 08fabe2f97b8ea7d2ecd70f151b3621ec3ed319c Mon Sep 17 00:00:00 2001 From: Andrew Jones Date: Mon, 15 Jun 2020 14:33:09 +0100 Subject: [PATCH 10/11] Make OptLevel consistent with Lto (no option) --- src/workspace.rs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/workspace.rs b/src/workspace.rs index a6589899..51ad47f3 100644 --- a/src/workspace.rs +++ b/src/workspace.rs @@ -432,7 +432,7 @@ impl Workspace { /// Subset of cargo profile settings to configure defaults for building contracts pub struct Profile { - opt_level: Option, + opt_level: OptLevel, lto: Lto, // `None` means use rustc default. codegen_units: Option, @@ -444,7 +444,7 @@ impl Profile { /// The preferred set of defaults for compiling a release build of a contract pub fn default_contract_release() -> Profile { Profile { - opt_level: Some(OptLevel::Z), + opt_level: OptLevel::Z, lto: Lto::Fat, codegen_units: Some(1), overflow_checks: true, @@ -463,9 +463,7 @@ impl Profile { profile.insert(key.into(), value); } }; - if let Some(opt_level) = self.opt_level { - set_value_if_vacant("opt-level", opt_level.to_toml_value()); - } + set_value_if_vacant("opt-level", self.opt_level.to_toml_value()); set_value_if_vacant("lto", self.lto.to_toml_value()); if let Some(codegen_units) = self.codegen_units { set_value_if_vacant("codegen-units", codegen_units.into()); @@ -479,6 +477,7 @@ impl Profile { #[allow(unused)] #[derive(Clone, Copy)] pub enum OptLevel { + NoOptimizations, O1, O2, O3, @@ -489,6 +488,7 @@ pub enum OptLevel { impl OptLevel { fn to_toml_value(&self) -> value::Value { match self { + OptLevel::NoOptimizations => 0.into(), OptLevel::O1 => 1.into(), OptLevel::O2 => 2.into(), OptLevel::O3 => 3.into(), -- GitLab From ba24bd5b304b44617fe26e953b4f5c2be0332851 Mon Sep 17 00:00:00 2001 From: Andrew Jones Date: Mon, 15 Jun 2020 14:41:53 +0100 Subject: [PATCH 11/11] Revert to using type-metadata until ink! 3.0 release --- template/_Cargo.toml | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/template/_Cargo.toml b/template/_Cargo.toml index 289ece2f..a343b237 100644 --- a/template/_Cargo.toml +++ b/template/_Cargo.toml @@ -11,7 +11,13 @@ ink_core = { version = "2", git = "https://github.com/paritytech/ink", tag = "la ink_lang = { version = "2", git = "https://github.com/paritytech/ink", tag = "latest-v2", package = "ink_lang", default-features = false } scale = { package = "parity-scale-codec", version = "1.2", default-features = false, features = ["derive"] } -scale-info = { version = "0.1", default-features = false, features = ["derive"], optional = true } + +[dependencies.type-metadata] +git = "https://github.com/type-metadata/type-metadata.git" +rev = "02eae9f35c40c943b56af5b60616219f2b72b47d" +default-features = false +features = ["derive"] +optional = true [lib] name = "{{name}}" @@ -31,7 +37,7 @@ std = [ "ink_core/std", "ink_primitives/std", "scale/std", - "scale-info/std", + "type-metadata/std", ] test-env = [ "std", @@ -40,7 +46,7 @@ test-env = [ ink-generate-abi = [ "std", "ink_abi", - "scale-info", + "type-metadata", "ink_core/ink-generate-abi", "ink_lang/ink-generate-abi", ] -- GitLab