forked from LiteLDev/LeviLamina
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathxmake.lua
201 lines (184 loc) · 5.42 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
includes("scripts/localbdslibrary.lua")
add_repositories("liteldev-repo https://github.com/LiteLDev/xmake-repo.git")
-- Dependencies from xmake-repo.
add_requires("entt 3.12.2")
add_requires("fmt 10.1.1")
add_requires("gsl 4.0.0")
add_requires("leveldb 1.23")
add_requires("magic_enum 0.9.0")
add_requires("nlohmann_json 3.11.2")
add_requires("rapidjson 1.1.0")
-- Dependencies from liteldev-repo.
add_requires("ctre 3.8.1")
add_requires("pcg_cpp 1.0.0")
add_requires("pfr 2.1.1")
add_requires("preloader 1.3.0")
add_requires("symbolprovider 1.1.0")
if has_config("tests") then
add_requires("gtest 1.12.1")
end
if has_config("localbdslibrary") then
add_requires("localbdslibrary")
else
add_requires("bdslibrary 1.20.41.02")
end
if not has_config("vs_runtime") then
set_runtimes("MD")
end
option("tests")
set_default(false)
set_showmenu(true)
set_description("Enable tests")
option("localbdslibrary")
set_default(false)
set_showmenu(true)
set_description("Use local bdslibrary")
target("LeviLamina")
add_configfiles(
"src/(ll/core/Version.h.in)"
)
add_cxflags(
"/utf-8",
"/permissive-",
"/EHa",
"/W4",
"/w44265",
"/w44289",
"/w44296",
"/w45263",
"/w44738",
"/w45204"
)
add_defines(
"_AMD64_",
"_CRT_SECURE_NO_WARNINGS",
"_ENABLE_CONSTEXPR_MUTEX_CONSTRUCTOR",
"NOMINMAX",
"UNICODE",
"WIN32_LEAN_AND_MEAN"
)
add_defines("LL_EXPORT")
add_files(
"src/ll/api/**.cpp",
"src/ll/core/**.cpp",
"src/ll/core/**.rc",
"src/mc/**.cpp"
)
add_headerfiles(
"src/(ll/api/**.h)",
"src/(mc/**.h)"
)
add_includedirs(
"src",
"$(buildir)/config"
)
add_packages(
"entt",
"fmt",
"gsl",
"leveldb",
"magic_enum",
"nlohmann_json",
"rapidjson",
"ctre",
"pcg_cpp",
"pfr",
"preloader",
"symbolprovider",
{ public = true }
)
add_rules(
"mode.debug",
"mode.release"
)
add_shflags("/DELAYLOAD:bedrock_server.dll")
set_configdir("$(buildir)/config")
set_configvar("LL_WORKSPACE_FOLDER", "$(projectdir)")
set_exceptions("none")
set_kind("shared")
set_languages("c++23")
set_pcxxheader("src/mc/_HeaderOutputPredefine.h")
set_symbols("debug")
set_strip("all")
if has_config("tests") then
add_packages("gtest")
add_defines("LL_DEBUG")
add_files("src/ll/test/**.cpp")
end
if is_mode("debug") then
add_defines("LL_DEBUG")
end
-- if is_toolchain("clang-cl") then
-- set_languages("c++20")
-- add_defines("_HAS_CXX23")
-- end
if has_config("localbdslibrary") then
add_packages("localbdslibrary")
else
add_packages("bdslibrary")
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)
task("bds-lib")
on_run(function ()
import("core.base.option")
local actions = {"remote", "local", "clean", "tool"}
-- error if multiple actions are specified or no action is specified
local action = nil
for _, a in ipairs(actions) do
if option.get(a) then
if action then
raise("only one action can be specified")
end
action = a
end
end
if not action then
raise("no action specified")
end
if action == "remote" then
print("[localbdslibrary] Using remote BDS library.")
os.exec("xmake config --localbdslibrary=n")
elseif action == "local" then
print("[localbdslibrary] Using local BDS library.")
os.exec("xmake config --localbdslibrary=y")
elseif action == "clean" then
import("core.project.config")
local lib_dir = path.join(config.buildir(), "bds")
os.rm(lib_dir)
print("[localbdslibrary] Local bdslibrary has been cleared.")
elseif action == "tool" then
import("core.project.config")
local tool_dir = path.join(config.buildir(), "tools")
os.rm(tool_dir)
print("[localbdslibrary] Toolchain has been cleared.")
end
end)
set_menu {
usage = "xmake bds-lib",
description = "Manage local BDS library",
options = {
{'r', "remote", "k", nil, "Use remote BDS library"},
{'l', "local", "k", nil, "Use local BDS library"},
{'c', "clean", "k", nil, "Clean local BDS library"},
{'t', "tool", "k", nil, "Remove toolchain"}
}
}