mirror of
https://github.com/HarbourMasters/Shipwright.git
synced 2024-12-20 23:28:51 -05:00
Opt-in for an easy-way CMake target to create soh.otr file (#3057)
* use a convenient cmake target for gen soh otr * Update generate-builds.yml * Apply for all conditions * grandma change
This commit is contained in:
parent
74d6678543
commit
6923c2d3c0
5
.github/workflows/generate-builds.yml
vendored
5
.github/workflows/generate-builds.yml
vendored
@ -47,10 +47,7 @@ jobs:
|
||||
run: |
|
||||
export PATH="/usr/lib/ccache:/usr/local/opt/ccache/libexec:$PATH"
|
||||
cmake --no-warn-unused-cli -H. -Bbuild-cmake -GNinja -DCMAKE_BUILD_TYPE:STRING=Release
|
||||
cmake --build build-cmake --config Release --target ZAPD
|
||||
mkdir Extract
|
||||
cp -r OTRExporter/assets/ ./Extract/assets
|
||||
./build-cmake/ZAPD/ZAPD.out botr -se OTR --norom
|
||||
cmake --build build-cmake --config Release --target GenerateSohOtr
|
||||
- uses: actions/upload-artifact@v3
|
||||
with:
|
||||
name: soh.otr
|
||||
|
@ -132,6 +132,18 @@ add_custom_target(
|
||||
DEPENDS ZAPD
|
||||
)
|
||||
|
||||
# Target to generate only soh.otr
|
||||
add_custom_target(
|
||||
GenerateSohOtr
|
||||
# CMake versions prior to 3.17 do not have the rm command, use remove instead for older versions
|
||||
COMMAND ${CMAKE_COMMAND} -E $<IF:$<VERSION_LESS:${CMAKE_VERSION},3.17>,remove,rm> -f soh.otr
|
||||
COMMAND ${Python3_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/OTRExporter/extract_assets.py -z "$<TARGET_FILE:ZAPD>" --norom
|
||||
COMMAND ${CMAKE_COMMAND} -DSYSTEM_NAME=${CMAKE_SYSTEM_NAME} -DTARGET_DIR="$<TARGET_FILE_DIR:ZAPD>" -DSOURCE_DIR=${CMAKE_CURRENT_SOURCE_DIR} -DBINARY_DIR=${CMAKE_BINARY_DIR} -DONLYSOHOTR=On -P ${CMAKE_CURRENT_SOURCE_DIR}/copy-existing-otrs.cmake
|
||||
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/OTRExporter
|
||||
COMMENT "Generating soh.otr..."
|
||||
DEPENDS ZAPD
|
||||
)
|
||||
|
||||
if(CMAKE_SYSTEM_NAME MATCHES "Linux")
|
||||
find_package(ImageMagick COMPONENTS convert)
|
||||
if (ImageMagick_FOUND)
|
||||
|
@ -33,6 +33,22 @@ def BuildOTR(xmlPath, rom, zapd_exe=None, genHeaders=None):
|
||||
print("Aborting...", file=os.sys.stderr)
|
||||
print("\n")
|
||||
|
||||
def BuildSohOtr(zapd_exe=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, "botr", "-se", "OTR", "--norom"]
|
||||
|
||||
print(exec_cmd)
|
||||
exitValue = subprocess.call(exec_cmd)
|
||||
if exitValue != 0:
|
||||
print("\n")
|
||||
print("Error when building soh.otr file...", file=os.sys.stderr)
|
||||
print("Aborting...", file=os.sys.stderr)
|
||||
print("\n")
|
||||
|
||||
def main():
|
||||
parser = argparse.ArgumentParser()
|
||||
parser.add_argument("-z", "--zapd", help="Path to ZAPD executable", dest="zapd_exe", type=str)
|
||||
@ -40,9 +56,17 @@ def main():
|
||||
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")
|
||||
parser.add_argument("--norom", help="Generate only soh.otr to be bundled to the game", dest="norom", action="store_true")
|
||||
|
||||
args = parser.parse_args()
|
||||
|
||||
if args.norom:
|
||||
if (os.path.exists("Extract")):
|
||||
shutil.rmtree("Extract")
|
||||
|
||||
BuildSohOtr(args.zapd_exe)
|
||||
return
|
||||
|
||||
roms = [ Z64Rom(args.rom) ] if args.rom else rom_chooser.chooseROM(args.verbose, args.non_interactive)
|
||||
for rom in roms:
|
||||
if (os.path.exists("Extract")):
|
||||
|
@ -1,11 +1,11 @@
|
||||
message(STATUS "Copying otr files...")
|
||||
|
||||
if(EXISTS ${SOURCE_DIR}/OTRExporter/oot.otr)
|
||||
if(NOT ONLYSOHOTR AND EXISTS ${SOURCE_DIR}/OTRExporter/oot.otr)
|
||||
execute_process(COMMAND ${CMAKE_COMMAND} -E copy oot.otr ${SOURCE_DIR})
|
||||
execute_process(COMMAND ${CMAKE_COMMAND} -E copy oot.otr ${BINARY_DIR}/soh/)
|
||||
message(STATUS "Copied oot.otr")
|
||||
endif()
|
||||
if(EXISTS ${SOURCE_DIR}/OTRExporter/oot-mq.otr)
|
||||
if(NOT ONLYSOHOTR AND EXISTS ${SOURCE_DIR}/OTRExporter/oot-mq.otr)
|
||||
execute_process(COMMAND ${CMAKE_COMMAND} -E copy oot-mq.otr ${SOURCE_DIR})
|
||||
execute_process(COMMAND ${CMAKE_COMMAND} -E copy oot-mq.otr ${BINARY_DIR}/soh/)
|
||||
message(STATUS "Copied oot-mq.otr")
|
||||
@ -18,10 +18,10 @@ endif()
|
||||
|
||||
# Additionally for Windows, copy the otrs to the target dir, side by side with soh.exe
|
||||
if(SYSTEM_NAME MATCHES "Windows")
|
||||
if(EXISTS ${SOURCE_DIR}/OTRExporter/oot.otr)
|
||||
if(NOT ONLYSOHOTR AND EXISTS ${SOURCE_DIR}/OTRExporter/oot.otr)
|
||||
execute_process(COMMAND ${CMAKE_COMMAND} -E copy oot.otr ${TARGET_DIR})
|
||||
endif()
|
||||
if(EXISTS ${SOURCE_DIR}/OTRExporter/oot-mq.otr)
|
||||
if(NOT ONLYSOHOTR AND EXISTS ${SOURCE_DIR}/OTRExporter/oot-mq.otr)
|
||||
execute_process(COMMAND ${CMAKE_COMMAND} -E copy oot-mq.otr ${TARGET_DIR})
|
||||
endif()
|
||||
if(EXISTS ${SOURCE_DIR}/OTRExporter/soh.otr)
|
||||
@ -29,7 +29,7 @@ if(SYSTEM_NAME MATCHES "Windows")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if(NOT EXISTS ${SOURCE_DIR}/oot.otr AND NOT EXISTS ${SOURCE_DIR}/oot-mq.otr)
|
||||
if(NOT ONLYSOHOTR AND (NOT EXISTS ${SOURCE_DIR}/oot.otr AND NOT EXISTS ${SOURCE_DIR}/oot-mq.otr))
|
||||
message(FATAL_ERROR "Failed to copy. No OTR files found.")
|
||||
endif()
|
||||
if(NOT EXISTS ${SOURCE_DIR}/soh.otr)
|
||||
|
Loading…
Reference in New Issue
Block a user