-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
xmake.lua
321 lines (296 loc) · 9.58 KB
/
xmake.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
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
add_rules("mode.release", "mode.debug")
add_repositories("liteldev-repo https://github.com/LiteLDev/xmake-repo.git")
local is_windows = is_plat("windows")
local is_linux = is_plat("linux")
local is_android = is_plat("android")
local is_iphoneos = is_plat("iphoneos")
local is_server = is_config("target_type", "server")
local is_client = is_config("target_type", "client")
-- Dependencies from xmake-repo.
add_requires("ctre 3.8.1")
add_requires("entt 41aab920b083aa424ac1d27666ce287eeaff6ceb") -- master
add_requires("expected-lite v0.8.0")
add_requires("fmt 10.2.1")
add_requires("gsl v4.0.0")
add_requires("leveldb 1.23")
add_requires("magic_enum v0.9.5")
add_requires("nlohmann_json v3.11.3")
add_requires("rapidjson v1.1.0")
add_requires("mimalloc 2.1.2")
add_requires("cpr 1.10.5", {configs = {ssl = true}})
add_requires("boost 1.86.0", {configs = {stacktrace = true}})
-- Dependencies from liteldev-repo.
add_requires("pcg_cpp v1.0.0")
add_requires("pfr 2.1.1")
add_requires("demangler v17.0.7")
add_requires("levibuildscript 0.2.0")
if is_windows then
add_requires("preloader v1.9.0")
add_requires("symbolprovider v1.2.0")
add_requires("libhat 2024.4.16")
end
if has_config("tests") then
add_requires("gtest")
end
if is_server then
if is_windows then
add_requires("bedrockdata 1.21.3.1-server")
end
else
if is_windows then
add_requires("bedrockdata 1.21.0.3-client")
end
if is_windows then
add_requires("imgui v1.91.0-docking", {configs = {dx11 = true, dx12 = true}})
end
end
option("tests")
set_default(false)
set_showmenu(true)
set_description("Enable tests")
option("use_mimalloc")
set_default(false)
set_showmenu(true)
set_description("Enable mimalloc")
option("target_type")
set_default("server")
set_showmenu(true)
set_values("server", "client")
option_end()
if is_server then
set_defaultarchs("windows|x64")
set_allowedarchs("windows|x64", "linux|x86_64")
elseif is_client then
set_defaultarchs("windows|x64")
set_allowedarchs("windows|x64", "android|arm64-v8a", "iphoneos|arm64")
end
if is_windows and not has_config("vs_runtime") then
set_runtimes("MD")
end
if is_linux then
set_runtimes("c++_shared")
end
target("LeviLamina")
add_rules("@levibuildscript/linkrule")
add_rules("@levibuildscript/modpacker")
set_languages("c++20")
set_kind("shared")
set_symbols("debug")
set_exceptions("none")
add_files("src/**.cpp")
add_files("src/**.rc")
set_configdir("$(buildir)/config")
set_configvar("LL_WORKSPACE_FOLDER", "$(projectdir)")
add_configfiles("src/(ll/core/Version.h.in)")
add_headerfiles("src/(ll/api/**.h)", "src/(mc/**.h)")
add_includedirs("src", "$(buildir)/config")
set_pcxxheader("src/ll/api/Global.h")
add_packages("demangler", "mimalloc", "cpp-httplib")
if is_windows then
add_packages("libhat", "preloader")
end
add_packages(
"entt",
"expected-lite",
"fmt",
"gsl",
"leveldb",
"magic_enum",
"nlohmann_json",
"rapidjson",
"ctre",
"pcg_cpp",
"pfr",
"cpr",
"boost",
{public = true}
)
if is_windows then
add_packages("symbolprovider", "bedrockdata", {public = true})
end
add_defines(
"ENTT_PACKED_PAGE=128", -- public = true
"LL_EXPORT"
)
-- work around to enable c++23
if is_windows then
-- msstl
add_defines("_HAS_CXX23=1")
else
-- libstdc++
add_defines("_LIBCPP_STD_VER=23")
end
if is_windows then
add_syslinks("Version", "DbgHelp", "dwrite")
add_defines(
"_AMD64_",
"NOMINMAX",
"UNICODE",
"WIN32_LEAN_AND_MEAN"
)
add_cxflags(
"/utf-8",
"/permissive-",
"/EHa",
"/W4",
"/w44265",
"/w44289",
"/w44296",
"/w45263",
"/w44738"
)
add_cxflags(
"/EHs",
"-Wno-microsoft-cast",
"-Wno-invalid-offsetof",
"-Wno-c++2b-extensions",
"-Wno-microsoft-include",
"-Wno-overloaded-virtual",
"-Wno-ignored-qualifiers",
"-Wno-missing-field-initializers",
"-Wno-potentially-evaluated-expression",
"-Wno-pragma-system-header-outside-header",
{tools = {"clang_cl"}}
)
end
if is_server then
add_headerfiles(
"src-server/(ll/api/**.h)"
-- ,"src-server/(mc/**.h)"
)
add_includedirs("src-server")
add_files(
"src-server/**.cpp"
)
elseif is_client then
if is_windows then
add_syslinks("dxgi", "runtimeobject", "gdi32")
end
add_packages("imgui")
add_headerfiles(
"src-client/(ll/api/**.h)"
-- , "src-client/(mc/**.h)"
)
add_includedirs("src-client")
add_files("src-client/**.cpp")
remove_files( -- remove when everything fine
"src/mc/world/**.cpp",
-- "src/mc/world/level/**.cpp",
"src/mc/network/**.cpp",
"src/mc/server/*.cpp",
-- "src/mc/nbt/**.cpp",
-- "src/ll/api/chrono/**.cpp",
-- "src/ll/api/command/**.cpp",
-- "src/ll/core/command/**.cpp",
-- "src/ll/api/event/**.cpp",
-- "src/ll/api/Versions.cpp",
-- "src/ll/api/service/ServiceManager.cpp",
-- "src/ll/api/utils/CryptoUtils.cpp",
-- "src/ll/api/thread/TickSyncSleep.cpp",
-- "src/ll/api/thread/TickSyncTaskPool.cpp",
"src/ll/core/plugin-abi/**.cpp"
-- "src/ll/core/tweak/ModifyMemoryAllocator.cpp"
)
add_cxflags("/wd4273")
add_shflags("/IGNORE:4217")
end
if has_config("tests") then
add_defines("LL_DEBUG")
add_packages("gtest")
add_includedirs("src-test/common/")
add_files("src-test/common/**.cpp")
if is_server then
add_includedirs("src-test/server/")
add_files("src-test/server/**.cpp")
else
add_includedirs("src-test/client/")
add_files("src-test/client/**.cpp")
end
before_build(function (target)
headers = ""
for _,x in ipairs(os.files("src/**.h")) do
headers = headers.."#include \""..path.relative(x, "src/").."\"\n"
end
file = io.open("src-test/common/include_all.cpp", "w")
file:write(headers)
file:close()
if is_server then
headers = ""
for _,x in ipairs(os.files("src-server/**.h")) do
headers = headers.."#include \""..path.relative(x, "src-server/").."\"\n"
end
file = io.open("src-test/server/include_all.cpp", "w")
file:write(headers)
file:close()
else
headers = ""
for _,x in ipairs(os.files("src-client/**.h")) do
headers = headers.."#include \""..path.relative(x, "src-client/").."\"\n"
end
file = io.open("src-test/client/include_all.cpp", "w")
file:write(headers)
file:close()
end
end)
after_build(function (target)
io.writefile("src-test/common/include_all.cpp", "// auto gen when build test\n")
if is_server then
io.writefile("src-test/server/include_all.cpp", "// auto gen when build test\n")
else
io.writefile("src-test/client/include_all.cpp", "// auto gen when build test\n")
end
end)
end
if has_config("use_mimalloc") then
add_defines("LL_USE_MIMALLOC")
end
if is_mode("debug") then
add_defines("LL_DEBUG")
end
if not is_windows then
remove_files("./**/*_win.*")
remove_files("./**/*_windows.*") -- mojang has two styles
remove_files("./**/win/**.*")
remove_headerfiles("./**/win/**.*")
end
if not is_linux then
remove_files("./**/*_linux.*")
remove_files("./**/linux/**.*")
remove_headerfiles("./**/linux/**.*")
end
if not is_android then
remove_files("./**/*_android.*")
remove_files("./**/android/**.*")
remove_headerfiles("./**/android/**.*")
end
if not is_iphoneos then
remove_files("./**/*_ios.*")
remove_files("./**/ios/**.*")
remove_headerfiles("./**/ios/**.*")
end
on_config(function (target)
-- vs_runtime can not be set to MDd or MTd.
if has_config("vs_runtime") and (get_config("vs_runtime"):endswith("d")) then
raise("LeviLamina: vs_runtime can not be set to MDd or MTd")
end
end)
on_load(function (target)
local tag = os.iorun("git describe --tags --abbrev=0 --always")
local major, minor, patch, suffix = tag:match("v(%d+)%.(%d+)%.(%d+)(.*)")
if not major then
print("Failed to parse version tag, using 0.0.0")
major, minor, patch = 0, 0, 0
end
if suffix then
prerelease = suffix:match("-(.*)")
if prerelease then
prerelease = prerelease:gsub("\n", "")
end
if prerelease then
target:set("configvar", "LL_VERSION_PRERELEASE", prerelease)
end
end
target:set("configvar", "LL_VERSION_MAJOR", major)
target:set("configvar", "LL_VERSION_MINOR", minor)
target:set("configvar", "LL_VERSION_PATCH", patch)
end)