Skip to content

Commit 96c7944

Browse files
committed
Fix CI for no_std
Signed-off-by: aeryz <[email protected]>
1 parent 4daa719 commit 96c7944

File tree

5 files changed

+31
-24
lines changed

5 files changed

+31
-24
lines changed

.circleci/config.yml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -268,21 +268,21 @@ jobs:
268268
working_directory: ~/project/packages/std
269269
command: cargo wasm --locked --no-default-features
270270
- run:
271-
name: Run unit tests (no features)
271+
name: Run unit tests (only "std" feature)
272272
working_directory: ~/project/packages/std
273-
command: cargo test --locked --no-default-features
273+
command: cargo test --locked --no-default-features --features std
274274
- run:
275275
name: Build library for native target (all features)
276276
working_directory: ~/project/packages/std
277-
command: cargo build --locked --features abort,iterator,staking,stargate,cosmwasm_1_1
277+
command: cargo build --locked --features abort,iterator,staking,stargate,std,cosmwasm_1_1
278278
- run:
279279
name: Build library for wasm target (all features)
280280
working_directory: ~/project/packages/std
281-
command: cargo wasm --locked --features abort,iterator,staking,stargate,cosmwasm_1_1
281+
command: cargo wasm --locked --features abort,iterator,staking,stargate,std,cosmwasm_1_1
282282
- run:
283283
name: Run unit tests (all features)
284284
working_directory: ~/project/packages/std
285-
command: cargo test --locked --features abort,iterator,staking,stargate,cosmwasm_1_1
285+
command: cargo test --locked --features abort,iterator,staking,stargate,std,cosmwasm_1_1
286286
- run:
287287
name: Build and run schema generator
288288
working_directory: ~/project/packages/std

