Skip to content

Commit f640a6e

Browse files
committed
Get sample to build using linker script.
1 parent 1fc0758 commit f640a6e

File tree

4 files changed

+22
-1
lines changed

4 files changed

+22
-1
lines changed

samples/hello/build.rs

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
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+
}

samples/hello/src/main.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
extern crate neotron_sdk;
55

66
#[no_mangle]
7-
extern "C" fn main() -> i32 {
7+
extern "C" fn neotron_main() -> i32 {
88
let stdout = neotron_sdk::stdout();
99
stdout.write(b"Hello, world\n").unwrap();
1010
0

0 commit comments

Comments
 (0)