Commit 7948d23b authored by Hero Bird's avatar Hero Bird Committed by GitHub

Make std crate feature default for all ink crates (#146)

* make std crate feature default for all ink crates

* adjust travis CI for builds without std feature enabled

* remove incorrect usages of ink_abi

* apply rustfmt

* remove invalid type-metadata dependencies for ink_core

* [lang] fix Cargo.toml indentations

* adjust Erc20 token examples for new std crate feature

* adjust template and lang example std feature and propagation
parent 7d19156e
......@@ -60,9 +60,11 @@ before_script:
script:
- |
cargo check --verbose --all --all-features &&
cargo fmt --verbose --all -- --check
cargo check --verbose --all --no-default-features &&
cargo fmt --verbose --all -- --check &&
cargo clippy --verbose --all --all-features -- -D warnings &&
cargo clippy --verbose --all --no-default-features -- -D warnings &&
cargo test --verbose --all --all-features &&
cargo kcov --verbose --coveralls --all --no-clean-rebuild &&
cargo build --verbose --all --release --target=wasm32-unknown-unknown &&
cargo build --verbose --all --no-default-features --release --target=wasm32-unknown-unknown &&
bash <(curl -s https://codecov.io/bash)
......@@ -21,5 +21,5 @@ include = ["/Cargo.toml", "src/**/*.rs", "/README.md", "/LICENSE"]
wee_alloc = { version = "0.4", default-features = false }
[features]
default = []
default = ["std"]
std = []
......@@ -15,13 +15,7 @@
// along with ink!. If not, see <http://www.gnu.org/licenses/>.
#![cfg_attr(not(feature = "std"), no_std)]
#![cfg_attr(
not(feature = "std"),
feature(
alloc_error_handler,
core_intrinsics,
)
)]
#![cfg_attr(not(feature = "std"), feature(alloc_error_handler, core_intrinsics,))]
// Use `wee_alloc` as the global allocator.
#[cfg(not(feature = "std"))]
......
......@@ -5,9 +5,9 @@ authors = ["[your_name] <[your_email]>"]
edition = "2018"
[dependencies]
ink_core = { git = "https://github.com/paritytech/ink", package = "ink_core" }
ink_model = { git = "https://github.com/paritytech/ink", package = "ink_model" }
ink_lang = { git = "https://github.com/paritytech/ink", package = "ink_lang" }
ink_core = { git = "https://github.com/paritytech/ink", package = "ink_core", default-features = false }
ink_model = { git = "https://github.com/paritytech/ink", package = "ink_model", default-features = false }
ink_lang = { git = "https://github.com/paritytech/ink", package = "ink_lang", default-features = false }
parity-codec = { version = "3.3", default-features = false, features = ["derive"] }
[lib]
......@@ -15,8 +15,15 @@ name = "{{name}}"
crate-type = ["cdylib"]
[features]
default = []
default = ["std"]
std = [
"ink_core/std",
"ink_model/std",
"ink_lang/std",
"parity-codec/std",
]
test-env = [
"std",
"ink_core/test-env",
"ink_model/test-env",
"ink_lang/test-env",
......
......@@ -7,7 +7,7 @@ PROJNAME={{name}}
# rm Cargo.lock
CARGO_INCREMENTAL=0 &&
cargo build --release --features generate-api-description --target=wasm32-unknown-unknown --verbose
cargo build --no-default-features --release --features generate-api-description --target=wasm32-unknown-unknown --verbose
wasm2wat -o target/$PROJNAME.wat target/wasm32-unknown-unknown/release/$PROJNAME.wasm
cat target/$PROJNAME.wat | sed "s/(import \"env\" \"memory\" (memory (;0;) 2))/(import \"env\" \"memory\" (memory (;0;) 2 16))/" > target/$PROJNAME-fixed.wat
wat2wasm -o target/$PROJNAME.wasm target/$PROJNAME-fixed.wat
......
......@@ -18,14 +18,15 @@ categories = ["no-std", "embedded"]
include = ["/Cargo.toml", "src/**/*.rs", "/README.md", "/LICENSE"]
[dependencies]
ink_alloc = { path = "../alloc/" }
ink_utils = { path = "../utils/" }
parity-codec = { version = "3.2", default-features = false, features = ["derive", "full"] }
ink_alloc = { path = "../alloc/", default-features = false }
ink_utils = { path = "../utils/", default-features = false }
parity-codec = { version = "4.1", default-features = false, features = ["derive", "full"] }
[features]
default = []
default = ["std"]
test-env = ["std"]
std = [
"ink_alloc/std",
"ink_utils/std",
"parity-codec/std",
]
......@@ -5,16 +5,23 @@ authors = ["Parity Technologies <admin@parity.io>"]
edition = "2018"
[dependencies]
ink_core = { path = "../../../core" }
parity-codec = { version = "3.2", default-features = false, features = ["derive"] }
ink_core = { path = "../../../core", default-features = false }
parity-codec = { version = "4.1", default-features = false, features = ["derive"] }
[lib]
name = "erc20"
crate-type = ["cdylib"]
[features]
default = []
test-env = ["ink_core/test-env"]
default = ["std"]
std = [
"ink_core/std",
"parity-codec/std",
]
test-env = [
"std",
"ink_core/test-env",
]
[profile.release]
panic = "abort"
......
......@@ -5,10 +5,10 @@ authors = ["Parity Technologies <admin@parity.io>"]
edition = "2018"
[dependencies]
ink_core = { path = "../../../core" }
ink_model = { path = "../../../model" }
ink_lang = { path = "../../../lang" }
parity-codec = { version = "3.2", default-features = false, features = ["derive"] }
ink_core = { path = "../../../core", default-features = false }
ink_model = { path = "../../../model", default-features = false }
ink_lang = { path = "../../../lang", default-features = false }
parity-codec = { version = "4.1", default-features = false, features = ["derive"] }
[lib]
name = "erc20"
......@@ -16,11 +16,19 @@ crate-type = ["cdylib"]
[features]
default = [
"std",
"ink_lang/generate-api-description"
]
std = [
"ink_core/std",
"ink_model/std",
"ink_lang/std",
"parity-codec/std",
]
test-env = [
"ink_core/test-env",
"ink_model/test-env",
"std",
"ink_core/test-env",
"ink_model/test-env",
"ink_lang/test-env",
]
generate-api-description = [
......@@ -30,5 +38,5 @@ generate-api-description = [
[profile.release]
panic = "abort"
lto = true
# debug = true
opt-level = "z"
# debug = true
......@@ -7,7 +7,7 @@ PROJNAME=erc20
# cargo clean
# rm Cargo.lock
CARGO_INCREMENTAL=0 cargo build --release --features generate-api-description --target=wasm32-unknown-unknown --verbose
CARGO_INCREMENTAL=0 cargo build --no-default-features --release --features generate-api-description --target=wasm32-unknown-unknown --verbose
wasm2wat -o target/$PROJNAME.wat target/wasm32-unknown-unknown/release/$PROJNAME.wasm
cat target/$PROJNAME.wat | sed "s/(import \"env\" \"memory\" (memory (;0;) 2))/(import \"env\" \"memory\" (memory (;0;) 2 16))/" > target/$PROJNAME-fixed.wat
wat2wasm -o target/$PROJNAME.wasm target/$PROJNAME-fixed.wat
......
......@@ -7,15 +7,21 @@ edition = "2018"
[dependencies]
ink_core = { path = "../../../core" }
ink_model = { path = "../../../model" }
parity-codec = { version = "3.2", default-features = false, features = ["derive"] }
parity-codec = { version = "4.1", default-features = false, features = ["derive"] }
[lib]
name = "erc20"
crate-type = ["cdylib"]
[features]
default = []
default = ["std"]
std = [
"ink_core/std",
"ink_model/std",
"parity-codec/std",
]
test-env = [
"std",
"ink_core/test-env",
"ink_model/test-env",
]
......
......@@ -18,18 +18,18 @@ categories = ["no-std", "embedded"]
include = ["Cargo.toml", "src/**/*.rs", "README.md", "LICENSE"]
[dependencies]
ink_utils = { path = "../utils/" }
ink_model = { path = "../model/" }
parity-codec = { version = "3.2", default-features = false, features = ["derive"] }
ink_utils = { path = "../utils/", default-features = false }
ink_model = { path = "../model/", default-features = false }
parity-codec = { version = "4.1", default-features = false, features = ["derive"] }
quote = "0.6"
syn = { version = "0.15", features = ["parsing", "full", "extra-traits"] }
proc-macro2 = "0.4"
heck = "0.3"
itertools = "0.7"
either = "1.5"
serde = { version = "1.0.89", features = ["derive"] }
serde_json = "1.0.39"
itertools = { version = "0.8", default-features = false }
either = { version = "1.5", default-features = false }
serde = { version = "1.0", default-features = false, features = ["derive"] }
serde_json = "1.0"
[dev-dependencies]
pretty_assertions = "0.6.1"
......@@ -39,10 +39,14 @@ name = "ink_lang"
proc-macro = true
[features]
default = []
default = ["std"]
std = [
"ink_utils/std",
"ink_model/std",
"parity-codec/std",
"itertools/use_std",
"either/use_std",
"serde/std",
]
test-env = [
"ink_model/test-env",
......
......@@ -14,10 +14,16 @@ categories = ["no-std", "embedded"]
include = ["/Cargo.toml", "src/**/*.rs", "/README.md", "/LICENSE"]
[dependencies]
parity-codec = { version = "3.2", default-features = false, features = ["derive", "full"] }
ink_core = { version = "0.1.0", path = "../core" }
ink_core = { path = "../core", default-features = false }
parity-codec = { version = "4.1", default-features = false, features = ["derive", "full"] }
[features]
default = []
test-env = ["std", "ink_core/test-env"]
std = ["ink_core/std"]
default = ["std"]
test-env = [
"std",
"ink_core/test-env",
]
std = [
"ink_core/std",
"parity-codec/std",
]
......@@ -21,5 +21,5 @@ include = ["/Cargo.toml", "src/**/*.rs", "/README.md", "/LICENSE"]
tiny-keccak = "1.4"
[features]
default = []
default = ["std"]
std = []
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment