forked from pbghogehoge/ssg
-
Notifications
You must be signed in to change notification settings - Fork 5
/
Tupfile.lua
232 lines (208 loc) · 7.33 KB
/
Tupfile.lua
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
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
tup.include("libs/tupblocks/Tuprules.lua")
-- SDL
-- ---
SDL = sourcepath("libs/SDL/")
SDL_COMPILE = {
base = {
cflags = "/DDLL_EXPORT",
lflags = (
"advapi32.lib imm32.lib gdi32.lib kernel32.lib ole32.lib " ..
"oleaut32.lib setupapi.lib user32.lib version.lib winmm.lib"
),
objdir = "SDL/",
},
buildtypes = {
debug = { lflags = "ucrtd.lib" },
release = { lflags = "ucrt.lib" },
}
}
SDL_LINK = {
base = {
cflags = ("-I" .. SDL.join("include/")),
lflags = "shell32.lib", -- for SDL_main()'s CommandLineToArgvW()
},
}
sdl_src += SDL.glob("src/*.c")
sdl_src += SDL.glob("src/atomic/*.c")
sdl_src += (SDL.glob("src/audio/*.c") - { "SDL_audiodev.c$" })
sdl_src += SDL.glob("src/audio/directsound/*.c")
sdl_src += SDL.glob("src/audio/disk/*.c")
sdl_src += SDL.glob("src/audio/dummy/*.c")
sdl_src += SDL.glob("src/audio/winmm/*.c")
sdl_src += (SDL.glob("src/audio/wasapi/*.c") - { "winrt.cpp$" })
sdl_src += SDL.glob("src/core/windows/*.c")
sdl_src += SDL.glob("src/cpuinfo/*.c")
sdl_src += SDL.glob("src/dynapi/*.c")
sdl_src += (
SDL.glob("src/events/*.c") -
{ "imKStoUCS.c$", "SDL_keysym_to_scancode.c$", "SDL_scancode_tables.c$" }
)
sdl_src += SDL.glob("src/file/*.c")
sdl_src += SDL.glob("src/filesystem/windows/*.c")
sdl_src += SDL.glob("src/haptic/*.c")
sdl_src += SDL.glob("src/haptic/windows/*.c")
sdl_src += SDL.glob("src/hidapi/*.c")
sdl_src += SDL.glob("src/joystick/*.c")
sdl_src += SDL.glob("src/joystick/hidapi/*.c")
sdl_src += SDL.glob("src/joystick/virtual/*.c")
sdl_src += SDL.glob("src/joystick/windows/*.c")
sdl_src += SDL.glob("src/libm/*.c")
sdl_src += SDL.glob("src/loadso/windows/*.c")
sdl_src += SDL.glob("src/locale/*.c")
sdl_src += SDL.glob("src/locale/windows/*.c")
sdl_src += SDL.glob("src/misc/*.c")
sdl_src += SDL.glob("src/misc/windows/*.c")
sdl_src += SDL.glob("src/power/*.c")
sdl_src += SDL.glob("src/power/windows/*.c")
sdl_src += SDL.glob("src/render/*.c")
sdl_src += SDL.glob("src/render/direct3d/*.c")
sdl_src += (SDL.glob("src/render/direct3d11/*.c") - { "winrt.cpp$" })
sdl_src += (SDL.glob("src/render/direct3d12/*.c") - { "winrt.cpp$" })
sdl_src += SDL.glob("src/render/opengl/*.c")
sdl_src += SDL.glob("src/render/opengles2/*.c")
sdl_src += SDL.glob("src/render/software/*.c")
sdl_src += SDL.glob("src/sensor/*.c")
sdl_src += SDL.glob("src/sensor/windows/*.c")
sdl_src += (SDL.glob("src/stdlib/*.c") - { "SDL_mslibc.c$" })
sdl_src += SDL.glob("src/thread/*.c")
sdl_src += SDL.glob("src/thread/windows/*.c")
sdl_src += SDL.glob("src/timer/*.c")
sdl_src += SDL.glob("src/timer/windows/*.c")
sdl_src += SDL.glob("src/video/*.c")
sdl_src += SDL.glob("src/video/dummy/*.c")
sdl_src += SDL.glob("src/video/windows/*.c")
sdl_src += SDL.glob("src/video/yuv2rgb/*.c")
sdl_src += SDL.join("src/thread/generic/SDL_syscond.c")
sdl_winmain_src += SDL.glob("src/main/windows/*.c")
sdl_cfg = CONFIG:branch("", SDL_COMPILE, SDL_LINK)
sdl_mslibc_cfg = sdl_cfg:branch("", {
buildtypes = { release = { cflags = flag_remove("/GL") } }
})
sdl_obj = (
cxx(sdl_cfg, sdl_src) +
cxx(sdl_mslibc_cfg, SDL.join("src/stdlib/SDL_mslibc.c")) +
rc(sdl_cfg, SDL.join("src/main/windows/version.rc"))
)
sdl_dll = (
dll(sdl_cfg, sdl_obj, "SDL2") +
cxx(sdl_cfg, sdl_winmain_src)
)
-- ---
-- libogg and libvorbis
-- --------------------
LIBOGG = sourcepath("libs/libogg/")
LIBVORBIS = sourcepath("libs/libvorbis/")
XIPH_LINK = { base = { cflags = string.format(
"-I%sinclude -I%sinclude", LIBOGG.root, LIBVORBIS.root
)} }
libogg_cfg = CONFIG:branch("", XIPH_LINK, { base = { objdir = "libogg/" } })
libogg_src += LIBOGG.glob("src/*.c")
libvorbis_cfg = CONFIG:branch("", XIPH_LINK, { base = {
objdir = "libvorbis/"
} })
libvorbis_src += (LIBVORBIS.glob("lib/*.c") - {
"barkmel.c$", "misc.c$", "psytune.c$", "tone.c$", "vorbisenc.c$"
})
xiph_obj = (cxx(libogg_cfg, libogg_src) + cxx(libvorbis_cfg, libvorbis_src))
-- --------------------
-- BLAKE3
-- ------
BLAKE3 = sourcepath("libs/BLAKE3/c/")
BLAKE3_COMPILE = {
base = {
objdir = "BLAKE3/",
-- Visual C++ has no SSE4.1 flag, and I don't trust the /arch:AVX option
cflags = "/DBLAKE3_NO_SSE41",
}
}
BLAKE3_LINK = { base = { cflags = ("-I" .. BLAKE3.root) } }
blake3_src += BLAKE3.join("blake3.c")
blake3_src += BLAKE3.join("blake3_dispatch.c")
blake3_src += BLAKE3.join("blake3_portable.c")
blake3_modern_cfg = CONFIG:branch("", BLAKE3_COMPILE, { base = {
objdir = "modern/",
} })
-- Each optimized version must be built with the matching Visual C++ `/arch`
-- flag. This is not only necessary for the compiler to actually emit the
-- intended instructions, but also prevents newer instruction sets from
-- accidentally appearing in older code. (For example, globally setting
-- `/arch:AVX512` for all of these files would cause AVX-512 instructions to
-- also appear in the AVX2 version, breaking it on those CPUs.)
-- That's why they recommend the ASM versions, but they're 64-bit-exclusive…
blake3_arch_cfgs = {
blake3_modern_cfg:branch("", { base = { cflags = "/arch:SSE2" } }),
blake3_modern_cfg:branch("", { base = { cflags = "/arch:AVX2" } }),
blake3_modern_cfg:branch("", { base = { cflags = "/arch:AVX512" } }),
}
blake3_modern_obj = (
cxx(blake3_modern_cfg, blake3_src) +
cxx(blake3_arch_cfgs[1], BLAKE3.join("blake3_sse2.c")) +
cxx(blake3_arch_cfgs[2], BLAKE3.join("blake3_avx2.c")) +
cxx(blake3_arch_cfgs[3], BLAKE3.join("blake3_avx512.c"))
)
-- ------
-- Static analysis using the C++ Core Guideline checker plugin.
ANALYSIS_CFLAGS = (
"/analyze:autolog- /analyze:plugin EspXEngine.dll " ..
"/external:W0 /external:anglebrackets /analyze:external- " ..
-- Critical warnings
"/we26819 " .. -- Unannotated fallthrough between switch labels
"/we26427 " .. -- Static initialization order fiasco
-- Disabled warnings
"/wd4834 " .. -- Discarding `[[nodiscard]]` (C6031 covers this and more)
"/wd26408 " .. -- Avoid _malloca()
"/wd26432 " .. -- Rule of Five boilerplate
"/wd26440 " .. -- `noexcept` all the things
"/wd26481 " .. -- Don't use pointer arithmetic
"/wd26482 " .. -- Only index into arrays using constant expressions
"/wd26490 " .. -- Don't use `reinterpret_cast`
"/wd26429 /wd26446 /wd26472 /wd26821" -- Guideline Support Library
)
ANALYSIS = {
buildtypes = {
release = { cflags = ANALYSIS_CFLAGS },
},
}
main_cfg = CONFIG:branch(tup.getconfig("BUILDTYPE"), SDL_LINK, BLAKE3_LINK, {
base = {
cflags = (
"/std:c++latest " ..
"/DWIN32 " ..
"/I. " ..
"/EHsc " ..
"/source-charset:utf-8 " ..
"/execution-charset:utf-8"
),
lflags = "obj/dinput.lib",
objdir = "ssg/",
},
buildtypes = {
debug = { cflags = "/DPBG_DEBUG" },
}
})
modern_cfg = main_cfg:branch(tup.getconfig("BUILDTYPE"), ANALYSIS)
modern_src += tup.glob("game/*.cpp")
modern_src += "game/codecs/flac.cpp"
modern_src += tup.glob("platform/windows/*.cpp")
main_src += tup.glob("DirectXUTYs/*.CPP")
main_src += tup.glob("DirectXUTYs/*.cpp")
main_src += tup.glob("GIAN07/*.cpp")
main_src += tup.glob("GIAN07/*.CPP")
main_obj = (
cxx(modern_cfg, modern_src) +
cxx(modern_cfg:branch("", XIPH_LINK), "game/codecs/vorbis.cpp") +
cxx(main_cfg, main_src)
)
main_sdl_cfg = main_cfg:branch("", ANALYSIS, {
base = { lflags = "/SUBSYSTEM:windows" }
})
main_sdl_src += "MAIN/main_sdl.cpp"
main_sdl_src += tup.glob("platform/miniaudio/*.cpp")
main_sdl_src += tup.glob("platform/sdl/*.cpp")
main_sdl_obj = cxx(main_sdl_cfg, main_sdl_src)
main_sdl_obj = (main_sdl_obj + xiph_obj)
exe(
main_sdl_cfg,
(main_sdl_obj + main_obj + blake3_modern_obj + sdl_dll),
"GIAN07"
)