diff --git a/.github/workflows/generate-builds.yml b/.github/workflows/generate-builds.yml index 41f279a13..ff4730582 100644 --- a/.github/workflows/generate-builds.yml +++ b/.github/workflows/generate-builds.yml @@ -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 diff --git a/CMakeLists.txt b/CMakeLists.txt index f7ad4089d..855b9da3d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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 $,remove,rm> -f soh.otr + COMMAND ${Python3_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/OTRExporter/extract_assets.py -z "$" --norom + COMMAND ${CMAKE_COMMAND} -DSYSTEM_NAME=${CMAKE_SYSTEM_NAME} -DTARGET_DIR="$" -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) diff --git a/OTRExporter/extract_assets.py b/OTRExporter/extract_assets.py index 53553da82..c6d5282a4 100755 --- a/OTRExporter/extract_assets.py +++ b/OTRExporter/extract_assets.py @@ -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")): diff --git a/copy-existing-otrs.cmake b/copy-existing-otrs.cmake index aa4b739cc..f5226510c 100644 --- a/copy-existing-otrs.cmake +++ b/copy-existing-otrs.cmake @@ -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)