forked from cbruiz/printhor
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.rs
74 lines (69 loc) · 3.1 KB
/
build.rs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
#[allow(unused)]
use std::io::Write;
fn main() {
cfg_if::cfg_if! {
if #[cfg(feature="rp_2040")] {
let out = &std::path::PathBuf::from(std::env::var_os("OUT_DIR").unwrap());
let memory_x_path = std::path::PathBuf::from(".")
.join("hwi-boards")
.join("printhor-hwi_rp_2040")
.join("memory.x");
let memory_x_path_str = memory_x_path.as_path().to_str().unwrap();
std::fs::File::create(out.join("memory.x"))
.unwrap()
.write_all(std::fs::read(memory_x_path_str).unwrap().as_slice())
.unwrap();
println!("cargo:rustc-link-search={}", out.display());
println!("cargo:rerun-if-changed={}", memory_x_path_str);
}
else if #[cfg(all(feature="skr_mini_e3_v2", feature="with-bootloader"))] {
let out = &std::path::PathBuf::from(std::env::var_os("OUT_DIR").unwrap());
let memory_x_path = std::path::PathBuf::from(".")
.join("hwi-boards")
.join("printhor-hwi_skr_mini_e3")
.join("skr_mini_e3_v2")
.join("memory.x");
let memory_x_path_str = memory_x_path.as_path().to_str().unwrap();
std::fs::File::create(out.join("memory.x"))
.unwrap()
.write_all(std::fs::read(memory_x_path_str).unwrap().as_slice())
.unwrap();
println!("cargo:rustc-link-search={}", out.display());
println!("cargo:rerun-if-changed={}", memory_x_path_str);
}
else if #[cfg(all(feature="skr_mini_e3_v3", feature="with-bootloader"))] {
let out = &std::path::PathBuf::from(std::env::var_os("OUT_DIR").unwrap());
let memory_x_path = std::path::PathBuf::from(".")
.join("hwi-boards")
.join("printhor-hwi_skr_mini_e3")
.join("skr_mini_e3_v3")
.join("memory.x");
let memory_x_path_str = memory_x_path.as_path().to_str().unwrap();
std::fs::File::create(out.join("memory.x"))
.unwrap()
.write_all(std::fs::read(memory_x_path_str).unwrap().as_slice())
.unwrap();
println!("cargo:rustc-link-search={}", out.display());
println!("cargo:rerun-if-changed={}", memory_x_path_str);
}
}
// By default, Cargo will re-run a build script whenever
// any file in the project changes. By specifying `memory.x`
// here, we ensure the build script is only re-run when
// `memory.x` is changed.
#[cfg(not(feature = "native"))]
{
println!("cargo:rustc-link-arg-bins=--nmagic");
println!("cargo:rustc-link-arg-bins=-Tlink.x");
}
cfg_if::cfg_if! {
if #[cfg(feature="rp_2040")] {
println!("cargo:rustc-link-arg-bins=-Tlink-rp.x");
}
}
#[cfg(feature = "with-defmt")]
println!("cargo:rustc-link-arg-bins=-Tdefmt.x");
// make native lvgl more platform independent
//#[cfg(feature="native")]
//println!("cargo:rustc-link-arg-bins=-L/opt/homebrew/lib");
}