Merge remote-tracking branch 'upstream/main' into bmg

This commit is contained in:
Yanis002
2025-02-04 00:43:39 +01:00
344 changed files with 9776 additions and 5389 deletions
+17 -1
View File
@@ -27,7 +27,7 @@ CC_FLAGS = " ".join([
"-proc arm946e", # Target processor
"-gccext,on", # Enable GCC extensions
"-fp soft", # Compute float operations in software
"-inline on,noauto", # Inline only functions marked with 'inline'
"-inline noauto", # Inline only functions marked with 'inline'
"-lang=c++", # Set language to C++
"-Cpp_exceptions off", # Disable C++ exceptions
"-RTTI off", # Disable runtime type information
@@ -179,6 +179,12 @@ def main():
)
n.newline()
n.rule(
name="sha1",
command=f"{PYTHON} tools/sha1.py $in -c $sha1_file"
)
n.newline()
game_build = build_path / game_version
game_extract = extract_path / game_version
@@ -249,6 +255,16 @@ def add_mwld_and_rom_builds(n: ninja_syntax.Writer, game_build: Path, game_confi
)
n.newline()
n.build(
inputs=rom_file,
rule="sha1",
variables={
"sha1_file": str(Path(rom_file).with_suffix(".sha1"))
},
outputs="sha1",
)
n.newline()
def add_mwcc_builds(n: ninja_syntax.Writer, game_version: str, game_build: Path, mwcc_implicit: list[Path]):
for source_file in get_c_cpp_files([src_path, libs_path]):
+4 -3
View File
@@ -21,7 +21,8 @@ CXX_FLAGS = [
'-nostdinc',
'-Iinclude',
'-Ilibs/c/include',
'-Ilibs/cpp/include'
'-Ilibs/cpp/include',
'-Ilibs/nds/include'
]
script_dir = Path(os.path.dirname(os.path.realpath(__file__)))
@@ -37,8 +38,8 @@ COMMENT_REGEX = r'\/\/.*$|\/\*(?:.|\r|\n)+?\*\/'
with open(args.file, 'r') as f:
contents = f.read()
contents = re.sub(COMMENT_REGEX, '', contents, 0, re.MULTILINE)
includes = re.findall(INCLUDE_REGEX, contents, re.MULTILINE)
contents = re.sub(COMMENT_REGEX, '', contents, count=0, flags=re.MULTILINE)
includes = re.findall(INCLUDE_REGEX, contents, flags=re.MULTILINE)
_, suffix = os.path.splitext(args.file)
+20 -10
View File
@@ -15,6 +15,7 @@ include_dir = root_dir / 'include'
libs_dir = root_dir / 'libs'
libc_include_dir = libs_dir / 'c' / 'include'
libcpp_include_dir = libs_dir / 'cpp' / 'include'
libnds_include_dir = libs_dir / 'nds' / 'include'
if platform.system() == 'Windows': cc = [str(cc_path)]
else: cc = ['wine', str(cc_path)]
@@ -27,7 +28,7 @@ cc.extend([
'-proc', 'arm946e',
'-gccext,on',
'-fp', 'soft',
'-inline', 'on,noauto',
'-inline', 'noauto',
'-Cpp_exceptions', 'off',
'-RTTI', 'off',
'-interworking',
@@ -38,6 +39,7 @@ cc.extend([
'-i', include_dir,
'-i', libc_include_dir,
'-i', libcpp_include_dir,
'-i', libnds_include_dir,
args.file
])
@@ -52,19 +54,27 @@ output = output.decode()
# print(output)
mangled_funcs: list[str] = re.findall(r'.text +([^\$ ]\S+)', output)
mangled_data: list[str] = re.findall(r'(?:.data|.bss) +([^\. ]\S+)', output)
init_funcs: list[str] = re.findall(r'.init +([^\$ ]\S+)', output)
mangled_data: list[str] = re.findall(r'.data +([^\. ]\S+)', output)
mangled_bss: list[str] = re.findall(r'.bss +([^\. ]\S+)', output)
if len(mangled_funcs) > 0:
print('Functions:')
print()
print('.text:\n')
for func in mangled_funcs:
print(func)
print()
print()
print('\n')
if len(init_funcs) > 0:
print('.init:\n')
for func in init_funcs:
print(func)
print('\n')
if len(mangled_data) > 0:
print('Data:')
print()
print('.data:\n')
for data in mangled_data:
print(data)
print()
print()
print('\n')
if len(mangled_bss) > 0:
print('.bss:\n')
for bss in mangled_bss:
print(bss)
print('\n')
+1 -1
View File
@@ -4,7 +4,7 @@ import io
from pathlib import Path
import platform
DSD_VERSION = 'v0.2.3'
DSD_VERSION = 'v0.4.0'
tools_path = Path(__file__).parent
+29
View File
@@ -0,0 +1,29 @@
#!/usr/bin/env python
from pathlib import Path
import argparse
import hashlib
import sys
def eprint(*args, **kwargs):
print(*args, file=sys.stderr, **kwargs)
parser = argparse.ArgumentParser(description="Computes and verifies a SHA1 checksum")
parser.add_argument('file', help="Input file to verify")
parser.add_argument('-c', type=str, dest='checksum_file', required=False, help='Checksum file')
args = parser.parse_args()
file_path = Path(args.file)
checksum_path = Path(args.checksum_file)
with checksum_path.open('r') as file:
target_sha1, _ = file.readline().split(' ', 1)
with file_path.open('rb') as file:
file_sha1 = hashlib.sha1(file.read()).hexdigest()
if target_sha1 != file_sha1:
eprint(f"{file_path}: FAILED")
exit(1)
else:
eprint(f"{file_path}: OK")