summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZaxus125 <109976242+Zaxus125@users.noreply.github.com>2022-08-16 02:34:30 -0500
committerGitHub <noreply@github.com>2022-08-16 09:34:30 +0200
commit4483fbe8cc50ca77e79da24f149a87dbb3de75f4 (patch)
tree4f05380657957be6713876f5dab2f45b51410175
parent026039b290b100940c6c4d694d6c999fd4ed07b7 (diff)
[cmake] Improve OTRExporter asset extraction script, Lower required CMake to 3.16 (#1196)
* supply ZAPD.out path as an argument to extract_assets.py rather than regenerating the script Generating an entirely new script file to change a string is excessive. Instead, extract_assets.py takes in one optional positional argument that contains the path to ZAPD.out, the original purpose for the string replacement. This also removes the need for the file(CHMOD ...) command, which bumps the minimum cmake version all the way up to 3.19. Additionally, there was an extra script being generated in OTRExporter/CMakeLists.txt that used the same CHMOD logic, but did not accurately declare its minimum version to 3.19, this removes that unused logic. * OTRExporter: accept a rom path as an argument to extract_assets.py
-rw-r--r--CMakeLists.txt6
-rwxr-xr-xextract_assets.py17
2 files changed, 13 insertions, 10 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 5f31492..6fc3664 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -94,9 +94,3 @@ if (NOT TARGET ZAPDUtils)
endif()
add_subdirectory(OTRExporter)
-
-file(READ ${CMAKE_CURRENT_SOURCE_DIR}/extract_assets.py filedata)
-string(REGEX REPLACE "../ZAPDTR/ZAPD.out" "${CMAKE_BINARY_DIR}/ZAPD/ZAPD.out" filedata "${filedata}")
-file(WRITE "${CMAKE_CURRENT_SOURCE_DIR}/extract_assets_cmake.py" "${filedata}")
-file(CHMOD "${CMAKE_CURRENT_SOURCE_DIR}/extract_assets_cmake.py" PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_WRITE GROUP_EXECUTE WORLD_READ WORLD_EXECUTE)
-
diff --git a/extract_assets.py b/extract_assets.py
index 407760b..7fd0573 100755
--- a/extract_assets.py
+++ b/extract_assets.py
@@ -6,15 +6,18 @@ from rom_info import Z64Rom
import rom_chooser
import struct
import subprocess
+import argparse
-def BuildOTR(xmlPath, rom):
+def BuildOTR(xmlPath, rom, zapd_exe=None):
shutil.copytree("assets", "Extract/assets")
checksum = int(Z64Rom(rom).checksum.value, 16)
with open("Extract/version", "wb") as f:
f.write(struct.pack('<L', checksum))
- zapd_exe = "x64\\Release\\ZAPD.exe" if sys.platform == "win32" else "../ZAPDTR/ZAPD.out"
+ 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"]
@@ -28,13 +31,19 @@ def BuildOTR(xmlPath, rom):
print("\n")
def main():
- rom_path = rom_chooser.chooseROM()
+ parser = argparse.ArgumentParser()
+ parser.add_argument("-z", "--zapd", help="Path to ZAPD executable", dest="zapd_exe", type=str)
+ parser.add_argument("rom", help="Path to the rom", type=str, nargs="?")
+
+ args = parser.parse_args()
+
+ rom_path = args.rom if args.rom else rom_chooser.chooseROM()
rom = Z64Rom(rom_path)
if (os.path.exists("Extract")):
shutil.rmtree("Extract")
- BuildOTR("../soh/assets/xml/" + rom.version.xml_ver + "/", rom_path)
+ BuildOTR("../soh/assets/xml/" + rom.version.xml_ver + "/", rom_path, zapd_exe=args.zapd_exe)
if __name__ == "__main__":
main()