mirror of
https://github.com/zeldaret/oot.git
synced 2025-05-11 11:33:48 +00:00
Write source with static for overlays using HACK_IS_STATIC_ON
hack
This commit is contained in:
parent
956b3b4a96
commit
11e8d23027
3 changed files with 17 additions and 10 deletions
|
@ -631,6 +631,8 @@ class File:
|
|||
self, "source_c_path"
|
||||
), "set_source_path must be called before write_source"
|
||||
assert hasattr(self, "source_h_path")
|
||||
self.source_c_path.parent.mkdir(parents=True, exist_ok=True)
|
||||
self.source_h_path.parent.mkdir(parents=True, exist_ok=True)
|
||||
with self.source_c_path.open("w") as c:
|
||||
with self.source_h_path.open("w") as h:
|
||||
|
||||
|
@ -890,17 +892,17 @@ class Resource(abc.ABC):
|
|||
Binary: extracted_path_suffix = ".bin"
|
||||
with get_filename_stem() = "blob"
|
||||
extract_to_path: `extracted/VERSION/assets/.../blob.bin`
|
||||
inc_c_path: `build/VERSION/assets/.../blob.inc.c`
|
||||
inc_c_path: `assets/.../blob.inc.c`
|
||||
|
||||
C: extracted_path_suffix = ".inc.c"
|
||||
with get_filename_stem() = "data"
|
||||
extract_to_path: `extracted/VERSION/assets/.../data.inc.c`
|
||||
inc_c_path: `extracted/VERSION/assets/.../data.inc.c`
|
||||
inc_c_path: `assets/.../data.inc.c`
|
||||
|
||||
rgba16 image: extracted_path_suffix = ".png"
|
||||
with get_filename_stem() = "img.rgba16"
|
||||
extract_to_path: `extracted/VERSION/assets/.../img.rgba16.png`
|
||||
inc_c_path: `build/VERSION/assets/.../img.rgba16.inc.c`
|
||||
inc_c_path: `assets/.../img.rgba16.inc.c`
|
||||
"""
|
||||
|
||||
filename_stem = self.get_filename_stem()
|
||||
|
@ -909,11 +911,9 @@ class Resource(abc.ABC):
|
|||
extracted_path / out_path / (filename_stem + self.extracted_path_suffix)
|
||||
)
|
||||
|
||||
if self.needs_build:
|
||||
inc_c_path = build_path / out_path / (filename_stem + ".inc.c")
|
||||
else:
|
||||
if not self.needs_build:
|
||||
assert self.extracted_path_suffix == ".inc.c"
|
||||
inc_c_path = extract_to_path
|
||||
inc_c_path = out_path / (filename_stem + ".inc.c")
|
||||
|
||||
self.extract_to_path = extract_to_path
|
||||
self.inc_c_path = inc_c_path
|
||||
|
|
|
@ -376,6 +376,8 @@ class S16ArrayResource(CDataResource):
|
|||
super().__init__(file, range_start, name)
|
||||
|
||||
def get_c_declaration_base(self):
|
||||
if hasattr(self, "HACK_IS_STATIC_ON"):
|
||||
return f"s16 {self.symbol_name}[{self.cdata_ext.size // self.elem_cdata_ext.size}]"
|
||||
return f"s16 {self.symbol_name}[]"
|
||||
|
||||
def get_c_reference(self, resource_offset: int):
|
||||
|
|
|
@ -66,6 +66,13 @@ def create_file_resources(rescoll: ResourcesDescCollection, file: File):
|
|||
resource = e.resource
|
||||
list_ResourceNeedsPostProcessWithPoolResourcesException.append(e)
|
||||
|
||||
# TODO nice hack right here.
|
||||
# probably instead rework the "c declaration" system into a more opaque object
|
||||
# not that this is really a required long term feature as it's only relevant
|
||||
# for writing the source files (main .c/.h), not extracting
|
||||
if file.name.startswith("ovl_") and file.name != "ovl_file_choose":
|
||||
resource.HACK_IS_STATIC_ON = ...
|
||||
|
||||
file.add_resource(resource)
|
||||
|
||||
file_resources_by_desc[resource_desc] = resource
|
||||
|
@ -224,14 +231,12 @@ def process_pool(
|
|||
# TODO this looks jank
|
||||
for rescoll, file in file_by_rescoll.items():
|
||||
file.set_source_path(Path("assets") / rescoll.out_path)
|
||||
(Path("assets") / rescoll.out_path).mkdir(parents=True, exist_ok=True)
|
||||
|
||||
file.set_resources_paths(
|
||||
EXTRACTED_PATH,
|
||||
BUILD_PATH,
|
||||
Path("assets") / rescoll.out_path,
|
||||
)
|
||||
(EXTRACTED_PATH / rescoll.out_path).mkdir(parents=True, exist_ok=True)
|
||||
|
||||
for file, file_memctx in memctx_by_file.items():
|
||||
# write to EXTRACTED_PATH
|
||||
|
@ -253,7 +258,7 @@ def process_pool_wrapped(version_memctx_base, pd):
|
|||
import sys
|
||||
|
||||
# Some exceptions can't be pickled for passing back to the main process
|
||||
# so print them now as well
|
||||
# so print them now as well as reraising
|
||||
traceback.print_exc(file=sys.stdout)
|
||||
raise Exception(
|
||||
"ERROR with pool_desc collections:",
|
||||
|
|
Loading…
Add table
Reference in a new issue