-
Notifications
You must be signed in to change notification settings - Fork 92
/
setup.py
executable file
·120 lines (98 loc) · 4.42 KB
/
setup.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
#!/usr/bin/env python3
import argparse
import os
from pathlib import Path
import shutil
import subprocess
import sys
import re
from tools.oot import *
def clean():
# Clean build environment
print("Cleaning build environment")
# Build list of paths (files and folders) to delete
paths = []
# Assets
paths.append(Path('assets/'))
paths.append(Path('build/'))
# GlideN64
paths.append(Path('GLideN64/projects/msvc/build'))
paths.extend(Path('external/Win32/').glob('*GLide*'))
paths.extend(Path('external/Win32/').glob('osal*'))
# ooot
paths.append(Path('vs/Debug/'))
# Delete files and folders
for path in paths:
if path.exists() == False:
continue
elif path.is_dir():
shutil.rmtree(path)
else:
os.remove(path)
def build():
print("Starting asset extraction and parsing")
# sys.executable points to python executable
subprocess.check_call([sys.executable, '-m', 'pip', 'install', 'tqdm'])
subprocess.check_call([sys.executable, '-m', 'pip', 'install', 'libyaz0'])
subprocess.check_call([sys.executable, str('tools/fixbaserom.py'), buildRom()])
subprocess.check_call([sys.executable, str('tools/extract_baserom.py'), buildRom()])
subprocess.check_call([sys.executable, str('tools/extract_assets.py'), buildRom()])
subprocess.check_call([sys.executable, str('tools/extract_z64_variables.py'), buildRom()])
subprocess.check_call([sys.executable, str('tools/convert_assets.py'), buildRom()])
mkdir(assetPath('text'))
subprocess.check_call([sys.executable, str('tools/msgenc.py'), str(romPath('text/charmap.txt')), str(assetPath('text/message_data.h')), str(assetPath('text/message_data.enc.h')), buildRom()])
subprocess.check_call([sys.executable, str('tools/msgenc.py'), str(romPath('text/charmap.txt')), str(assetPath('text/message_data_staff.h')), str(assetPath('text/message_data_staff.enc.h')), buildRom()])
subprocess.check_call([sys.executable, str('tools/extract_missing_assets.py'), buildRom()])
subprocess.check_call([sys.executable, str('tools/create_luts.py'), buildRom()])
subprocess.check_call([sys.executable, str('tools/fix_mtx.py'), buildRom()])
print("Finished asset extraction and parsing")
def main():
# Command Line Interface
parser = argparse.ArgumentParser(description="Setup")
parser.add_argument("-c", "--clean", help="Cleans environment before asset extraction", action="store_true", default=False)
parser.add_argument("-p", "--props-only", help="Only sets project properties / options (does not extract assets)", action="store_true", default=False)
parser.add_argument("-co", "--clean-only", help="Cleans environment without asset extraction", action="store_true", default=False)
parser.add_argument("-b", "--buildRom", choices=validBuildOptions(), help="build rom config ex: EUR_MQD")
parser.add_argument("-f", "--framerate", choices=['20', '25', '30', '40', '60', '120', '240'], help="game framerate", default='20')
parser.add_argument("-m", "--enable-mouse", help="Enables mouse controls", action="store_true", default=True)
parser.add_argument("--refresh-configs", help="Refreshes rom config files (do not use)", action="store_true", default=False)
parser.add_argument("-o", "--organize-roms", help="Renames and moves roms to their proper location", action="store_true", default=False)
parser.add_argument("-s", "--skip-organize-roms", help="Skip organizing roms", action="store_true", default=False)
args = parser.parse_args()
if args.refresh_configs:
calcRomHashes()
exit(0)
if args.organize_roms:
organizeRoms()
exit(0)
if not args.props_only and not args.skip_organize_roms:
organizeRoms()
if args.buildRom:
setBuildRom(args.buildRom)
else:
setBuildRom(findBuildRom())
with open('vs/oot.props.src', 'r') as f:
buffer = f.read()
buffer = buffer.replace('#BUILD_ROM#', buildRom())
defines = []
defines.append('ENABLE_%sFPS' % args.framerate)
if args.enable_mouse:
defines.append('ENABLE_MOUSE')
if buildRom().lower()[-1] != 'd':
defines.append('RETAIL')
defines.append(re.sub(r'[^A-Z0-9_]+', '', buildRom()))
defines.append('NATIVE')
#buffer = re.sub(r'<PreprocessorDefinitions>.*</PreprocessorDefinitions>', r'<PreprocessorDefinitions>%s</PreprocessorDefinitions>' % ';'.join(defines), buffer)
buffer = buffer.replace('#DEFINES#', ';'.join(defines))
with open('vs/oot.props', 'w') as f:
f.write(buffer)
if not args.props_only:
if args.clean == True:
clean()
build()
elif args.clean_only == True:
clean()
else:
build()
if __name__ == "__main__":
main()