diff --git a/tools/build/configure.py b/tools/build/configure.py index e62d2522af9..a0be92ebe06 100755 --- a/tools/build/configure.py +++ b/tools/build/configure.py @@ -486,7 +486,6 @@ def write_ninja( skip_outputs: Set[str], non_matching: bool, modern_gcc: bool, - c_maps: bool = False, ): assert self.linker_entries is not None @@ -1039,21 +1038,21 @@ def build( }, asset_deps=[f"mapfs/tex/{name}"], ) - elif name.endswith("_shape_built"): + elif name.endswith("_shape"): base_name = name[:-6] - raw_bin_path = self.resolve_asset_path(f"assets/x/mapfs/geom/{base_name}.bin") - bin_path = bin_path.parent / "geom" / (base_name + ".bin") - if c_maps: - # raw bin -> c -> o -> elf -> objcopy -> final bin file - c_file_path = (bin_path.parent / "geom" / base_name).with_suffix(".c") - o_path = bin_path.parent / "geom" / (base_name + ".o") - elf_path = bin_path.parent / "geom" / (base_name + ".elf") - - build(c_file_path, [raw_bin_path], "shape") + # Backwards-compatibility: if there is a .bin file, use that + path_deprecated = self.resolve_asset_path(path.with_suffix(".bin")) + if path_deprecated.is_file(): + print(f"warning: {name} has a .bin file, which is deprecated. use a .c file instead.") + print(bin_path, path_deprecated) + build(bin_path, [path_deprecated], "cp") + else: + o_path = bin_path.with_suffix(".o") + elf_path = bin_path.with_suffix(".elf") build( o_path, - [c_file_path], + [path], "cc" if not modern_gcc else "cc_modern", variables={ "cflags": "", @@ -1063,8 +1062,6 @@ def build( ) build(elf_path, [o_path], "shape_ld") build(bin_path, [elf_path], "shape_objcopy") - else: - build(bin_path, [raw_bin_path], "cp") compress = True out_dir = out_dir / "geom" @@ -1399,7 +1396,7 @@ def make_current(self, ninja: ninja_syntax.Writer): sys.path.append(str((ROOT / "tools/splat_ext").resolve())) configure.split(not args.no_split_assets, args.split_code, args.shift, args.debug) - configure.write_ninja(ninja, skip_files, non_matching, args.modern_gcc, args.c_maps) + configure.write_ninja(ninja, skip_files, non_matching, args.modern_gcc) all_rom_oks.append(str(configure.rom_ok_path())) diff --git a/tools/splat_ext/pm_map_data.py b/tools/splat_ext/pm_map_data.py index 3d5e0908cc1..ba53874d2a6 100644 --- a/tools/splat_ext/pm_map_data.py +++ b/tools/splat_ext/pm_map_data.py @@ -12,6 +12,9 @@ import n64img.image from tex_archives import TexArchive +sys.path.append(os.path.join(os.path.dirname(__file__), "..", "..", "build")) # terrible +from mapfs.shape import ShapeFile + script_dir = Path(os.path.dirname(os.path.realpath(__file__))) @@ -49,15 +52,13 @@ def unpack_color(data): return palette -def add_file_ext(name: str, linker: bool = False) -> str: +def add_file_ext(name: str) -> str: if name.startswith("party_"): return "party/" + name + ".png" elif name.endswith("_hit"): return "geom/" + name + ".bin" elif name.endswith("_shape"): - if linker: - name += "_built" - return "geom/" + name + ".bin" + return "geom/" + name + ".c" elif name.endswith("_tex"): return "tex/" + name + ".bin" elif name.endswith("_bg"): @@ -213,6 +214,12 @@ def split(self, rom_bytes): elif name.endswith("_tex"): TexArchive.extract(bytes, fs_dir / "tex" / name) + elif name.endswith("_shape"): + map_name = name[:-6] + shape = ShapeFile(map_name, bytes) + shape.digest() + with open(path, "w") as f: + shape.write_to_c(f) else: assert path is not None with open(path, "wb") as f: @@ -231,7 +238,7 @@ def get_linker_entries(self): src_paths = [] for name, file in self.files.items(): - src_paths.append(fs_dir / add_file_ext(name, linker=True)) + src_paths.append(fs_dir / add_file_ext(name)) if file.get("dump_raw", False): src_paths.append(fs_dir / f"{name}.raw.dat")