File tree Expand file tree Collapse file tree 15 files changed +47
-92
lines changed
Expand file tree Collapse file tree 15 files changed +47
-92
lines changed Original file line number Diff line number Diff line change @@ -3,7 +3,7 @@ description = "SDK for writing applications for Neotron OS"
33edition = " 2021"
44license = " MIT OR Apache-2.0"
55name = " neotron-sdk"
6- version = " 0.1 .0"
6+ version = " 0.2 .0"
77authors = [" Jonathan 'theJPster' Pallant <neotron@thejpster.org.uk>" ]
88
99[dependencies ]
Original file line number Diff line number Diff line change 1+ //! Build script for the Neotron SDK
2+ //!
3+ //! Sets up Rust to link with a Cortex-M linker script if you are building for
4+ //! an Arm bare-metal target.
5+
6+ use std:: io:: prelude:: * ;
7+
8+ fn main ( ) {
9+ let arch = std:: env:: var ( "CARGO_CFG_TARGET_ARCH" ) . expect ( "CARGO_CFG_TARGET_ARCH variable" ) ;
10+ let os = std:: env:: var ( "CARGO_CFG_TARGET_OS" ) . expect ( "CARGO_CFG_TARGET_OS variable" ) ;
11+ match ( arch. as_str ( ) , os. as_str ( ) ) {
12+ ( "arm" , "none" ) => {
13+ setup_cortexm_linker ( ) ;
14+ }
15+ _ => {
16+ // no script required
17+ }
18+ }
19+ }
20+
21+ fn setup_cortexm_linker ( ) {
22+ // Put `neotron-cortex-m.ld` in our output directory and ensure it's
23+ // on the linker search path.
24+ let out = & std:: path:: PathBuf :: from ( std:: env:: var_os ( "OUT_DIR" ) . unwrap ( ) ) ;
25+ std:: fs:: File :: create ( out. join ( "neotron-cortex-m.ld" ) )
26+ . unwrap ( )
27+ . write_all ( include_bytes ! ( "./neotron-cortex-m.ld" ) )
28+ . unwrap ( ) ;
29+ println ! ( "cargo:rustc-link-search={}" , out. display( ) ) ;
30+
31+ // By default, Cargo will re-run a build script whenever
32+ // any file in the project changes. By specifying `neotron-cortex-m.ld`
33+ // here, we ensure the build script is only re-run when
34+ // `neotron-cortex-m.ld` is changed.
35+ println ! ( "cargo:rerun-if-changed=./neotron-cortex-m.ld" ) ;
36+ }
File renamed without changes.
Original file line number Diff line number Diff line change @@ -8,6 +8,9 @@ members = [
88]
99resolver = " 2"
1010
11+ [workspace .dependencies ]
12+ neotron-sdk = { path = " .." , version = " 0.2" }
13+
1114[profile .release ]
1215opt-level = " z"
1316lto = " fat"
Original file line number Diff line number Diff line change @@ -19,6 +19,6 @@ arm-none-eabi-gcc \
1919 -nostartfiles \
2020 -ffreestanding \
2121 -mcpu=$CPU \
22- -Wl,-T../neotron-cortex-m.ld \
22+ -Wl,-T../../ neotron-cortex-m.ld \
2323 -o asmhello.elf \
2424 asmhello.S \
Original file line number Diff line number Diff line change @@ -28,7 +28,7 @@ arm-none-eabi-gcc \
2828 -Wdouble-promotion \
2929 -Wextra \
3030 -Wl,-gc-sections \
31- -Wl,-T../neotron-cortex-m.ld \
31+ -Wl,-T../../ neotron-cortex-m.ld \
3232 -Wshadow \
3333 --specs=nano.specs \
3434 --specs=nosys.specs \
Original file line number Diff line number Diff line change @@ -7,6 +7,6 @@ authors = ["Jonathan 'theJPster' Pallant <neotron@thejpster.org.uk>"]
77description = " Hello World for Neotron systems"
88
99[dependencies ]
10- neotron-sdk = { path = " ../.. " }
10+ neotron-sdk = { workspace = true }
1111
1212# See workspace for profile settings
Load Diff This file was deleted.
Original file line number Diff line number Diff line change @@ -7,6 +7,6 @@ authors = ["Jonathan 'theJPster' Pallant <neotron@thejpster.org.uk>"]
77description = " Hello World for Neotron systems"
88
99[dependencies ]
10- neotron-sdk = { path = " ../.. " }
10+ neotron-sdk = { workspace = true }
1111
1212# See workspace for profile settings
Load Diff This file was deleted.
You can’t perform that action at this time.
0 commit comments