Move the linkers scripts to the src directory so agb itself can change its script

This commit is contained in:
Gwilym Inzani 2023-10-18 12:26:50 +01:00
parent 721aba3c76
commit 4ed2ea3784
5 changed files with 10 additions and 6 deletions

View file

@ -7,8 +7,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## [Unreleased]
### Added
- There is now a multiboot feature which you can use to easily make multiboot ROMS.
### Changed
- General improvements to the linker script that you will need to update.
- You no longer need the gba.ld or gba_mb.ld files in your repository. You should delete these when upgrading.
### Fixed

View file

@ -3,17 +3,18 @@ use std::{env, error::Error, fs, path::PathBuf};
fn main() -> Result<(), Box<dyn Error>> {
let out = &PathBuf::from(env::var("OUT_DIR").unwrap());
let linker_script = if env::var("CARGO_FEATURE_MULTIBOOT").is_ok() {
include_bytes!("gba_mb.ld").as_slice()
include_bytes!(concat!(env!("CARGO_MANIFEST_DIR"), "/src/gba_mb.ld")).as_slice()
} else {
include_bytes!("gba.ld").as_slice()
include_bytes!(concat!(env!("CARGO_MANIFEST_DIR"), "/src/gba.ld")).as_slice()
};
fs::write(out.join("gba.ld"), linker_script)?;
println!("cargo:rustc-link-search={}", out.display());
println!("cargo:rerun-if-changed=gba.ld");
println!("cargo:rerun-if-changed=gba_mb.ld");
println!("cargo:rerun-if-changed=src/gba.ld");
println!("cargo:rerun-if-changed=src/gba_mb.ld");
println!("cargo:rerun-if-changed=build.rs");
println!("cargo:rerun-if-env-changed=CARGO_FEATURE_MULTIBOOT");
Ok(())
}

View file

@ -146,7 +146,7 @@ _test-debug crate:
_test-debug-arm crate:
(cd "{{crate}}" && cargo test --target=armv4t-none-eabi)
_test-multiboot:
(cd "agb" && AGB_MULTIBOOT=true RUSTFLAGS="-Clink-arg=-Tgba_mb.ld -Ctarget-cpu=arm7tdmi" cargo test --test=test_multiboot)
(cd "agb" && AGB_MULTIBOOT=true cargo test --features=multiboot --test=test_multiboot)
_clippy crate:
(cd "{{crate}}" && cargo clippy --examples --tests -- {{CLIPPY_ARGUMENTS}})
_clean crate: