mirror of
https://github.com/pret/pokeplatinum.git
synced 2026-04-25 07:29:01 -05:00
Remove unnecessary build system fixes
This commit is contained in:
parent
9581ed2178
commit
69ad69e2ed
6
build.sh
6
build.sh
|
|
@ -8,12 +8,6 @@ cd build
|
|||
# Build rom
|
||||
ninja
|
||||
|
||||
export NINJA_STATUS="
|
||||
"
|
||||
|
||||
# Fix dependency paths on non-Windows platforms
|
||||
#ninja fixdep
|
||||
|
||||
export NINJA_STATUS=""
|
||||
|
||||
# Fix rom header secure area CRC
|
||||
|
|
|
|||
|
|
@ -34,6 +34,6 @@ fi
|
|||
if [ "$native_file" = "native_wine.ini" ]; then
|
||||
cat > build/.mwconfig << EOF
|
||||
path_unix="$PWD"
|
||||
path_win="$(winepath -w "$PWD")"
|
||||
path_win="$("${WINE:-wine}" winepath -w "$PWD")"
|
||||
EOF
|
||||
fi
|
||||
|
|
|
|||
|
|
@ -192,10 +192,6 @@ pokeplatinum_nds = custom_target('pokeplatinum.us.nds',
|
|||
############################################################
|
||||
### RUN TARGETS ###
|
||||
############################################################
|
||||
fixdep_target = run_target('fixdep',
|
||||
command: [fixdep_py, '.ninja_deps']
|
||||
)
|
||||
|
||||
fixrom_target = run_target('fixrom',
|
||||
command: [fixrom_exe, pokeplatinum_nds,'--secure-crc', '0xF8B8', '--game-code', 'CPUE']
|
||||
)
|
||||
|
|
|
|||
|
|
@ -1,83 +0,0 @@
|
|||
#!/usr/bin/env python3
|
||||
|
||||
import argparse
|
||||
import os
|
||||
import platform
|
||||
import re
|
||||
|
||||
|
||||
class PathRecord:
|
||||
def __init__(self, id: int, path: str):
|
||||
self.id = id
|
||||
self.path = path
|
||||
|
||||
def fix(self):
|
||||
root = '/mnt/c/' if is_wsl_accessing_windows() else '/'
|
||||
self.path = re.sub(r'[A-Z]:[/\\]', root, self.path).replace('\\', '/')
|
||||
|
||||
def to_bytearray(self) -> bytearray:
|
||||
byte_array = bytearray()
|
||||
|
||||
byte_array.extend((len(self.path) + len(self.path) % 4 + 0x4).to_bytes(4, byteorder='little'))
|
||||
byte_array.extend(self.path.encode('utf-8'))
|
||||
byte_array.extend(bytearray(len(self.path) % 4))
|
||||
byte_array.extend((~self.id).to_bytes(4, byteorder='little', signed=True))
|
||||
|
||||
return byte_array
|
||||
|
||||
|
||||
class DepsRecord:
|
||||
def __init__(self, id: int, data: bytes):
|
||||
self.id = id
|
||||
self.data = data
|
||||
|
||||
def to_bytearray(self) -> bytearray:
|
||||
byte_array = bytearray(self.id.to_bytes(4, 'little'))
|
||||
byte_array.extend(self.data)
|
||||
return byte_array
|
||||
|
||||
|
||||
def is_wsl_accessing_windows() -> bool:
|
||||
return ("microsoft" in platform.uname()[2].lower() and os.path.realpath(os.path.abspath(__file__)).startswith("/mnt/"))
|
||||
|
||||
|
||||
def main():
|
||||
if platform.system().lower() == 'windows':
|
||||
return
|
||||
|
||||
args = parse_args()
|
||||
with open(args.depfile, 'rb+') as ninja_deps:
|
||||
assert ninja_deps.read(0xC).decode('utf-8') == '# ninjadeps\n'
|
||||
ninja_version = int.from_bytes(ninja_deps.read(0x4), 'little')
|
||||
|
||||
records = list()
|
||||
path_counter = 0
|
||||
while entry_key_bytes := ninja_deps.read(0x4):
|
||||
entry_key = int.from_bytes(entry_key_bytes, 'little')
|
||||
if (entry_key >> 31) & 1:
|
||||
# deps record
|
||||
entry_len = entry_key & 0xFFFF
|
||||
records.append(DepsRecord(entry_key, ninja_deps.read(entry_len)))
|
||||
else:
|
||||
# path record
|
||||
path = ninja_deps.read(entry_key - 0x4).decode('utf-8').rstrip()
|
||||
records.append(PathRecord(path_counter, path))
|
||||
path_counter += 1
|
||||
ninja_deps.read(0x4) # Skip checksum
|
||||
|
||||
ninja_deps.seek(0x10)
|
||||
|
||||
for record in records:
|
||||
if isinstance(record, PathRecord):
|
||||
record.fix()
|
||||
ninja_deps.write(record.to_bytearray())
|
||||
|
||||
|
||||
def parse_args():
|
||||
parser = argparse.ArgumentParser()
|
||||
parser.add_argument("depfile", type=str, help="Path to the .ninja_deps file")
|
||||
return parser.parse_args()
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
|
|
@ -1 +0,0 @@
|
|||
fixdep_py = find_program('fixdep.py', native: true)
|
||||
|
|
@ -1,9 +1,8 @@
|
|||
# Native tools
|
||||
subdir('fixdep')
|
||||
subdir('fixrom')
|
||||
subdir('postconf')
|
||||
|
||||
# Prebuilt tools
|
||||
makebanner_exe = find_program('makebanner', native: true)
|
||||
makelcf_exe = find_program('makelcf', native: true)
|
||||
makerom_exe = find_program('makerom', native: true)
|
||||
makerom_exe = find_program('makerom', native: true)
|
||||
|
|
|
|||
|
|
@ -9,13 +9,6 @@ SOURCE_DIRECTORY = os.environ["MESON_SOURCE_ROOT"]
|
|||
COMPILER_RULE_PATTERN = r'rule c_COMPILER[\r\n]+(?:\s\w+ =.+[\r\n]+){4}'
|
||||
|
||||
|
||||
def add_compiler_rules(fileString: str) -> str:
|
||||
rule = re.search(COMPILER_RULE_PATTERN, fileString).group(0)
|
||||
fileString = fileString.replace(rule, rule + rule.replace('sp2p2', 'sp2').replace('c_COMPILER', 'c_COMPILER_NitroSDK'))
|
||||
fileString = re.sub(r'(build lib/external/NitroSDK.+?c_COMPILER\b)', r'\1_NitroSDK', fileString)
|
||||
return fileString
|
||||
|
||||
|
||||
def backslash_to_forward_slash(fileString: str) -> str:
|
||||
return fileString.replace('\\\\', '/')
|
||||
|
||||
|
|
@ -38,11 +31,9 @@ def main():
|
|||
compile_commands_string = compile_commands_in.read()
|
||||
|
||||
# build.ninja edits
|
||||
build_ninja_string = add_compiler_rules(build_ninja_string)
|
||||
build_ninja_string = backslash_to_forward_slash(build_ninja_string)
|
||||
build_ninja_string = fix_static_libs(build_ninja_string)
|
||||
build_ninja_string = nasm_to_asm(build_ninja_string)
|
||||
build_ninja_string = silence_static_linking_warnings(build_ninja_string)
|
||||
|
||||
# compile_commands.json edits
|
||||
compile_commands_string = backslash_to_forward_slash(compile_commands_string)
|
||||
|
|
@ -61,19 +52,10 @@ def nasm_to_asm(fileString: str) -> str:
|
|||
return fileString.replace('Nasm', 'ASM')
|
||||
|
||||
|
||||
def rename_objects(fileString: str) -> str:
|
||||
'''Remove filepaths from object names'''
|
||||
return re.sub(r'(?:src|asm)_(?:overlay\d+_)*(\w+\.[cs]\.[do])', r'\1', fileString)
|
||||
|
||||
|
||||
def relativize_pch_paths(fileString: str) -> str:
|
||||
'''Make paths to headers to be precompiled relative (for WSL)'''
|
||||
return re.sub(r'c_PCH [\w/]+?lib', r'c_PCH ../lib', fileString)
|
||||
|
||||
|
||||
def silence_static_linking_warnings(fileString: str) -> str:
|
||||
return re.sub(r'mwldarm\.exe(")* \$LINK_ARGS', r'mwldarm.exe\1 $LINK_ARGS -w nocmdline', fileString)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
main()
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user