Carry-over Infineon basis
This commit is contained in:
parent
7bdbb13177
commit
b2152284dd
8 changed files with 567 additions and 2 deletions
51
build.rs
Normal file
51
build.rs
Normal file
|
|
@ -0,0 +1,51 @@
|
|||
// Build script for Infineon Traveo Rust project
|
||||
|
||||
use std::env;
|
||||
use std::fs;
|
||||
use std::path::Path;
|
||||
|
||||
fn main() {
|
||||
// Get the target and feature flags
|
||||
let target = env::var("TARGET").unwrap_or_default();
|
||||
let features = env::var("CARGO_CFG_FEATURES").unwrap_or_default();
|
||||
|
||||
println!("cargo:rerun-if-changed=build.rs");
|
||||
println!("cargo:rerun-if-changed=memory.x");
|
||||
println!("cargo:rerun-if-changed=memory-m0.x");
|
||||
|
||||
// Select appropriate memory configuration based on target
|
||||
let memory_file = if target.contains("thumbv6m") {
|
||||
"memory-m0.x"
|
||||
} else if target.contains("thumbv7em") {
|
||||
"memory.x"
|
||||
} else {
|
||||
"memory.x" // Default to Cortex-M7 config
|
||||
};
|
||||
|
||||
// Check if memory file exists and copy it to output directory
|
||||
if Path::new(memory_file).exists() {
|
||||
println!("cargo:rustc-link-arg-bins=--script={}", memory_file);
|
||||
fs::copy(
|
||||
memory_file,
|
||||
env::var("OUT_DIR").unwrap() + "/" + memory_file,
|
||||
)
|
||||
.expect("Failed to copy memory configuration");
|
||||
}
|
||||
|
||||
// Set up linker script based on target
|
||||
if target.contains("thumbv6m-none-eabi") {
|
||||
println!("cargo:rustc-link-arg=-Tmemory-m0.x");
|
||||
println!("cargo:rustc-link-arg=-Tlink.x");
|
||||
} else if target.contains("thumbv7em-none-eabi") {
|
||||
println!("cargo:rustc-link-arg=-Tmemory.x");
|
||||
println!("cargo:rustc-link-arg=-Tlink.x");
|
||||
}
|
||||
|
||||
// Add target-specific linker arguments
|
||||
println!("cargo:rustc-link-arg=-lc");
|
||||
println!("cargo:rustc-link-arg=-lm");
|
||||
println!("cargo:rustc-link-arg=-lgcc");
|
||||
|
||||
// Set optimization level for embedded development
|
||||
println!("cargo:rustc-env=OPT_LEVEL=s");
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue