File tree Expand file tree Collapse file tree 7 files changed +18
-28
lines changed Expand file tree Collapse file tree 7 files changed +18
-28
lines changed Original file line number Diff line number Diff line change @@ -5,3 +5,6 @@ edition = "2021"
5
5
6
6
[dependencies ]
7
7
ckb-std = " 0.15.3"
8
+
9
+ [features ]
10
+ native-simulator = [" ckb-std/native-simulator" ]
Original file line number Diff line number Diff line change
1
+ #![ cfg_attr( not( feature = "native-simulator" ) , no_std) ]
2
+ #![ allow( special_module_name) ]
3
+ #![ allow( unused_attributes) ]
4
+ #[ cfg( feature = "native-simulator" ) ]
5
+ mod main;
6
+ #[ cfg( feature = "native-simulator" ) ]
7
+ pub use main:: program_entry;
Original file line number Diff line number Diff line change 1
- #![ no_std]
1
+ #![ cfg_attr ( not ( feature = "native-simulator" ) , no_std) ]
2
2
#![ cfg_attr( not( test) , no_main) ]
3
3
4
- #[ cfg( test) ]
4
+ #[ cfg( any ( feature = "native-simulator" , test) ) ]
5
5
extern crate alloc;
6
6
7
- #[ cfg( not( test) ) ]
8
- use ckb_std:: default_alloc;
9
- #[ cfg( not( test) ) ]
7
+ #[ cfg( not( any( feature = "native-simulator" , test) ) ) ]
10
8
ckb_std:: entry!( program_entry) ;
11
- #[ cfg( not( test) ) ]
12
- default_alloc ! ( ) ;
9
+ #[ cfg( not( any ( feature = "native-simulator" , test) ) ) ]
10
+ ckb_std :: default_alloc!( ) ;
13
11
14
12
pub fn program_entry ( ) -> i8 {
15
13
ckb_std:: debug!( "This is a sample contract!" ) ;
Original file line number Diff line number Diff line change @@ -5,8 +5,8 @@ edition = "2021"
5
5
6
6
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
7
7
[dependencies ]
8
- {{contract_name}} = { path = " ../../contracts/{{contract_name}}" , features = [" simulator" ] }
9
- ckb-std = { version = " 0.15.3" , features = [" simulator" ] }
8
+ {{contract_name}} = { path = " ../../contracts/{{contract_name}}" , features = [" native- simulator" ] }
9
+ ckb-std = { version = " 0.15.3" , features = [" native- simulator" ] }
10
10
11
11
[lib ]
12
12
crate-type = [" cdylib" ]
Load Diff This file was deleted.
Original file line number Diff line number Diff line change @@ -16,4 +16,4 @@ debug = true
16
16
17
17
# TODO: Will be deleted after release
18
18
[replace ]
19
- "ckb-std:0.15.3" = { git = " https://github.com/nervosnetwork /ckb-std.git" , rev = " 36942aa " }
19
+ "ckb-std:0.15.3" = { git = " https://github.com/joii2020 /ckb-std.git" , rev = " 76f1ac3 " }
Original file line number Diff line number Diff line change @@ -129,17 +129,6 @@ generate-native-simulator:
129
129
--destination native-simulators \
130
130
-d contract_name=$(CRATE ) \
131
131
-d contract_crate_name=` echo " $( CRATE) " | tr ' -' ' _' ` ; \
132
- mv native-simulators/$(CRATE ) -sim/src/contract-lib.rs contracts/$(CRATE ) /src/lib.rs; \
133
- FILE=contracts/$(CRATE ) /Cargo.toml; \
134
- if grep -q " \\ [features\\ ]" " $$ FILE" ; then \
135
- sed -i ' /\[features\]/a\\simulator = \[\"ckb-std/simulator\"\]' $$ FILE; \
136
- else \
137
- echo " \\ n[features]\\ nsimulator = [\" ckb-std/simulator\" ]\\ n" >> $$ FILE ; \
138
- fi ; \
139
- FILE=contracts/$(CRATE ) /src/main.rs; \
140
- sed -i ' s/#!\[no_std\]/#!\[cfg_attr(not(feature = "simulator"), no_std)\]/' $$ FILE; \
141
- sed -i ' s/#\[cfg(test)\]/#\[cfg(any(feature = "simulator", test))\]/' $$ FILE; \
142
- sed -i ' s/#\[cfg(not(test))\]/#\[cfg(not(any(feature = "simulator", test)))\]/' $$ FILE; \
143
132
sed ' /@@INSERTION_POINT@@/s/$$/\n "native-simulators\/$(CRATE)-sim",/' Cargo.toml > Cargo.toml.new; \
144
133
mv Cargo.toml.new Cargo.toml;
145
134
You can’t perform that action at this time.
0 commit comments