mirror of https://github.com/zeldaret/mm.git
Small Misc Tooling (#1668)
* Move .extracted_assets.json to extracted folder * .options.mk * Move extract assets to tools folder * .make_options.mk * gitignore as well * Remove duplicate import
This commit is contained in:
parent
629584b1bc
commit
d925976c82
|
@ -58,4 +58,5 @@ docs/doxygen/
|
||||||
# Per-user configuration
|
# Per-user configuration
|
||||||
.python-version
|
.python-version
|
||||||
.make_options
|
.make_options
|
||||||
|
.make_options.mk
|
||||||
.*env
|
.*env
|
||||||
|
|
8
Makefile
8
Makefile
|
@ -1,7 +1,7 @@
|
||||||
# Build options can be changed by modifying the makefile or by building with 'make SETTING=value'.
|
# 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
|
MAKEFLAGS += --no-builtin-rules
|
||||||
|
|
||||||
|
@ -433,7 +433,7 @@ assetclean:
|
||||||
$(RM) -r $(ASSET_BIN_DIRS)
|
$(RM) -r $(ASSET_BIN_DIRS)
|
||||||
$(RM) -r $(BUILD_DIR)/assets
|
$(RM) -r $(BUILD_DIR)/assets
|
||||||
$(RM) -r assets/text/*.h
|
$(RM) -r assets/text/*.h
|
||||||
$(RM) -r .extracted-assets.json
|
$(RM) -r $(EXTRACTED_DIR)/.extracted-assets.json
|
||||||
|
|
||||||
distclean: assetclean clean
|
distclean: assetclean clean
|
||||||
$(RM) -r asm data extracted
|
$(RM) -r asm data extracted
|
||||||
|
@ -457,7 +457,7 @@ setup-audio:
|
||||||
$(AUDIO_EXTRACT) -o $(EXTRACTED_DIR) -v $(VERSION) --read-xml
|
$(AUDIO_EXTRACT) -o $(EXTRACTED_DIR) -v $(VERSION) --read-xml
|
||||||
|
|
||||||
assets:
|
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
|
$(AUDIO_EXTRACT) -o $(EXTRACTED_DIR) -v $(VERSION) --read-xml
|
||||||
|
|
||||||
## Assembly generation
|
## Assembly generation
|
||||||
|
|
|
@ -5,8 +5,6 @@ from pathlib import Path
|
||||||
|
|
||||||
colorama.init()
|
colorama.init()
|
||||||
|
|
||||||
EXTRACTED_ASSETS_NAMEFILE = ".extracted-assets.json"
|
|
||||||
|
|
||||||
dontGenerateCFilesList = [
|
dontGenerateCFilesList = [
|
||||||
"map_grand_static",
|
"map_grand_static",
|
||||||
"map_i_static",
|
"map_i_static",
|
||||||
|
@ -95,6 +93,7 @@ def main():
|
||||||
type=Path,
|
type=Path,
|
||||||
help="Output directory to place files in",
|
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("-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("-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.")
|
parser.add_argument("-j", "--jobs", help="Number of cpu cores to extract with.")
|
||||||
|
@ -128,9 +127,10 @@ def main():
|
||||||
manager = multiprocessing.Manager()
|
manager = multiprocessing.Manager()
|
||||||
signal.signal(signal.SIGINT, SignalHandler)
|
signal.signal(signal.SIGINT, SignalHandler)
|
||||||
|
|
||||||
|
extractedAssetsFile = Path("extracted") / args.version / ".extracted-assets.json"
|
||||||
extractedAssetsTracker = manager.dict()
|
extractedAssetsTracker = manager.dict()
|
||||||
if not args.force and os.path.exists(EXTRACTED_ASSETS_NAMEFILE):
|
if not args.force and extractedAssetsFile.exists():
|
||||||
with open(EXTRACTED_ASSETS_NAMEFILE, encoding='utf-8') as f:
|
with extractedAssetsFile.open(encoding='utf-8') as f:
|
||||||
extractedAssetsTracker.update(json.load(f, object_hook=manager.dict))
|
extractedAssetsTracker.update(json.load(f, object_hook=manager.dict))
|
||||||
|
|
||||||
extract_text_path = outputDir / "text/message_data.h"
|
extract_text_path = outputDir / "text/message_data.h"
|
||||||
|
@ -139,11 +139,11 @@ def main():
|
||||||
asset_path = args.single
|
asset_path = args.single
|
||||||
if asset_path is not None:
|
if asset_path is not None:
|
||||||
if "text/" in asset_path:
|
if "text/" in asset_path:
|
||||||
from tools.msg.nes import msgdisNES
|
from msg.nes import msgdisNES
|
||||||
print("Extracting message_data")
|
print("Extracting message_data")
|
||||||
msgdisNES.main(extract_text_path)
|
msgdisNES.main(extract_text_path)
|
||||||
|
|
||||||
from tools.msg.staff import msgdisStaff
|
from msg.staff import msgdisStaff
|
||||||
print("Extracting staff_message_data")
|
print("Extracting staff_message_data")
|
||||||
msgdisStaff.main(extract_staff_text_path)
|
msgdisStaff.main(extract_staff_text_path)
|
||||||
else:
|
else:
|
||||||
|
@ -160,12 +160,12 @@ def main():
|
||||||
else:
|
else:
|
||||||
# Only extract text if the header does not already exist, or if --force was passed
|
# 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):
|
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")
|
print("Extracting message_data")
|
||||||
msgdisNES.main(baseromSegmentsDir, extract_text_path)
|
msgdisNES.main(baseromSegmentsDir, extract_text_path)
|
||||||
|
|
||||||
if args.force or not os.path.isfile(extract_staff_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")
|
print("Extracting staff_message_data")
|
||||||
msgdisStaff.main(baseromSegmentsDir, extract_staff_text_path)
|
msgdisStaff.main(baseromSegmentsDir, extract_staff_text_path)
|
||||||
|
|
||||||
|
@ -191,7 +191,7 @@ def main():
|
||||||
for singlePath in xmlFiles:
|
for singlePath in xmlFiles:
|
||||||
ExtractFunc(singlePath)
|
ExtractFunc(singlePath)
|
||||||
|
|
||||||
with open(EXTRACTED_ASSETS_NAMEFILE, 'w', encoding='utf-8') as f:
|
with extractedAssetsFile.open('w', encoding='utf-8') as f:
|
||||||
serializableDict = dict()
|
serializableDict = dict()
|
||||||
for xml, data in extractedAssetsTracker.items():
|
for xml, data in extractedAssetsTracker.items():
|
||||||
serializableDict[xml] = dict(data)
|
serializableDict[xml] = dict(data)
|
Loading…
Reference in New Issue