50 lines
1.7 KiB
Python
50 lines
1.7 KiB
Python
import os
|
|
import argparse
|
|
import sys
|
|
|
|
# Check if the script is run with the correct arguments
|
|
parser = argparse.ArgumentParser(description="Generate chunk header files")
|
|
parser.add_argument('--assets', required=True, help='Dir to output built assets')
|
|
parser.add_argument('--build-type', choices=['wad', 'header'], default='raw', help='Type of build to perform')
|
|
parser.add_argument('--output-file', required=True, help='Output file for built assets (required for wad build)')
|
|
parser.add_argument('--headers-dir', required=True, help='Directory to output individual asset headers (required for header build)')
|
|
parser.add_argument('--output-headers', help='Output header file for built assets (required for header build)')
|
|
parser.add_argument('--output-assets', required=True, help='Output directory for built assets')
|
|
parser.add_argument('--input', required=True, help='Input assets to process', nargs='+')
|
|
args = parser.parse_args()
|
|
|
|
inputAssets = []
|
|
for inputArg in args.input:
|
|
files = inputArg.split('$')
|
|
for file in files:
|
|
if str(file).strip() == '':
|
|
continue
|
|
|
|
pieces = file.split('#')
|
|
|
|
if len(pieces) < 2:
|
|
print(f"Error: Invalid input asset format '{file}'. Expected format: type#path[#option1%option2...]")
|
|
sys.exit(1)
|
|
|
|
options = {}
|
|
if len(pieces) > 2:
|
|
optionParts = pieces[2].split('%')
|
|
for part in optionParts:
|
|
partSplit = part.split('=')
|
|
|
|
if len(partSplit) < 1:
|
|
continue
|
|
if len(partSplit) == 2:
|
|
options[partSplit[0]] = partSplit[1]
|
|
else:
|
|
options[partSplit[0]] = True
|
|
|
|
inputAssets.append({
|
|
'type': pieces[0],
|
|
'path': pieces[1],
|
|
'options': options
|
|
})
|
|
|
|
if not inputAssets:
|
|
print("Error: No input assets provided.")
|
|
sys.exit(1) |