diff --git a/data/objects.txt b/data/objects.txt deleted file mode 100644 index 7e420513..00000000 --- a/data/objects.txt +++ /dev/null @@ -1,37 +0,0 @@ -build/obj/1.o -build/obj/sdk/msl/runtime/__mem.o -build/obj/2.o -build/obj/sdk/msl/runtime/runtime.o -build/obj/sdk/trk/__exception.o -build/obj/4.o -build/obj/sdk/rvl/base/PPCArch.o -build/obj/5.o -build/obj/sdk/rvl/os/OS.o -build/obj/6.o -build/obj/sdk/rvl/os/OSCache.o -build/obj/sdk/rvl/os/OSContext.o -build/obj/8.o -build/obj/sdk/rvl/os/__start.o -build/obj/sdk/rvl/os/__ppc_eabi_init.o -build/obj/10.o -build/obj/donut/Main.o -build/obj/11.o -build/obj/donut/app/AppImpl.o -build/obj/12.o -build/obj/donut/app/EntryPoint.o -build/obj/13.o -build/obj/donut/app/EntryPoint2.o -build/obj/14.o -build/obj/donut/app/System.o -build/obj/15.o -build/obj/donut/g3d/Root.o -build/obj/16.o -build/obj/donut/gfx/GXFifoMemoryManager.o -build/obj/17.o -build/obj/donut/gfx/RenderSetting.o -build/obj/18.o -build/obj/donut/gfx/XFBManager.o -build/obj/19.o -build/obj/donut/mem/Memory.o -build/obj/20.o -build/obj/21.o diff --git a/data/ranges.csv b/data/ranges.csv index a1a29574..be933d19 100644 --- a/data/ranges.csv +++ b/data/ranges.csv @@ -1,5 +1,5 @@ .init start,.init end,extab start,extab end,extabindex start,extabindex end,.text start,.text end,.ctors start,.ctors end,.dtors start,.dtors end,.rodata start,.rodata end,.data start,.data end,.bss start,.bss end,.sdata start,.sdata end,.sbss start,.sbss end,.sdata2 start,.sdata2 end,.sbss2 start,.sbss2 end,File -,,,,,,,,80406540,80406544,,,,,,,,,,,,,,,,,Linker generated symbol file +,,,,,,,,80406540,80406544,,,,,,,,,,,,,,,,, 80004000,80004380,,,,,80006a8c,80006aa8,,,,,,,,,,,,,,,,,,,sdk/msl/runtime/__mem.o ,,,,,,80007214,800079fc,,,,,80406580,80406598,,,,,,,,,,,,,sdk/msl/runtime/runtime.o 80004380,800062c0,,,,,,,,,,,,,,,,,,,,,,,,,sdk/trk/__exception.o @@ -14,10 +14,10 @@ ,,,,,,801776bc,80177810,,,,,,,80452cf7,80452d18,,,,,8055d13c,8055d141,,,,,donut/app/EntryPoint.o ,,,,,,801778d8,8017793c,,,,,,,,,,,,,,,,,,,donut/app/EntryPoint2.o ,,,,,,8017bbdc,8017bd88,,,,,,,,,,,,,,,,,,,donut/app/System.o -,,,,,,,,,,,,,,,,,,,,8055d1b0,8055d1b4,,,,,donut/gfx/Root.cpp +,,,,,,,,,,,,,,,,,,,,8055d1b0,8055d1b4,,,,,donut/g3d/Root.o ,,,,,,8019607c,801961fc,,,,,,,,,,,,,8055d1b4,8055d1b9,,,,,donut/gfx/GXFifoMemoryManager.o ,,,,,,801962a8,80196404,,,,,,,,,,,,,,,8055f720,8055f730,,,donut/gfx/RenderSetting.o ,,,,,,80197d50,80197ef4,,,,,,,,,,,,,,,,,,,donut/gfx/XFBManager.o ,,,,,,801bf250,801bf2bc,,,,,,,,,80545bf8,80545ed0,,,8055d2a0,8055d2a1,,,,,donut/mem/Memory.o -80006684,80006728,,,,,,,8040652c,80406530,80406548,8040654c,,,,,,,,,,,,,,,Linker generated symbol file -80006728,80006728,800068cc,800068cc,800069e4,800069e4,80406244,80406244,80406530,80406530,8040654c,8040654c,80421030,80421030,804966fc,804966fc,8055640c,8055640c,8055c6d0,8055c6d0,8055df74,8055df74,805643b0,805643b0,805643fc,805643fc,End of File \ No newline at end of file +80006684,80006728,,,,,,,8040652c,80406530,80406548,8040654c,,,,,,,,,,,,,,, +80006728,80006728,800068cc,800068cc,800069e4,800069e4,80406244,80406244,80406530,80406530,8040654c,8040654c,80421030,80421030,804966fc,804966fc,8055640c,8055640c,8055c6d0,8055c6d0,8055df74,8055df74,805643b0,805643b0,805643fc,805643fc, \ No newline at end of file diff --git a/include/hel/common/ExplicitSingleton.hpp b/include/hel/common/ExplicitSingleton.hpp index 173f111f..6b7e8a48 100644 --- a/include/hel/common/ExplicitSingleton.hpp +++ b/include/hel/common/ExplicitSingleton.hpp @@ -9,4 +9,4 @@ template struct ExplicitSingleton : NonCopyable { ~ExplicitSingleton(); }; } // namespace common -} // namespace hel \ No newline at end of file +} // namespace hel diff --git a/rules.ninja b/rules.ninja index 5738bb9f..1bcd70ec 100644 --- a/rules.ninja +++ b/rules.ninja @@ -1,27 +1,41 @@ rule extract-object command = cargo run --quiet --release --bin extract-dol -- $in $out $start $end + depfile = target/release/extract-dol.d + deps = gcc rule directory command = mkdir $out rule genlcf command = cargo run --quiet --release --bin genlcf -- $out + depfile = target/release/genlcf.d + deps = gcc rule ccld command = ./run-exe.sh bin/mwcc/mwldeppc.exe $in -o $out -lcf $lcf -fp hard -linkmode moreram -map $map -mapunused -code_merging all rule cc - command = ./run-exe.sh bin/mwcc/mwcceppc.exe $cflags -c $in -o $out -gccdep -MD + command = (./run-exe.sh bin/mwcc/mwcceppc.exe $cflags -c $in -o $out -gccdep -MDfile $out.d && sed -i 's|Z:||g; s|\\|/|g; s| /| \\|g' $out.d) depfile = $out.d deps = gcc rule as - command = ./run-exe.sh bin/mwcc/mwasmeppc.exe $asflags -c $in -o $out -gccdep -MD + command = (./run-exe.sh bin/mwcc/mwasmeppc.exe $asflags -c $in -o $out -gccdep -MDfile $out.d && sed -i 's|Z:||g; s|\\|/|g; s| /| \\|g' $out.d) depfile = $out.d deps = gcc rule elf2dol command = cargo run --quiet --release --bin elf2dol -- $in $out + depfile = target/release/elf2dol.d + deps = gcc rule mergeobj command = ld.lld -relocatable $in -o $out + +rule create_ninja + command = cargo run --quiet + generator = true + depfile = target/debug/buildgen.d + deps = gcc + +build build.ninja build/objects.txt: create_ninja | data/ranges.csv diff --git a/src/bin/buildgen.rs b/src/bin/buildgen.rs index 1772ad29..4062a71a 100644 --- a/src/bin/buildgen.rs +++ b/src/bin/buildgen.rs @@ -1,6 +1,6 @@ use std::{ fs::File, - io::{BufRead, BufReader}, + io::{BufReader, BufWriter, Write}, num::ParseIntError, }; @@ -79,6 +79,7 @@ fn main() -> Result<()> { } let mut rdr = csv::Reader::from_reader(BufReader::new(File::open("data/ranges.csv")?)); + let mut objects = Vec::new(); for (i, result) in rdr.records().enumerate() { let result = result?; @@ -105,6 +106,10 @@ fn main() -> Result<()> { } if !to_merge.is_empty() { ninja.emit_merge(format!("build/obj/{}.o", i), &to_merge)?; + objects.push(format!("build/obj/{}.o", i)); + } + if !result[26].is_empty() { + objects.push(format!("build/obj/{}", &result[26])); } } @@ -117,14 +122,14 @@ fn main() -> Result<()> { } ninja.emit_genlcf("build/donut.lcf")?; - ninja.emit_ccld( - "build/donut.elf", - "build/donut.lcf", - &BufReader::new(File::open("data/objects.txt")?) - .lines() - .collect::, std::io::Error>>()?, - )?; + ninja.emit_ccld("build/donut.elf", "build/donut.lcf", &objects)?; ninja.emit_elf2dol("build/donut.dol", "build/donut.elf")?; + let mut writer = BufWriter::new(File::create("build/objects.txt")?); + for object in objects { + writer.write_all(object.as_bytes())?; + writer.write_all(b"\n")?; + } + Ok(()) } diff --git a/src/bin/genlcf.rs b/src/bin/genlcf.rs index bfa8c54a..f7408681 100644 --- a/src/bin/genlcf.rs +++ b/src/bin/genlcf.rs @@ -75,7 +75,7 @@ MEMORY { } out.write_all(b"}\n")?; - let reader = BufReader::new(File::open("data/objects.txt")?); + let reader = BufReader::new(File::open("build/objects.txt")?); out.write_all(b"FORCEFILES { \n")?; for line in reader.lines() { let line = line?; diff --git a/src/ninja/mod.rs b/src/ninja/mod.rs index 2901a58a..f5e726dd 100644 --- a/src/ninja/mod.rs +++ b/src/ninja/mod.rs @@ -226,7 +226,7 @@ impl NinjaFile { } self.writer.write_all( format!( - "| {} data/objects.txt || {}\n lcf={}\n map=build/donut.map\n", + "| {} build/objects.txt || {}\n lcf={}\n map=build/donut.map\n", lcffile.display(), parent.display(), lcffile.display()