-
Notifications
You must be signed in to change notification settings - Fork 3
/
SConstruct
126 lines (100 loc) · 2.94 KB
/
SConstruct
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
120
121
122
123
124
125
126
import os
import os.path
import sys
# Find emcc
emcc = None
path = os.environ['PATH'].split(os.path.pathsep)
for p in path:
p2 = os.path.join(p, 'emcc')
if os.path.exists(p2):
emcc = p2
break
if not emcc:
print('Could not find emcc. Check your PATH?')
sys.exit(1)
def EmscriptenEnvironment():
if sys.platform in ('windows', 'win32'):
env_dict = {
'path': os.environ['PATH']
}
for key in ['HOME', 'USERPROFILE', 'EM_CONFIG']:
value = os.environ.get(key)
if value is not None:
env_dict[key] = value
env = Environment(ENV=env_dict, TOOLS=['mingw'])
else:
env = Environment()
env['CC'] = emcc
env['CXX'] = emcc
emscriptenOpts = [
'-s', 'ASYNCIFY',
'-s', 'ASYNCIFY_IMPORTS=["fetchSync","downloadAll","wasm_nextFrame","emscripten_sleep"]',
'-s', 'FETCH=1',
'-s', 'FORCE_FILESYSTEM=1',
'-s', 'ALLOW_MEMORY_GROWTH=1',
]
cflags = ['-fcolor-diagnostics']
asmjs = ARGUMENTS.get('asmjs', 0)
debug = ARGUMENTS.get('debug', 0)
asan = ARGUMENTS.get('asan', 0)
ubsan = ARGUMENTS.get('ubsan', 0)
if debug:
if not asan:
emscriptenOpts += [
'-s', 'SAFE_HEAP=1',
]
emscriptenOpts += [
'-s', 'ASYNCIFY_STACK_SIZE=327680',
'-s', 'ASSERTIONS=1',
'-s', 'STACK_OVERFLOW_CHECK=1',
'-s', 'DEMANGLE_SUPPORT=1',
]
cflags.append('-g')
env.Append(LINKFLAGS=[
'-g',
'--source-map-base', 'https://localhost/',
])
else:
emscriptenOpts += [
'-s', 'ASYNCIFY_STACK_SIZE=32768',
]
cflags.append('-O3')
if asmjs:
env.Append(LINKFLAGS=[
'-s', 'WASM=0',
])
if asan:
cflags.append('-fsanitize=address')
env.Append(LINKFLAGS=['-fsanitize=address'])
if ubsan:
cflags.append('-fsanitize=undefined')
env.Append(LINKFLAGS=['-fsanitize=undefined'])
cflags.extend([
'-MMD',
'-Wno-parentheses',
'-Wno-long-long',
'-Wno-dangling-else',
'-Wno-writable-strings',
])
cflags.extend(emscriptenOpts)
env.Append(CFLAGS=cflags)
env.Append(CXXFLAGS=cflags)
env.Append(LINKFLAGS=[
'-lidbfs.js',
] + emscriptenOpts)
return env
sources = Split("""
engine.cpp menu.cpp nichgvc.cpp ricvc.cpp vc.cpp xbigdvc.cpp
battle.cpp entity.cpp menu2.cpp pcx.cpp sound.cpp vclib.cpp
control.cpp main.cpp render.cpp timer.cpp vga.cpp wyrdvc.cpp
fs.cpp stack.cpp base64.cpp
""")
sources = ['src/' + s for s in sources]
env = EmscriptenEnvironment()
env.Append(
CXXFLAGS=[
'-std=c++17',
#'-Werror', # Hahaha no way. This code dates back to like 1997.
],
)
verge = env.Program('verge.out.js', sources, PROGSUFFIX='.js')