mirror of
https://github.com/encounter/decomp-toolkit.git
synced 2025-12-16 08:27:02 +00:00
Add code_size, data_size to generated config.json
Also simplify project config generation by skipping default fields
This commit is contained in:
@@ -293,4 +293,29 @@ impl ObjInfo {
|
||||
.filter(|(_, _, _, split)| split.unit == unit)
|
||||
.all(|(_, _, _, split)| split.autogenerated)
|
||||
}
|
||||
|
||||
/// Calculate the total size of all code sections.
|
||||
pub fn code_size(&self) -> u32 {
|
||||
self.sections
|
||||
.iter()
|
||||
.filter(|(_, section)| section.kind == ObjSectionKind::Code)
|
||||
.map(|(_, section)| section.size as u32)
|
||||
.sum()
|
||||
}
|
||||
|
||||
/// Calculate the total size of all data sections, including common BSS symbols.
|
||||
pub fn data_size(&self) -> u32 {
|
||||
self.sections
|
||||
.iter()
|
||||
.filter(|(_, section)| section.kind != ObjSectionKind::Code)
|
||||
.map(|(_, section)| section.size as u32)
|
||||
.chain(
|
||||
// Include common symbols
|
||||
self.symbols
|
||||
.iter()
|
||||
.filter(|&symbol| symbol.flags.is_common())
|
||||
.map(|s| s.size as u32),
|
||||
)
|
||||
.sum()
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user