Write ldscript_template path to ouput depfile

This commit is contained in:
Luke Street 2025-05-30 19:18:46 -06:00
parent 5505120148
commit 9c681557f5
3 changed files with 13 additions and 4 deletions

2
Cargo.lock generated
View File

@ -348,7 +348,7 @@ dependencies = [
[[package]] [[package]]
name = "decomp-toolkit" name = "decomp-toolkit"
version = "1.5.1" version = "1.5.2"
dependencies = [ dependencies = [
"aes", "aes",
"anyhow", "anyhow",

View File

@ -3,7 +3,7 @@ name = "decomp-toolkit"
description = "Yet another GameCube/Wii decompilation toolkit." description = "Yet another GameCube/Wii decompilation toolkit."
authors = ["Luke Street <luke@street.dev>"] authors = ["Luke Street <luke@street.dev>"]
license = "MIT OR Apache-2.0" license = "MIT OR Apache-2.0"
version = "1.5.1" version = "1.5.2"
edition = "2021" edition = "2021"
publish = false publish = false
repository = "https://github.com/encounter/decomp-toolkit" repository = "https://github.com/encounter/decomp-toolkit"

View File

@ -578,6 +578,7 @@ struct ModuleInfo<'a> {
config: &'a ModuleConfig, config: &'a ModuleConfig,
symbols_cache: Option<FileReadInfo>, symbols_cache: Option<FileReadInfo>,
splits_cache: Option<FileReadInfo>, splits_cache: Option<FileReadInfo>,
dep: Vec<Utf8NativePathBuf>,
} }
type ModuleMapByName<'a> = BTreeMap<String, ModuleInfo<'a>>; type ModuleMapByName<'a> = BTreeMap<String, ModuleInfo<'a>>;
@ -1055,9 +1056,11 @@ fn split_write_obj(
// Generate ldscript.lcf // Generate ldscript.lcf
let ldscript_template = if let Some(template_path) = &module.config.ldscript_template { let ldscript_template = if let Some(template_path) = &module.config.ldscript_template {
let template_path = template_path.with_encoding(); let template_path = template_path.with_encoding();
Some(fs::read_to_string(&template_path).with_context(|| { let template = fs::read_to_string(&template_path).with_context(|| {
format!("Failed to read linker script template '{}'", template_path) format!("Failed to read linker script template '{}'", template_path)
})?) })?;
module.dep.push(template_path);
Some(template)
} else { } else {
None None
}; };
@ -1245,6 +1248,7 @@ fn split(args: SplitArgs) -> Result<()> {
config: &config.base, config: &config.base,
symbols_cache: result.symbols_cache, symbols_cache: result.symbols_cache,
splits_cache: result.splits_cache, splits_cache: result.splits_cache,
dep: Default::default(),
} }
}; };
let mut function_count = dol.obj.symbols.by_kind(ObjSymbolKind::Function).count(); let mut function_count = dol.obj.symbols.by_kind(ObjSymbolKind::Function).count();
@ -1259,6 +1263,7 @@ fn split(args: SplitArgs) -> Result<()> {
config: &config.modules[idx], config: &config.modules[idx],
symbols_cache: result.symbols_cache, symbols_cache: result.symbols_cache,
splits_cache: result.splits_cache, splits_cache: result.splits_cache,
dep: Default::default(),
}), }),
Entry::Occupied(_) => bail!("Duplicate module name {}", result.obj.name), Entry::Occupied(_) => bail!("Duplicate module name {}", result.obj.name),
}; };
@ -1440,6 +1445,10 @@ fn split(args: SplitArgs) -> Result<()> {
} }
// Write dep file // Write dep file
dep.extend(dol.dep);
for module in modules.into_values() {
dep.extend(module.dep);
}
{ {
let dep_path = args.out_dir.join("dep"); let dep_path = args.out_dir.join("dep");
let mut dep_file = buf_writer(&dep_path)?; let mut dep_file = buf_writer(&dep_path)?;