aboutsummaryrefslogtreecommitdiff
path: root/examples/boot/bootloader/stm32/build.rs
diff options
context:
space:
mode:
authorUlf Lilleengen <[email protected]>2022-06-24 19:56:15 +0200
committerUlf Lilleengen <[email protected]>2022-06-24 19:56:15 +0200
commit776be79f7bb10b09e795e2ea93bb795a653c9b4c (patch)
tree269046d330ee503c84049bb8fc47baf0297ecb80 /examples/boot/bootloader/stm32/build.rs
parent84628d36cf743193cbf0e7d47ef1cfa9fb590890 (diff)
Move bootloader main to examples
This should remove some confusion around embassy-boot-* being a library vs. a binary. The binary is now an example bootloader instead.
Diffstat (limited to 'examples/boot/bootloader/stm32/build.rs')
-rw-r--r--examples/boot/bootloader/stm32/build.rs32
1 files changed, 32 insertions, 0 deletions
diff --git a/examples/boot/bootloader/stm32/build.rs b/examples/boot/bootloader/stm32/build.rs
new file mode 100644
index 000000000..3997702f6
--- /dev/null
+++ b/examples/boot/bootloader/stm32/build.rs
@@ -0,0 +1,32 @@
1use std::env;
2use std::fs::File;
3use std::io::Write;
4use std::path::PathBuf;
5
6fn main() {
7 // Put `memory.x` 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("memory.x"))
11 .unwrap()
12 .write_all(include_bytes!("memory.x"))
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 `memory.x`
18 // here, we ensure the build script is only re-run when
19 // `memory.x` is changed.
20 println!("cargo:rerun-if-changed=memory.x");
21
22 println!("cargo:rustc-link-arg-bins=--nmagic");
23 println!("cargo:rustc-link-arg-bins=-Tlink.x");
24 if env::var("CARGO_FEATURE_DEFMT").is_ok() {
25 println!("cargo:rustc-link-arg-bins=-Tdefmt.x");
26 }
27
28 let target = env::var("TARGET").unwrap();
29 if target.starts_with("thumbv6m-") {
30 println!("cargo:rustc-cfg=armv6m");
31 }
32}