macOS support, small fixes

This commit is contained in:
alessamothdream
2026-07-25 17:01:01 -05:00
committed by Timothy O'Barr
parent a12dc1c6b2
commit ade1415ed8
4 changed files with 53 additions and 39 deletions
+6 -2
View File
@@ -1,7 +1,11 @@
# Disable printing "Entering/Leaving directory ..."
MAKEFLAGS += --no-print-directory
NUMPROC ?= $(shell nproc)
ARCH ?= $(shell uname -m)
KERNEL ?= $(shell uname -s)
PLATFORM ?= $(if $(filter $(KERNEL),Darwin),macos,linux)
OS ?= $(PLATFORM)-$(subst _,-,$(ARCH))
NUMPROC ?= $(if $(filter $(PLATFORM),linux),$(shell nproc),$(shell sysctl -n hw.logicalcpu))
CHECK_ENV_CMDS := \
python3 \
@@ -97,7 +101,7 @@ configure: ## Configure project (needs SLUS_210.07)
.build-only:
@cd config/; \
ninja -t clean; \
ninja -j$(NUMPROC)
ninja -v -j$(NUMPROC)
.check-files-on-error:
ls -l config/build/SLUS_210.07 config/SLUS_210.07
+28 -3
View File
@@ -1,3 +1,28 @@
INCLUDE "undefined_syms.txt"
INCLUDE "undefined_syms_auto.txt"
INCLUDE "undefined_funcs_auto.txt"
MEMORY
{
main (RWX) : ORIGIN = 0x100000, LENGTH = 0x0
}
KEEP_SECTION
{
.rodata,
.data,
.vutext,
.vudata,
.vubss
}
SECTIONS
{
.main :
{
_gp = 0x25f4f0;
. = ALIGN(0x80);
__start = .;
### 🔴 code 🔴 ###
. = ALIGN(0x80);
} > main
}
+19 -14
View File
@@ -64,8 +64,10 @@ CROSS = "mips-ps2-decompals-"
COMPILER = "mwcps2-3.0b52-030722"
COMPILER_FLAGS = "-O3,p -sym on -str readonly"
WIBO = f"{TOOLS_DIR}/wibo-x86_64"
PLATFORM = "x86_64" # @todo get this from makefile
# PLATFORM = "macos"
WIBO = f"{TOOLS_DIR}/wibo-{PLATFORM}"
LCF = "SLUS_210.07.lcf"
LANGUAGES: dict[str, str] = {
"SLUS_210.07": "",
@@ -209,7 +211,7 @@ def build_stuff(
ninja = ninja_syntax.Writer(open(str(ROOT / config_dir / "build.ninja"), "w"), width=9999)
# Rules
ld_args = "-map -lcf $in -o $out"
ld_args = "-map -sym on,elf -noinhibit-exec -main ENTRYPOINT -o $out $lcf $objects"
ld = Path("..", (Path("tools") / "cc" / COMPILER / "mwldps2.exe"))
cpp = Path("..", (Path("tools") / "cc" / COMPILER / "mwccps2.exe"))
@@ -220,7 +222,7 @@ def build_stuff(
# NOTE: Japanese strings are EUC-JP encoded!!
# We need to convert them from (-f) UTF-8 to (-t) EUC-JP while compiling,
# otherwise Japanese strings will be compiled wrong!
command=f"{WIBO} {cpp} {common_includes} $in -o - | iconv -f=UTF-8 -t=EUC-JP | {CROSS}as -no-pad-sections -EL -march=5900 -mabi=eabi -I{src_path.parent / 'include'} -o $out",
command=f"{CROSS}as -no-pad-sections -EL -march=5900 -mabi=eabi -mno-branch-relocs -I{src_path.parent / 'include'} -Iinclude -o $out $in",
)
ninja.rule(
@@ -275,7 +277,7 @@ def build_stuff(
ninja.rule(
"elf",
description="elf $out",
command=f"{ld}objcopy $in $out -O binary && python3 {ROOT}/tools/python/fix_bin_matching.py {language} $out",
command=f"{CROSS}objcopy $in $out -O binary && python3 {ROOT}/tools/python/fix_bin_matching.py {language} $out",
)
for entry in linker_entries:
@@ -320,12 +322,18 @@ def build_stuff(
print(f"ERROR: Unsupported build segment type {seg.type}")
sys.exit(1)
built_object_paths = [str(obj) for obj in built_objects]
ninja.build(
pre_elf_path,
"ld",
ld_path,
implicit=[str(obj) for obj in built_objects],
variables={"mapfile": map_path},
ld_path.replace(".ld",".lcf"),
implicit=built_object_paths,
variables={
"mapfile": map_path,
"objects": [str(obj) for obj in built_objects],
"lcf": LCF
},
)
ninja.build(
@@ -782,8 +790,6 @@ def generate_lcf():
objects = entries_by_section_type[section_type]
if not objects:
continue
if section_type == ".bss":
alignment = args.bss_alignment
block = [
f"\t\t# {section_type}",
@@ -802,8 +808,8 @@ def generate_lcf():
generated_lcf = "\n\n".join(lcf_blocks)
template_path = args.template_path
output_path = args.lcf_output_path
template_path = Path("config") / LCF.replace(".lcf", ".inc.lcf")
output_path = Path("config") / LCF
template = template_path.read_text()
output = template.replace(
@@ -812,8 +818,7 @@ def generate_lcf():
)
output_path.write_text(output)
if args.verbose:
print(f"✅ Mullberry/generate: wrote LCF to {output_path}")
print(f"✅ Mulberry/generate: wrote LCF to {output_path}")
def main():
-20
View File
@@ -1,20 +0,0 @@
.macro glabel label
.global \label
.type \label, @function
\label:
.endm
.macro dlabel label
.global \label
\label:
.endm
.macro jlabel label
.global \label
\label:
.endm
.macro llabel label
.local \label
\label:
.endm