Skip to content

Commit

Permalink
fmt
Browse files Browse the repository at this point in the history
  • Loading branch information
AngheloAlf committed Mar 12, 2024
1 parent c9fb5e1 commit feb336a
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 12 deletions.
4 changes: 3 additions & 1 deletion slinky-cli/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@ fn main() {
}

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
.save_symbol_header(symbols_header_path)
.expect("Error writing symbol header file");
}
}
4 changes: 2 additions & 2 deletions slinky/src/dependencies_writer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ impl<'a> DependenciesWriter<'a> {

// internal functions
impl<'a> DependenciesWriter<'a> {
fn emit_file(&mut self, file: &FileInfo, segment: &Segment, base_path: &Path) {
fn emit_file(&mut self, file: &FileInfo, _segment: &Segment, base_path: &Path) {
// TODO: figure out glob support
match file.kind {
FileKind::Object | FileKind::Archive => {
Expand All @@ -110,7 +110,7 @@ impl<'a> DependenciesWriter<'a> {
new_base_path.extend(&file.dir);

for file_of_group in &file.files {
self.emit_file(file_of_group, segment, &new_base_path);
self.emit_file(file_of_group, _segment, &new_base_path);
}
}
}
Expand Down
27 changes: 21 additions & 6 deletions slinky/src/linker_writer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -185,13 +185,21 @@ impl<'a> LinkerWriter<'a> {
});
}

let arr_suffix = if self.settings.symbols_header_as_array { "[]" } else {""};
let arr_suffix = if self.settings.symbols_header_as_array {
"[]"
} else {
""
};

let mut linker_symbols_sorted: Vec<_> = (&self.linker_symbols).into_iter().collect();
let mut linker_symbols_sorted: Vec<_> = self.linker_symbols.iter().collect();
linker_symbols_sorted.sort();

for sym in linker_symbols_sorted {
if let Err(e) = writeln!(f, "extern {} {}{};", self.settings.symbols_header_type, sym, arr_suffix) {
if let Err(e) = writeln!(
f,
"extern {} {}{};",
self.settings.symbols_header_type, sym, arr_suffix
) {
return Err(SlinkyError::FailedFileWrite {
path: path.to_path_buf(),
description: e.to_string(),
Expand All @@ -217,13 +225,20 @@ impl<'a> LinkerWriter<'a> {

ret += "#ifndef HEADER_SYMBOLS_H\n#define HEADER_SYMBOLS_H\n\n";

let arr_suffix = if self.settings.symbols_header_as_array { "[]" } else {""};
let arr_suffix = if self.settings.symbols_header_as_array {
"[]"
} else {
""
};

let mut linker_symbols_sorted: Vec<_> = (&self.linker_symbols).into_iter().collect();
let mut linker_symbols_sorted: Vec<_> = self.linker_symbols.iter().collect();
linker_symbols_sorted.sort();

for sym in linker_symbols_sorted {
ret += &format!("extern {} {}{};", self.settings.symbols_header_type, sym, arr_suffix);
ret += &format!(
"extern {} {}{};",
self.settings.symbols_header_type, sym, arr_suffix
);
}

ret += "\n#endif\n";
Expand Down
13 changes: 10 additions & 3 deletions slinky/src/settings.rs
Original file line number Diff line number Diff line change
Expand Up @@ -242,9 +242,16 @@ impl SettingsSerial {
.target_path
.get_optional_nullable("target_path", settings_default_target_path)?;

let symbols_header_path = self.symbols_header_path.get_optional_nullable("symbols_header_path", settings_default_symbols_header_path)?;
let symbols_header_type = self.symbols_header_type.get_non_null("symbols_header_type", settings_default_symbols_header_type)?;
let symbols_header_as_array = self.symbols_header_as_array.get_non_null("symbols_header_as_array", settings_default_symbols_header_as_array)?;
let symbols_header_path = self
.symbols_header_path
.get_optional_nullable("symbols_header_path", settings_default_symbols_header_path)?;
let symbols_header_type = self
.symbols_header_type
.get_non_null("symbols_header_type", settings_default_symbols_header_type)?;
let symbols_header_as_array = self.symbols_header_as_array.get_non_null(
"symbols_header_as_array",
settings_default_symbols_header_as_array,
)?;

let sections_allowlist = self
.sections_allowlist
Expand Down

0 comments on commit feb336a

Please sign in to comment.