1#![doc = include_str!("../README.md")]
2
3use std::env;
4use std::fs::File;
5use std::io::Write;
6use std::path::PathBuf;
7
8pub fn build() {
9 let Ok(out) = env::var("OUT_DIR") else {
10 panic!("$OUT_DIR variable not found, not running in build context?");
11 };
12 let linker_path = PathBuf::from(out).join("aragonite.ld");
13 let linker_script = include_bytes!("./aragonite.ld");
14 let mut linker_file = File::create(&linker_path).expect("not able to create linker script");
15 let _ = linker_file.write_all(linker_script);
16
17 println!("cargo::rustc-link-arg=-nostdlib");
18 println!("cargo::rustc-link-arg=-nostartfiles");
19 println!(
20 "cargo::rustc-link-arg=-Wl,-T{path},--build-id=none",
21 path = linker_path.to_str().unwrap()
22 );
23}