Write default linker script if no overlay were specified

This commit is contained in:
Jaby 2022-12-01 02:56:18 +01:00
parent 573a345d17
commit 2bcb71d0d5
6 changed files with 37 additions and 1 deletions

View File

@ -6,3 +6,4 @@ edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies] [dependencies]
tool_helper = {path = "../tool_helper"}

View File

@ -0,0 +1,21 @@
use super::super::types::OverlaySlot;
use tool_helper::{Error, format_if_error, Output};
use std::io::Write;
const DEFAULT_LD_SCRIPT:&'static str = r#"
__heap_base = __bss_end;
"#;
pub fn write(output: &mut Output, overlay_desc: &Vec<OverlaySlot>) -> Result<(), Error> {
if overlay_desc.is_empty() {
return write_default(output);
}
format_if_error!(write!(output, "Dino\n"), "Writing test output failed with: {error_text}")?;
return Ok(());
}
fn write_default(output: &mut Output) -> Result<(), Error> {
format_if_error!(output.write(DEFAULT_LD_SCRIPT.as_bytes()), "Writing default LD Script failed with: {error_text}")?;
Ok(())
}

View File

@ -0,0 +1,2 @@
pub mod ldscript;
pub mod makefile;

View File

@ -1 +1,2 @@
pub mod types; pub mod types;
pub mod creator;

View File

@ -1,4 +1,5 @@
use mkoverlay::types::{OverlaySection, OverlaySlot}; use mkoverlay::types::{OverlaySection, OverlaySlot};
use tool_helper::{Error, open_output};
fn generate_file() -> Vec<OverlaySlot> { fn generate_file() -> Vec<OverlaySlot> {
let mut slots = Vec::new(); let mut slots = Vec::new();
@ -13,6 +14,16 @@ fn generate_file() -> Vec<OverlaySlot> {
slots slots
} }
fn run_main() -> Result<(), Error> {
let input = generate_file();
let mut output = open_output(None)?;
mkoverlay::creator::ldscript::write(&mut output, &input)
}
fn main() { fn main() {
println!("Blubbi: {:?}", generate_file()); match run_main() {
Ok(()) => println!("Planschbecken!!"),
Err(error) => println!("{}", error),
}
} }