diff --git a/.gitignore b/.gitignore index 00c76a3d41..7df5de28f2 100644 --- a/.gitignore +++ b/.gitignore @@ -58,4 +58,5 @@ docs/doxygen/ # Per-user configuration .python-version .make_options +.make_options.mk .*env diff --git a/Makefile b/Makefile index 6cbd903f7e..5aaf1f69ac 100644 --- a/Makefile +++ b/Makefile @@ -1,7 +1,7 @@ # Build options can be changed by modifying the makefile or by building with 'make SETTING=value'. -# It is also possible to override the settings in Defaults in a file called .make_options as 'SETTING=value'. +# It is also possible to override the settings in Defaults in a file called .make_options.mk as 'SETTING=value'. --include .make_options +-include .make_options.mk MAKEFLAGS += --no-builtin-rules @@ -433,7 +433,7 @@ assetclean: $(RM) -r $(ASSET_BIN_DIRS) $(RM) -r $(BUILD_DIR)/assets $(RM) -r assets/text/*.h - $(RM) -r .extracted-assets.json + $(RM) -r $(EXTRACTED_DIR)/.extracted-assets.json distclean: assetclean clean $(RM) -r asm data extracted @@ -457,7 +457,7 @@ setup-audio: $(AUDIO_EXTRACT) -o $(EXTRACTED_DIR) -v $(VERSION) --read-xml assets: - $(PYTHON) extract_assets.py $(EXTRACTED_DIR)/baserom assets -j$(N_THREADS) -Z Wno-hardcoded-pointer + $(PYTHON) tools/extract_assets.py $(EXTRACTED_DIR)/baserom assets -j$(N_THREADS) -Z Wno-hardcoded-pointer -v $(VERSION) $(AUDIO_EXTRACT) -o $(EXTRACTED_DIR) -v $(VERSION) --read-xml ## Assembly generation diff --git a/extract_assets.py b/tools/extract_assets.py similarity index 93% rename from extract_assets.py rename to tools/extract_assets.py index 7c69c3b4c3..cb8ace7c2f 100755 --- a/extract_assets.py +++ b/tools/extract_assets.py @@ -5,8 +5,6 @@ from pathlib import Path colorama.init() -EXTRACTED_ASSETS_NAMEFILE = ".extracted-assets.json" - dontGenerateCFilesList = [ "map_grand_static", "map_i_static", @@ -95,6 +93,7 @@ def main(): type=Path, help="Output directory to place files in", ) + parser.add_argument("-v", "--version", help="Which version should be processed", default="n64-us") parser.add_argument("-s", "--single", help="asset path relative to assets/, e.g. objects/gameplay_keep") parser.add_argument("-f", "--force", help="Force the extraction of every xml instead of checking the touched ones.", action="store_true") parser.add_argument("-j", "--jobs", help="Number of cpu cores to extract with.") @@ -128,9 +127,10 @@ def main(): manager = multiprocessing.Manager() signal.signal(signal.SIGINT, SignalHandler) + extractedAssetsFile = Path("extracted") / args.version / ".extracted-assets.json" extractedAssetsTracker = manager.dict() - if not args.force and os.path.exists(EXTRACTED_ASSETS_NAMEFILE): - with open(EXTRACTED_ASSETS_NAMEFILE, encoding='utf-8') as f: + if not args.force and extractedAssetsFile.exists(): + with extractedAssetsFile.open(encoding='utf-8') as f: extractedAssetsTracker.update(json.load(f, object_hook=manager.dict)) extract_text_path = outputDir / "text/message_data.h" @@ -139,11 +139,11 @@ def main(): asset_path = args.single if asset_path is not None: if "text/" in asset_path: - from tools.msg.nes import msgdisNES + from msg.nes import msgdisNES print("Extracting message_data") msgdisNES.main(extract_text_path) - from tools.msg.staff import msgdisStaff + from msg.staff import msgdisStaff print("Extracting staff_message_data") msgdisStaff.main(extract_staff_text_path) else: @@ -160,12 +160,12 @@ def main(): else: # Only extract text if the header does not already exist, or if --force was passed if args.force or not os.path.isfile(extract_text_path): - from tools.msg.nes import msgdisNES + from msg.nes import msgdisNES print("Extracting message_data") msgdisNES.main(baseromSegmentsDir, extract_text_path) if args.force or not os.path.isfile(extract_staff_text_path): - from tools.msg.staff import msgdisStaff + from msg.staff import msgdisStaff print("Extracting staff_message_data") msgdisStaff.main(baseromSegmentsDir, extract_staff_text_path) @@ -191,7 +191,7 @@ def main(): for singlePath in xmlFiles: ExtractFunc(singlePath) - with open(EXTRACTED_ASSETS_NAMEFILE, 'w', encoding='utf-8') as f: + with extractedAssetsFile.open('w', encoding='utf-8') as f: serializableDict = dict() for xml, data in extractedAssetsTracker.items(): serializableDict[xml] = dict(data)