summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--BUILDING.md9
-rw-r--r--CMakeLists.txt10
-rwxr-xr-xOTRExporter/extract_assets.py17
3 files changed, 31 insertions, 5 deletions
diff --git a/BUILDING.md b/BUILDING.md
index 13d852748..dfdb18429 100644
--- a/BUILDING.md
+++ b/BUILDING.md
@@ -45,6 +45,9 @@ cd Shipwright
# If you need to clean the project you can run
& 'C:\Program Files\CMake\bin\cmake.exe' --build .\build\x64 --target clean
+
+# If you need to regenerate the asset headers to check them into source
+& 'C:\Program Files\CMake\bin\cmake.exe' --build .\build\x64 --target ExtractAssetHeaders
```
### Developing SoH
@@ -104,6 +107,9 @@ cmake --build build-cmake # --config Release (if you're packaging)
# If you need to clean the project you can run
cmake --build build-cmake --target clean
+
+# If you need to regenerate the asset headers to check them into source
+cmake --build build-cmake --target ExtractAssetHeaders
```
### Generating a distributable
@@ -148,6 +154,9 @@ cp build-cmake/soh/oot.otr ~/Library/Application\ Support/com.shipofharkinian.so
# If you need to clean the project you can run
cmake --build build-cmake --target clean
+
+# If you need to regenerate the asset headers to check them into source
+cmake --build build-cmake --target ExtractAssetHeaders
```
### Generating a distributable
diff --git a/CMakeLists.txt b/CMakeLists.txt
index b88d9760a..c96c4be03 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -105,6 +105,7 @@ endif()
find_package(Python3 COMPONENTS Interpreter)
+# Target to generate OTRs
add_custom_target(
ExtractAssets
# CMake versions prior to 3.17 do not have the rm command, use remove instead for older versions
@@ -117,6 +118,15 @@ add_custom_target(
BYPRODUCTS oot.otr ${CMAKE_SOURCE_DIR}/oot.otr oot-mq.otr ${CMAKE_SOURCE_DIR}/oot-mq.otr ${CMAKE_SOURCE_DIR}/soh.otr
)
+# Target to generate headers
+add_custom_target(
+ ExtractAssetHeaders
+ COMMAND ${Python3_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/OTRExporter/extract_assets.py -z "$<TARGET_FILE:ZAPD>" --non-interactive --gen-headers
+ WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/OTRExporter
+ COMMENT "Generating asset headers..."
+ DEPENDS ZAPD
+)
+
if(CMAKE_SYSTEM_NAME MATCHES "Linux")
find_package(ImageMagick COMPONENTS convert)
if (ImageMagick_FOUND)
diff --git a/OTRExporter/extract_assets.py b/OTRExporter/extract_assets.py
index 4983e6c94..53553da82 100755
--- a/OTRExporter/extract_assets.py
+++ b/OTRExporter/extract_assets.py
@@ -8,16 +8,22 @@ import struct
import subprocess
import argparse
-def BuildOTR(xmlPath, rom, zapd_exe=None):
+def BuildOTR(xmlPath, rom, zapd_exe=None, genHeaders=None):
shutil.copytree("assets", "Extract/assets")
if not zapd_exe:
zapd_exe = "x64\\Release\\ZAPD.exe" if sys.platform == "win32" else "../ZAPDTR/ZAPD.out"
exec_cmd = [zapd_exe, "ed", "-i", xmlPath, "-b", rom, "-fl", "CFG/filelists",
- "-o", "placeholder", "-osf", "placeholder", "-gsf", "1",
- "-rconf", "CFG/Config.xml", "-se", "OTR", "--otrfile",
- "oot-mq.otr" if Z64Rom.isMqRom(rom) else "oot.otr"]
+ "-o", "placeholder", "-osf", "placeholder", "-rconf", "CFG/Config.xml"]
+
+ # generate headers, but not otrs by excluding the otr exporter
+ if genHeaders:
+ exec_cmd.extend(["-gsf", "1"])
+ else:
+ # generate otrs, but not headers
+ exec_cmd.extend(["-gsf", "0", "-se", "OTR", "--otrfile",
+ "oot-mq.otr" if Z64Rom.isMqRom(rom) else "oot.otr"])
print(exec_cmd)
exitValue = subprocess.call(exec_cmd)
@@ -33,6 +39,7 @@ def main():
parser.add_argument("rom", help="Path to the rom", type=str, nargs="?")
parser.add_argument("--non-interactive", help="Runs the script non-interactively for use in build scripts.", dest="non_interactive", action="store_true")
parser.add_argument("-v", "--verbose", help="Display rom's header checksums and their corresponding xml folder", dest="verbose", action="store_true")
+ parser.add_argument("--gen-headers", help="Generate source headers to be checked in", dest="gen_headers", action="store_true")
args = parser.parse_args()
@@ -41,7 +48,7 @@ def main():
if (os.path.exists("Extract")):
shutil.rmtree("Extract")
- BuildOTR("../soh/assets/xml/" + rom.version.xml_ver + "/", rom.file_path, zapd_exe=args.zapd_exe)
+ BuildOTR("../soh/assets/xml/" + rom.version.xml_ver + "/", rom.file_path, zapd_exe=args.zapd_exe, genHeaders=args.gen_headers)
if __name__ == "__main__":
main()