Skip to content

Throw compiler error if std feature is not enabled #1976

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Dec 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -344,15 +344,15 @@ jobs:
- run:
name: Build library for native target (no features)
working_directory: ~/project/packages/std
command: cargo build --locked --no-default-features
command: cargo build --locked --no-default-features --features std
- run:
name: Build library for wasm target (no features)
working_directory: ~/project/packages/std
command: cargo wasm --locked --no-default-features
command: cargo wasm --locked --no-default-features --features std
- run:
name: Run unit tests (no features)
working_directory: ~/project/packages/std
command: cargo test --locked --no-default-features
command: cargo test --locked --no-default-features --features std
- run:
name: Build library for native target (all features)
working_directory: ~/project/packages/std
Expand Down
2 changes: 1 addition & 1 deletion contracts/cyberpunk/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ cranelift = ["cosmwasm-vm/cranelift"]

[dependencies]
cosmwasm-schema = { path = "../../packages/schema" }
cosmwasm-std = { path = "../../packages/std", default-features = false, features = ["abort", "cosmwasm_1_3"] }
cosmwasm-std = { path = "../../packages/std", default-features = false, features = ["std", "abort", "cosmwasm_1_3"] }
rust-argon2 = "0.8"
thiserror = "1.0.26"

Expand Down
2 changes: 1 addition & 1 deletion contracts/hackatom/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ cranelift = ["cosmwasm-vm/cranelift"]

[dependencies]
cosmwasm-schema = { path = "../../packages/schema" }
cosmwasm-std = { path = "../../packages/std", default-features = false, features = ["abort"] }
cosmwasm-std = { path = "../../packages/std", default-features = false, features = ["std", "abort"] }
schemars = "0.8.3"
serde = { version = "1.0.103", default-features = false, features = ["derive"] }
sha2 = "0.10"
Expand Down
2 changes: 1 addition & 1 deletion contracts/reflect/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ cranelift = ["cosmwasm-vm/cranelift"]

[dependencies]
cosmwasm-schema = { path = "../../packages/schema" }
cosmwasm-std = { path = "../../packages/std", default-features = false, features = ["staking", "stargate", "cosmwasm_1_4"] }
cosmwasm-std = { path = "../../packages/std", default-features = false, features = ["std", "staking", "stargate", "cosmwasm_1_4"] }
schemars = "0.8.3"
serde = { version = "1.0.103", default-features = false, features = ["derive"] }
thiserror = "1.0.26"
Expand Down
2 changes: 1 addition & 1 deletion contracts/staking/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ cranelift = ["cosmwasm-vm/cranelift"]

[dependencies]
cosmwasm-schema = { path = "../../packages/schema" }
cosmwasm-std = { path = "../../packages/std", default-features = false, features = ["staking"] }
cosmwasm-std = { path = "../../packages/std", default-features = false, features = ["std", "staking"] }
schemars = "0.8.3"
serde = { version = "1.0.103", default-features = false, features = ["derive"] }
snafu = "0.6.6"
Expand Down
8 changes: 4 additions & 4 deletions devtools/check_workspace.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@ cargo fmt
cd packages/std
# default, min, all
cargo check
cargo check --no-default-features
cargo check --features abort,iterator,staking,stargate,cosmwasm_1_2
cargo check --no-default-features --features std
cargo check --features std,abort,iterator,staking,stargate,cosmwasm_1_2
cargo wasm-debug
cargo wasm-debug --features iterator,staking,stargate
cargo clippy --all-targets --features iterator,staking,stargate -- -D warnings
cargo wasm-debug --features std,iterator,staking,stargate
cargo clippy --all-targets --features std,iterator,staking,stargate -- -D warnings
)
(cd packages/schema && cargo build && cargo clippy --all-targets -- -D warnings)
(cd packages/schema-derive && cargo build && cargo clippy --all-targets -- -D warnings)
Expand Down
7 changes: 7 additions & 0 deletions packages/std/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
extern crate alloc;

#[cfg(not(feature = "std"))]
core::compile_error!(
r#"Please enable `cosmwasm-std`'s `std` feature, as we might move existing functionality to that feature in the future.
Builds without the std feature are currently not expected to work. If you need no_std support see #1484.
"#
);

// Exposed on all platforms

mod addresses;
Expand Down
2 changes: 1 addition & 1 deletion packages/vm/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ clru = "0.6.1"
crc32fast = "1.3.2"
bech32 = "0.9.1"
# Uses the path when built locally; uses the given version from crates.io when published
cosmwasm-std = { path = "../std", version = "1.5.0", default-features = false }
cosmwasm-std = { path = "../std", version = "1.5.0", default-features = false, features = ["std"] }
cosmwasm-crypto = { path = "../crypto", version = "1.5.0" }
derivative = "2"
hex = "0.4"
Expand Down