macOS support, small fixes
This commit is contained in:
committed by
Timothy O'Barr
parent
a12dc1c6b2
commit
ade1415ed8
@@ -1,7 +1,11 @@
|
|||||||
# Disable printing "Entering/Leaving directory ..."
|
# Disable printing "Entering/Leaving directory ..."
|
||||||
MAKEFLAGS += --no-print-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 := \
|
CHECK_ENV_CMDS := \
|
||||||
python3 \
|
python3 \
|
||||||
@@ -97,7 +101,7 @@ configure: ## Configure project (needs SLUS_210.07)
|
|||||||
.build-only:
|
.build-only:
|
||||||
@cd config/; \
|
@cd config/; \
|
||||||
ninja -t clean; \
|
ninja -t clean; \
|
||||||
ninja -j$(NUMPROC)
|
ninja -v -j$(NUMPROC)
|
||||||
|
|
||||||
.check-files-on-error:
|
.check-files-on-error:
|
||||||
ls -l config/build/SLUS_210.07 config/SLUS_210.07
|
ls -l config/build/SLUS_210.07 config/SLUS_210.07
|
||||||
|
|||||||
@@ -1,3 +1,28 @@
|
|||||||
INCLUDE "undefined_syms.txt"
|
MEMORY
|
||||||
INCLUDE "undefined_syms_auto.txt"
|
{
|
||||||
INCLUDE "undefined_funcs_auto.txt"
|
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
@@ -64,8 +64,10 @@ CROSS = "mips-ps2-decompals-"
|
|||||||
COMPILER = "mwcps2-3.0b52-030722"
|
COMPILER = "mwcps2-3.0b52-030722"
|
||||||
COMPILER_FLAGS = "-O3,p -sym on -str readonly"
|
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] = {
|
LANGUAGES: dict[str, str] = {
|
||||||
"SLUS_210.07": "",
|
"SLUS_210.07": "",
|
||||||
@@ -209,7 +211,7 @@ def build_stuff(
|
|||||||
ninja = ninja_syntax.Writer(open(str(ROOT / config_dir / "build.ninja"), "w"), width=9999)
|
ninja = ninja_syntax.Writer(open(str(ROOT / config_dir / "build.ninja"), "w"), width=9999)
|
||||||
|
|
||||||
# Rules
|
# 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"))
|
ld = Path("..", (Path("tools") / "cc" / COMPILER / "mwldps2.exe"))
|
||||||
cpp = Path("..", (Path("tools") / "cc" / COMPILER / "mwccps2.exe"))
|
cpp = Path("..", (Path("tools") / "cc" / COMPILER / "mwccps2.exe"))
|
||||||
@@ -220,7 +222,7 @@ def build_stuff(
|
|||||||
# NOTE: Japanese strings are EUC-JP encoded!!
|
# NOTE: Japanese strings are EUC-JP encoded!!
|
||||||
# We need to convert them from (-f) UTF-8 to (-t) EUC-JP while compiling,
|
# We need to convert them from (-f) UTF-8 to (-t) EUC-JP while compiling,
|
||||||
# otherwise Japanese strings will be compiled wrong!
|
# 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(
|
ninja.rule(
|
||||||
@@ -275,7 +277,7 @@ def build_stuff(
|
|||||||
ninja.rule(
|
ninja.rule(
|
||||||
"elf",
|
"elf",
|
||||||
description="elf $out",
|
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:
|
for entry in linker_entries:
|
||||||
@@ -320,12 +322,18 @@ def build_stuff(
|
|||||||
print(f"ERROR: Unsupported build segment type {seg.type}")
|
print(f"ERROR: Unsupported build segment type {seg.type}")
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
|
built_object_paths = [str(obj) for obj in built_objects]
|
||||||
|
|
||||||
ninja.build(
|
ninja.build(
|
||||||
pre_elf_path,
|
pre_elf_path,
|
||||||
"ld",
|
"ld",
|
||||||
ld_path,
|
ld_path.replace(".ld",".lcf"),
|
||||||
implicit=[str(obj) for obj in built_objects],
|
implicit=built_object_paths,
|
||||||
variables={"mapfile": map_path},
|
variables={
|
||||||
|
"mapfile": map_path,
|
||||||
|
"objects": [str(obj) for obj in built_objects],
|
||||||
|
"lcf": LCF
|
||||||
|
},
|
||||||
)
|
)
|
||||||
|
|
||||||
ninja.build(
|
ninja.build(
|
||||||
@@ -782,8 +790,6 @@ def generate_lcf():
|
|||||||
objects = entries_by_section_type[section_type]
|
objects = entries_by_section_type[section_type]
|
||||||
if not objects:
|
if not objects:
|
||||||
continue
|
continue
|
||||||
if section_type == ".bss":
|
|
||||||
alignment = args.bss_alignment
|
|
||||||
|
|
||||||
block = [
|
block = [
|
||||||
f"\t\t# {section_type}",
|
f"\t\t# {section_type}",
|
||||||
@@ -802,8 +808,8 @@ def generate_lcf():
|
|||||||
|
|
||||||
generated_lcf = "\n\n".join(lcf_blocks)
|
generated_lcf = "\n\n".join(lcf_blocks)
|
||||||
|
|
||||||
template_path = args.template_path
|
template_path = Path("config") / LCF.replace(".lcf", ".inc.lcf")
|
||||||
output_path = args.lcf_output_path
|
output_path = Path("config") / LCF
|
||||||
|
|
||||||
template = template_path.read_text()
|
template = template_path.read_text()
|
||||||
output = template.replace(
|
output = template.replace(
|
||||||
@@ -812,8 +818,7 @@ def generate_lcf():
|
|||||||
)
|
)
|
||||||
output_path.write_text(output)
|
output_path.write_text(output)
|
||||||
|
|
||||||
if args.verbose:
|
print(f"✅ Mulberry/generate: wrote LCF to {output_path}")
|
||||||
print(f"✅ Mullberry/generate: wrote LCF to {output_path}")
|
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
|
|||||||
@@ -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
|
|
||||||
Reference in New Issue
Block a user