-
Notifications
You must be signed in to change notification settings - Fork 3
/
build.py
88 lines (75 loc) · 2.5 KB
/
build.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
import subprocess
import sys
import shutil
import os
if 'clean' in sys.argv[1:]:
build_files = ['dist', 'build', 'target', 'wafel_core.pyd']
for file in build_files:
if os.path.isfile(file):
print('Removing ' + file)
os.remove(file)
elif os.path.isdir(file):
print('Removing ' + file)
shutil.rmtree(file)
if sys.argv[1:] == [] or 'dist' in sys.argv[1:]:
subprocess.run(
['cargo', 'build', '--release'],
check=True,
)
shutil.copyfile('target/release/wafel_core.dll', 'wafel_core.pyd')
import wafel.config as config
from wafel.game_versions import lock_game_version, unlocked_game_versions, find_locked_dlls
config.init()
if 'lock' in sys.argv[1:]:
print('Locking DLLs')
for game_version in unlocked_game_versions():
name = 'sm64_' + game_version.lower()
lock_game_version(
game_version,
os.path.join('roms', name + '.z64'),
os.path.join('libsm64', name + '.dll'),
os.path.join('libsm64', name + '.dll.locked'),
)
if 'dist' in sys.argv[1:]:
shutil.rmtree('build/dist', ignore_errors=True)
subprocess.run(
[sys.executable, 'setup.py', 'bdist_wheel'],
check=True,
)
import ctypes
import ctypes.util
from glfw.library import glfw, msvcr
subprocess.run(
[
'pyinstaller',
'--onefile',
'--icon', '../wafel.ico',
'--noconsole',
'--specpath', 'build',
'--distpath', 'build/dist',
'--add-binary', os.pathsep.join([ctypes.util.find_library('msvcp140.dll'), '.']),
'--add-binary', os.pathsep.join([glfw._name, '.']),
'--add-binary', os.pathsep.join([msvcr._name, '.']),
'--name', 'wafel',
'run.py',
],
check=True,
)
print('Copying locked DLLs')
os.makedirs(os.path.join('build', 'dist', 'libsm64'))
for game_version, locked_dll in find_locked_dlls().items():
name = 'sm64_' + game_version.lower()
shutil.copyfile(
locked_dll,
os.path.join('build', 'dist', 'libsm64', name + '.dll.locked')
)
print('Copying tools')
os.makedirs('build/dist/tools')
shutil.copyfile('target/release/sm64_layout.exe', 'build/dist/tools/sm64_layout.exe')
shutil.copyfile('target/release/libsm64_lock.exe', 'build/dist/tools/libsm64_lock.exe')
shutil.copyfile('target/release/sm64_var_dump.exe', 'build/dist/tools/sm64_var_dump.exe')
print('Copying bindings')
os.makedirs('build/dist/bindings')
shutil.copytree('dist', 'build/dist/bindings/python')
print('Copying .pdb')
shutil.copyfile('target/release/wafel_core.pdb', 'build/dist/wafel.pdb')