Improve the build system

This commit is contained in:
Charlotte Delenk 2021-10-20 15:46:48 +02:00
parent d317174681
commit 7144e7f1da
Signed by: darkkirb
GPG key ID: 015E3768A70AFBC5
7 changed files with 36 additions and 54 deletions

View file

@ -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

View file

@ -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 .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 80004000,80004380,,,,,80006a8c,80006aa8,,,,,,,,,,,,,,,,,,,sdk/msl/runtime/__mem.o
,,,,,,80007214,800079fc,,,,,80406580,80406598,,,,,,,,,,,,,sdk/msl/runtime/runtime.o ,,,,,,80007214,800079fc,,,,,80406580,80406598,,,,,,,,,,,,,sdk/msl/runtime/runtime.o
80004380,800062c0,,,,,,,,,,,,,,,,,,,,,,,,,sdk/trk/__exception.o 80004380,800062c0,,,,,,,,,,,,,,,,,,,,,,,,,sdk/trk/__exception.o
@ -14,10 +14,10 @@
,,,,,,801776bc,80177810,,,,,,,80452cf7,80452d18,,,,,8055d13c,8055d141,,,,,donut/app/EntryPoint.o ,,,,,,801776bc,80177810,,,,,,,80452cf7,80452d18,,,,,8055d13c,8055d141,,,,,donut/app/EntryPoint.o
,,,,,,801778d8,8017793c,,,,,,,,,,,,,,,,,,,donut/app/EntryPoint2.o ,,,,,,801778d8,8017793c,,,,,,,,,,,,,,,,,,,donut/app/EntryPoint2.o
,,,,,,8017bbdc,8017bd88,,,,,,,,,,,,,,,,,,,donut/app/System.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 ,,,,,,8019607c,801961fc,,,,,,,,,,,,,8055d1b4,8055d1b9,,,,,donut/gfx/GXFifoMemoryManager.o
,,,,,,801962a8,80196404,,,,,,,,,,,,,,,8055f720,8055f730,,,donut/gfx/RenderSetting.o ,,,,,,801962a8,80196404,,,,,,,,,,,,,,,8055f720,8055f730,,,donut/gfx/RenderSetting.o
,,,,,,80197d50,80197ef4,,,,,,,,,,,,,,,,,,,donut/gfx/XFBManager.o ,,,,,,80197d50,80197ef4,,,,,,,,,,,,,,,,,,,donut/gfx/XFBManager.o
,,,,,,801bf250,801bf2bc,,,,,,,,,80545bf8,80545ed0,,,8055d2a0,8055d2a1,,,,,donut/mem/Memory.o ,,,,,,801bf250,801bf2bc,,,,,,,,,80545bf8,80545ed0,,,8055d2a0,8055d2a1,,,,,donut/mem/Memory.o
80006684,80006728,,,,,,,8040652c,80406530,80406548,8040654c,,,,,,,,,,,,,,,Linker generated symbol 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,End of 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,
1 .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
2 80406540 80406544 Linker generated symbol file
3 80004000 80004380 80006a8c 80006aa8 sdk/msl/runtime/__mem.o
4 80007214 800079fc 80406580 80406598 sdk/msl/runtime/runtime.o
5 80004380 800062c0 sdk/trk/__exception.o
14 801776bc 80177810 80452cf7 80452d18 8055d13c 8055d141 donut/app/EntryPoint.o
15 801778d8 8017793c donut/app/EntryPoint2.o
16 8017bbdc 8017bd88 donut/app/System.o
17 8055d1b0 8055d1b4 donut/gfx/Root.cpp donut/g3d/Root.o
18 8019607c 801961fc 8055d1b4 8055d1b9 donut/gfx/GXFifoMemoryManager.o
19 801962a8 80196404 8055f720 8055f730 donut/gfx/RenderSetting.o
20 80197d50 80197ef4 donut/gfx/XFBManager.o
21 801bf250 801bf2bc 80545bf8 80545ed0 8055d2a0 8055d2a1 donut/mem/Memory.o
22 80006684 80006728 8040652c 80406530 80406548 8040654c Linker generated symbol file
23 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

View file

@ -9,4 +9,4 @@ template <class T> struct ExplicitSingleton : NonCopyable {
~ExplicitSingleton(); ~ExplicitSingleton();
}; };
} // namespace common } // namespace common
} // namespace hel } // namespace hel

View file

@ -1,27 +1,41 @@
rule extract-object rule extract-object
command = cargo run --quiet --release --bin extract-dol -- $in $out $start $end command = cargo run --quiet --release --bin extract-dol -- $in $out $start $end
depfile = target/release/extract-dol.d
deps = gcc
rule directory rule directory
command = mkdir $out command = mkdir $out
rule genlcf rule genlcf
command = cargo run --quiet --release --bin genlcf -- $out command = cargo run --quiet --release --bin genlcf -- $out
depfile = target/release/genlcf.d
deps = gcc
rule ccld 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 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 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 depfile = $out.d
deps = gcc deps = gcc
rule as 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 depfile = $out.d
deps = gcc deps = gcc
rule elf2dol rule elf2dol
command = cargo run --quiet --release --bin elf2dol -- $in $out command = cargo run --quiet --release --bin elf2dol -- $in $out
depfile = target/release/elf2dol.d
deps = gcc
rule mergeobj rule mergeobj
command = ld.lld -relocatable $in -o $out 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

View file

@ -1,6 +1,6 @@
use std::{ use std::{
fs::File, fs::File,
io::{BufRead, BufReader}, io::{BufReader, BufWriter, Write},
num::ParseIntError, 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 rdr = csv::Reader::from_reader(BufReader::new(File::open("data/ranges.csv")?));
let mut objects = Vec::new();
for (i, result) in rdr.records().enumerate() { for (i, result) in rdr.records().enumerate() {
let result = result?; let result = result?;
@ -105,6 +106,10 @@ fn main() -> Result<()> {
} }
if !to_merge.is_empty() { if !to_merge.is_empty() {
ninja.emit_merge(format!("build/obj/{}.o", i), &to_merge)?; 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_genlcf("build/donut.lcf")?;
ninja.emit_ccld( ninja.emit_ccld("build/donut.elf", "build/donut.lcf", &objects)?;
"build/donut.elf",
"build/donut.lcf",
&BufReader::new(File::open("data/objects.txt")?)
.lines()
.collect::<Result<Vec<_>, std::io::Error>>()?,
)?;
ninja.emit_elf2dol("build/donut.dol", "build/donut.elf")?; 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(()) Ok(())
} }

View file

@ -75,7 +75,7 @@ MEMORY {
} }
out.write_all(b"}\n")?; 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")?; out.write_all(b"FORCEFILES { \n")?;
for line in reader.lines() { for line in reader.lines() {
let line = line?; let line = line?;

View file

@ -226,7 +226,7 @@ impl NinjaFile {
} }
self.writer.write_all( self.writer.write_all(
format!( 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(), lcffile.display(),
parent.display(), parent.display(),
lcffile.display() lcffile.display()