Write default linker script if no overlay were specified
This commit is contained in:
parent
c407f02241
commit
3960f596bf
|
@ -6,3 +6,4 @@ edition = "2021"
|
|||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
|
||||
[dependencies]
|
||||
tool_helper = {path = "../tool_helper"}
|
|
@ -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(())
|
||||
}
|
|
@ -0,0 +1,2 @@
|
|||
pub mod ldscript;
|
||||
pub mod makefile;
|
|
@ -1 +1,2 @@
|
|||
pub mod types;
|
||||
pub mod creator;
|
|
@ -1,4 +1,5 @@
|
|||
use mkoverlay::types::{OverlaySection, OverlaySlot};
|
||||
use tool_helper::{Error, open_output};
|
||||
|
||||
fn generate_file() -> Vec<OverlaySlot> {
|
||||
let mut slots = Vec::new();
|
||||
|
@ -13,6 +14,16 @@ fn generate_file() -> Vec<OverlaySlot> {
|
|||
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() {
|
||||
println!("Blubbi: {:?}", generate_file());
|
||||
match run_main() {
|
||||
Ok(()) => println!("Planschbecken!!"),
|
||||
Err(error) => println!("{}", error),
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue