Skip to content

Commit

Permalink
write_other_files
Browse files Browse the repository at this point in the history
  • Loading branch information
AngheloAlf committed Apr 24, 2024
1 parent 89feb2c commit d195b11
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 16 deletions.
18 changes: 4 additions & 14 deletions slinky-cli/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/* SPDX-FileCopyrightText: © 2024 decompals */
/* SPDX-License-Identifier: MIT */

use std::path::{Path, PathBuf};
use std::path::PathBuf;

use clap::Parser;

Expand Down Expand Up @@ -47,17 +47,7 @@ fn main() {
// writer_test.save_linker_script(Path::new("test.ld")).expect("idk");
//}

if let Some(d_path) = &document.settings.d_path {
if let Some(target_path) = &document.settings.target_path {
writer
.save_dependencies_file(d_path, target_path)
.expect("Error writing dependencies file");
}
}

if let Some(symbols_header_path) = &document.settings.symbols_header_path {
writer
.save_symbol_header(symbols_header_path)
.expect("Error writing symbol header file");
}
writer
.write_other_files()
.expect("Error writing other files listed on the document");
}
27 changes: 25 additions & 2 deletions slinky/src/linker_writer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use crate::{utils, Settings};
use crate::{FileInfo, Segment};

pub struct LinkerWriter<'a> {
pub linker_symbols: HashSet<String>,
linker_symbols: HashSet<String>,

// Used for dependency generation
files_paths: Vec<PathBuf>,
Expand Down Expand Up @@ -159,6 +159,7 @@ impl<'a> LinkerWriter<'a> {
self.writeln("");
}

/*
pub fn add_single_segment(&mut self, segment: &Segment) {
assert!(self.buffer.is_empty());
Expand Down Expand Up @@ -251,6 +252,7 @@ impl<'a> LinkerWriter<'a> {
self.end_sections();
}
*/

pub fn save_linker_script(&self, path: &Path) -> Result<(), SlinkyError> {
let mut f = utils::create_file_and_parents(path)?;
Expand Down Expand Up @@ -280,7 +282,7 @@ impl<'a> LinkerWriter<'a> {
}

pub fn save_dependencies_file(
&mut self,
&self,
path: &Path,
target_path: &Path,
) -> Result<(), SlinkyError> {
Expand Down Expand Up @@ -415,6 +417,27 @@ impl<'a> LinkerWriter<'a> {

ret
}

#[must_use]
pub fn get(&self) -> &HashSet<String> {
&self.linker_symbols
}
}

impl LinkerWriter<'_> {
pub fn write_other_files(&self) -> Result<(), SlinkyError> {
if let Some(d_path) = &self.settings.d_path {
if let Some(target_path) = &self.settings.target_path {
self.save_dependencies_file(d_path, target_path)?;
}
}

if let Some(symbols_header_path) = &self.settings.symbols_header_path {
self.save_symbol_header(symbols_header_path)?;
}

Ok(())
}
}

// internal functions
Expand Down

0 comments on commit d195b11

Please sign in to comment.