File tree Expand file tree Collapse file tree 5 files changed +52
-0
lines changed
Expand file tree Collapse file tree 5 files changed +52
-0
lines changed Original file line number Diff line number Diff line change 44 " ./samples/panic/Cargo.toml" ,
55 " ./samples/hello/Cargo.toml" ,
66 " ./samples/fault/Cargo.toml" ,
7+ " ./samples/snake/Cargo.toml" ,
78 " ./Cargo.toml"
89 ]
910}
Original file line number Diff line number Diff line change @@ -3,6 +3,7 @@ members = [
33 " fault" ,
44 " hello" ,
55 " input-test" ,
6+ " snake" ,
67 " panic" ,
78]
89
Original file line number Diff line number Diff line change 1+ [package ]
2+ name = " snake"
3+ version = " 0.1.0"
4+ edition = " 2021"
5+ license = " MIT OR Apache-2.0"
6+ authors = [
" Jonathan 'theJPster' Pallant <[email protected] >" ]
7+ description = " ANSI Snake for Neotron systems"
8+
9+ [dependencies ]
10+ neotron-sdk = { path = " ../.." }
11+
12+ # See workspace for profile settings
Original file line number Diff line number Diff line change 1+ use std:: env;
2+ use std:: fs:: File ;
3+ use std:: io:: Write ;
4+ use std:: path:: PathBuf ;
5+
6+ fn main ( ) {
7+ // Put `neotron-cortex-m.ld` in our output directory and ensure it's
8+ // on the linker search path.
9+ let out = & PathBuf :: from ( env:: var_os ( "OUT_DIR" ) . unwrap ( ) ) ;
10+ File :: create ( out. join ( "neotron-cortex-m.ld" ) )
11+ . unwrap ( )
12+ . write_all ( include_bytes ! ( "../neotron-cortex-m.ld" ) )
13+ . unwrap ( ) ;
14+ println ! ( "cargo:rustc-link-search={}" , out. display( ) ) ;
15+
16+ // By default, Cargo will re-run a build script whenever
17+ // any file in the project changes. By specifying `neotron-cortex-m.ld`
18+ // here, we ensure the build script is only re-run when
19+ // `neotron-cortex-m.ld` is changed.
20+ println ! ( "cargo:rerun-if-changed=../neotron-cortex-m.ld" ) ;
21+ }
Original file line number Diff line number Diff line change 1+ #![ cfg_attr( target_os = "none" , no_std) ]
2+ #![ cfg_attr( target_os = "none" , no_main) ]
3+
4+ #[ cfg( not( target_os = "none" ) ) ]
5+ fn main ( ) {
6+ neotron_sdk:: init ( ) ;
7+ }
8+
9+ #[ no_mangle]
10+ extern "C" fn neotron_main ( ) -> i32 {
11+ let stdout = neotron_sdk:: stdout ( ) ;
12+ if stdout. write ( b"Hello, world\n " ) . is_ok ( ) {
13+ 0
14+ } else {
15+ 1
16+ }
17+ }
You can’t perform that action at this time.
0 commit comments