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"
55
66[dependencies ]
77ckb-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) ]
22#![ cfg_attr( not( test) , no_main) ]
33
4- #[ cfg( test) ]
4+ #[ cfg( any ( feature = "native-simulator" , test) ) ]
55extern crate alloc;
66
7- #[ cfg( not( test) ) ]
8- use ckb_std:: default_alloc;
9- #[ cfg( not( test) ) ]
7+ #[ cfg( not( any( feature = "native-simulator" , test) ) ) ]
108ckb_std:: entry!( program_entry) ;
11- #[ cfg( not( test) ) ]
12- default_alloc ! ( ) ;
9+ #[ cfg( not( any ( feature = "native-simulator" , test) ) ) ]
10+ ckb_std :: default_alloc!( ) ;
1311
1412pub fn program_entry ( ) -> i8 {
1513 ckb_std:: debug!( "This is a sample contract!" ) ;
Original file line number Diff line number Diff line change @@ -5,8 +5,8 @@ edition = "2021"
55
66# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
77[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" ] }
1010
1111[lib ]
1212crate-type = [" cdylib" ]
Load Diff This file was deleted.
Original file line number Diff line number Diff line change @@ -16,4 +16,4 @@ debug = true
1616
1717# TODO: Will be deleted after release
1818[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:
129129 --destination native-simulators \
130130 -d contract_name=$(CRATE ) \
131131 -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; \
143132 sed ' /@@INSERTION_POINT@@/s/$$/\n "native-simulators\/$(CRATE)-sim",/' Cargo.toml > Cargo.toml.new; \
144133 mv Cargo.toml.new Cargo.toml;
145134
You can’t perform that action at this time.
0 commit comments