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
|
-- Copyright Epic Games, Inc. All Rights Reserved.
set_configvar("ZEN_SCHEMA_VERSION", 4) -- store Cid data in CAS under raw hash (dan.engelbrecht)
add_requires(
"vcpkg::asio",
"vcpkg::blake3",
"vcpkg::catch2 2.13.8",
"vcpkg::cpr",
"vcpkg::curl",
"vcpkg::cxxopts",
"vcpkg::doctest",
"vcpkg::fmt",
"vcpkg::gsl-lite",
"vcpkg::http-parser",
"vcpkg::json11",
"vcpkg::lua",
"vcpkg::lz4",
"vcpkg::openssl",
"vcpkg::robin-map",
"vcpkg::sol2",
"vcpkg::spdlog",
"vcpkg::xxhash",
"vcpkg::zlib",
"vcpkg::zstd"
)
if not is_arch("arm64") then
add_requires(
"vcpkg::mimalloc",
"vcpkg::sentry-native"
)
end
add_rules("mode.debug", "mode.release")
if is_mode("release") then
set_optimize("smallest")
if is_plat("windows") then
add_ldflags("/LTCG")
end
end
if is_mode("debug") then
add_defines("DEBUG")
end
if is_mode("debug") then
add_defines("ZEN_WITH_TESTS=1")
else
add_defines("ZEN_WITH_TESTS=0")
end
if is_os("windows") then
add_defines(
"_CRT_SECURE_NO_WARNINGS",
"_UNICODE",
"UNICODE",
"_CONSOLE",
"NOMINMAX", -- stop Windows SDK defining 'min' and 'max'
"NOGDI", -- otherwise Windows.h defines 'GetObject'
"WIN32_LEAN_AND_MEAN", -- cut down Windows.h
"_WIN32_WINNT=0x0A00"
)
-- add_ldflags("/MAP")
end
if is_os("linux") or is_os("macosx") then
add_cxxflags("-Wno-implicit-fallthrough")
add_cxxflags("-Wno-missing-field-initializers")
add_cxxflags("-Wno-strict-aliasing")
add_cxxflags("-Wno-switch")
add_cxxflags("-Wno-unused-lambda-capture")
add_cxxflags("-Wno-unused-private-field")
add_cxxflags("-Wno-unused-value")
add_cxxflags("-Wno-unused-variable")
end
-- Turn use of undefined cpp macros into errors
if is_os("windows") then
add_cxxflags("/we4668")
else
add_cxxflags("-Wundef")
end
function add_define_by_config(define, config_name)
local value = has_config(config_name) and 1 or 0
add_defines(define.."="..value)
end
if not is_arch("arm64") then
option("zensentry")
set_default(true)
set_showmenu(true)
set_description("Enables Sentry support in Zen")
option_end()
add_define_by_config("ZEN_USE_SENTRY", "zensentry")
option("zenmimalloc")
set_default(true)
set_showmenu(true)
set_description("Use MiMalloc as Zen's allocator")
option_end()
add_define_by_config("ZEN_USE_MIMALLOC", "zenmimalloc")
end
if is_os("windows") then
option("httpsys")
set_default(true)
set_showmenu(true)
set_description("Enable http.sys server")
option_end()
add_define_by_config("ZEN_WITH_HTTPSYS", "httpsys")
end
option("catch2")
set_default(false)
set_showmenu(true)
set_description("Use catch2 to run tests")
option_end()
add_define_by_config("ZEN_USE_CATCH2", "catch2")
option("compute")
set_default(true)
set_showmenu(true)
set_description("Enable compute services endpoint")
option_end()
add_define_by_config("ZEN_WITH_COMPUTE_SERVICES", "compute")
option("zentrace")
set_default(true)
set_showmenu(true)
set_description("Enable UE's Trace support")
option_end()
add_define_by_config("ZEN_WITH_TRACE", "zentrace")
set_warnings("allextra", "error")
set_languages("cxx20")
-- always generate debug information
set_symbols("debug")
includes("zencore", "zencore-test")
includes("zenhttp")
includes("zenstore", "zenstore-test")
includes("zenutil")
includes("zenserver", "zenserver-test")
includes("zen")
includes("zentest-appstub")
task("bundle")
set_menu {
usage = "xmake bundle",
description = "Create Zip bundle from binaries",
options = {
{nil, "withtrace", "k", nil, "Compiles with trace support"},
}
}
on_run(function ()
import("scripts.bundle")
bundle()
end)
task("precommit")
set_menu {
usage = "xmake precommit",
description = "Run required pre-commit steps (clang-format, etc)",
}
on_run(function ()
print(os.exec("pre-commit run --all-files"))
end)
task("sln")
set_menu {
usage = "xmake sln",
description = "Generate Visual Studio project files",
}
on_run(function ()
print(os.exec("xmake project --yes --kind=vsxmake2022 -m release,debug -a x64"))
end)
task("test")
set_menu {
usage = "xmake runtest [core|store|server|integration|all]",
description = "Run Zen tests",
options = {
{'r', "run", "kv", "all", "Run test(s)", " - all", " - core ", " - store", " - server", " - integration"}
}
}
on_run(function()
import("core.base.option")
local testname = option.get("run")
local available_tests = {
core = "zencore-test",
store = "zenstore-test",
server = "zenserver",
integration = "zenserver-test"
}
local arch
if is_host("windows") then
arch = "x64"
else
arch = "x86_64"
end
print(os.exec("xmake config -c -m debug -a "..arch))
print(os.exec("xmake"))
local tests = {}
for name, test in pairs(available_tests) do
if name == testname or testname == "all" then
tests[name] = test
end
end
for name, test in pairs(tests) do
printf("=== %s ===\n", test)
local cmd = string.format("xmake run %s", test)
if name == "server" then
cmd = string.format("xmake run %s test", test)
end
print(os.exec(cmd))
end
end)
|