packages/std/src/exports.rs

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77
//! and `do_sudo` should be wrapped with a extern "C" entry point including
88
//! the contract-specific function pointer. This is done via the `#[entry_point]`
99
//! macro attribute from cosmwasm-derive.
10+
#![cfg(feature = "std")]
11+
1012
use alloc::string::ToString;
1113
use alloc::vec::Vec;
1214
use core::marker::PhantomData;
@@ -22,7 +24,7 @@ use crate::ibc::{
2224
};
2325
use crate::imports::{ExternalApi, ExternalQuerier, ExternalStorage};
2426
use crate::memory::{alloc, consume_region, release_buffer, Region};
25-
#[cfg(all(feature = "abort", feature = "std"))]
27+
#[cfg(feature = "abort")]
2628
use crate::panic::install_panic_handler;
2729
use crate::query::CustomQuery;
2830
use crate::results::{ContractResult, QueryResponse, Reply, Response};
@@ -101,7 +103,7 @@ where
101103
C: CustomMsg,
102104
E: ToString,
103105
{
104-
#[cfg(all(feature = "abort", feature = "std"))]
106+
#[cfg(feature = "abort")]
105107
install_panic_handler();
106108
let res = _do_instantiate(
107109
instantiate_fn,
@@ -131,7 +133,7 @@ where
131133
C: CustomMsg,
132134
E: ToString,
133135
{
134-
#[cfg(all(feature = "abort", feature = "std"))]
136+
#[cfg(feature = "abort")]
135137
install_panic_handler();
136138
let res = _do_execute(
137139
execute_fn,
@@ -160,7 +162,7 @@ where
160162
C: CustomMsg,
161163
E: ToString,
162164
{
163-
#[cfg(all(feature = "abort", feature = "std"))]
165+
#[cfg(feature = "abort")]
164166
install_panic_handler();
165167
let res = _do_migrate(migrate_fn, env_ptr as *mut Region, msg_ptr as *mut Region);
166168
let v = to_vec(&res).unwrap();
@@ -184,7 +186,7 @@ where
184186
C: CustomMsg,
185187
E: ToString,
186188
{
187-
#[cfg(all(feature = "abort", feature = "std"))]
189+
#[cfg(feature = "abort")]
188190
install_panic_handler();
189191
let res = _do_sudo(sudo_fn, env_ptr as *mut Region, msg_ptr as *mut Region);
190192
let v = to_vec(&res).unwrap();
@@ -207,7 +209,7 @@ where
207209
C: CustomMsg,
208210
E: ToString,
209211
{
210-
#[cfg(all(feature = "abort", feature = "std"))]
212+
#[cfg(feature = "abort")]
211213
install_panic_handler();
212214
let res = _do_reply(reply_fn, env_ptr as *mut Region, msg_ptr as *mut Region);
213215
let v = to_vec(&res).unwrap();
@@ -229,7 +231,7 @@ where
229231
M: DeserializeOwned,
230232
E: ToString,
231233
{
232-
#[cfg(all(feature = "abort", feature = "std"))]
234+
#[cfg(feature = "abort")]
233235
install_panic_handler();
234236
let res = _do_query(query_fn, env_ptr as *mut Region, msg_ptr as *mut Region);
235237
let v = to_vec(&res).unwrap();
@@ -252,7 +254,7 @@ where
252254
Q: CustomQuery,
253255
E: ToString,
254256
{
255-
#[cfg(all(feature = "abort", feature = "std"))]
257+
#[cfg(feature = "abort")]
256258
install_panic_handler();
257259
let res = _do_ibc_channel_open(contract_fn, env_ptr as *mut Region, msg_ptr as *mut Region);
258260
let v = to_vec(&res).unwrap();
@@ -277,7 +279,7 @@ where
277279
C: CustomMsg,
278280
E: ToString,
279281
{
280-
#[cfg(all(feature = "abort", feature = "std"))]
282+
#[cfg(feature = "abort")]
281283
install_panic_handler();
282284
let res = _do_ibc_channel_connect(contract_fn, env_ptr as *mut Region, msg_ptr as *mut Region);
283285
let v = to_vec(&res).unwrap();
@@ -302,7 +304,7 @@ where
302304
C: CustomMsg,
303305
E: ToString,
304306
{
305-
#[cfg(all(feature = "abort", feature = "std"))]
307+
#[cfg(feature = "abort")]
306308
install_panic_handler();
307309
let res = _do_ibc_channel_close(contract_fn, env_ptr as *mut Region, msg_ptr as *mut Region);
308310
let v = to_vec(&res).unwrap();
@@ -328,7 +330,7 @@ where
328330
C: CustomMsg,
329331
E: ToString,
330332
{
331-
#[cfg(all(feature = "abort", feature = "std"))]
333+
#[cfg(feature = "abort")]
332334
install_panic_handler();
333335
let res = _do_ibc_packet_receive(contract_fn, env_ptr as *mut Region, msg_ptr as *mut Region);
334336
let v = to_vec(&res).unwrap();
@@ -354,7 +356,7 @@ where
354356
C: CustomMsg,
355357
E: ToString,
356358
{
357-
#[cfg(all(feature = "abort", feature = "std"))]
359+
#[cfg(feature = "abort")]
358360
install_panic_handler();
359361
let res = _do_ibc_packet_ack(contract_fn, env_ptr as *mut Region, msg_ptr as *mut Region);
360362
let v = to_vec(&res).unwrap();
@@ -381,7 +383,7 @@ where
381383
C: CustomMsg,
382384
E: ToString,
383385
{
384-
#[cfg(all(feature = "abort", feature = "std"))]
386+
#[cfg(feature = "abort")]
385387
install_panic_handler();
386388
let res = _do_ibc_packet_timeout(contract_fn, env_ptr as *mut Region, msg_ptr as *mut Region);
387389
let v = to_vec(&res).unwrap();

packages/std/src/imports.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
#![cfg(feature = "std")]
2+
13
#[cfg(feature = "iterator")]
24
use alloc::boxed::Box;
35
use alloc::string::String;

packages/std/src/lib.rs

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -89,23 +89,24 @@ pub use crate::types::{BlockInfo, ContractInfo, Env, MessageInfo, TransactionInf
8989

9090
// Exposed in wasm build only
9191

92-
#[cfg(target_arch = "wasm32")]
92+
#[cfg(all(target_arch = "wasm32", feature = "std"))]
9393
mod exports;
94-
#[cfg(target_arch = "wasm32")]
94+
#[cfg(all(target_arch = "wasm32", feature = "std"))]
9595
mod imports;
96-
#[cfg(target_arch = "wasm32")]
9796
mod memory; // Used by exports and imports only. This assumes pointers are 32 bit long, which makes it untestable on dev machines.
9897

99-
#[cfg(target_arch = "wasm32")]
98+
#[cfg(all(target_arch = "wasm32", feature = "std"))]
10099
pub use crate::exports::{do_execute, do_instantiate, do_migrate, do_query, do_reply, do_sudo};
101-
#[cfg(all(feature = "stargate", target_arch = "wasm32"))]
100+
#[cfg(all(feature = "stargate", target_arch = "wasm32", feature = "std"))]
102101
pub use crate::exports::{
103102
do_ibc_channel_close, do_ibc_channel_connect, do_ibc_channel_open, do_ibc_packet_ack,
104103
do_ibc_packet_receive, do_ibc_packet_timeout,
105104
};
106-
#[cfg(target_arch = "wasm32")]
105+
#[cfg(all(target_arch = "wasm32", feature = "std"))]
107106
pub use crate::imports::{ExternalApi, ExternalQuerier, ExternalStorage};
108107

108+
pub use memory::Region;
109+
109110
// Exposed for testing only
110111
// Both unit tests and integration tests are compiled to native code, so everything in here does not need to compile to Wasm.
111112
#[cfg(not(target_arch = "wasm32"))]

packages/std/src/memory.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
#![allow(unused)]
2+
13
use alloc::boxed::Box;
24
use alloc::vec::Vec;
35
use core::mem;

0 commit comments

Comments
 (0)