mirror of
https://github.com/HarbourMasters/Shipwright.git
synced 2024-12-21 23:58:51 -05:00
chore: move asset header generation to new ExtractAssetsHeaders target (#2705)
* add dedicated build target for extracting asset headers conditionally * dont gen otr when generating headers * simplify python array
This commit is contained in:
parent
660c3ec3b0
commit
1861335cf0
@ -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
|
||||
|
@ -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)
|
||||
|
@ -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()
|
||||
|
Loading…
Reference in New Issue
Block a user