-
Notifications
You must be signed in to change notification settings - Fork 19
Expand file tree
/
Copy pathxmake.lua
More file actions
230 lines (208 loc) · 7.53 KB
/
Copy pathxmake.lua
File metadata and controls
230 lines (208 loc) · 7.53 KB
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
add_rules("mode.debug", "mode.release")
add_repositories("levimc-repo " .. (get_config("levimc_repo") or "https://github.com/LiteLDev/xmake-repo.git"))
if is_config("target_type", "server") then
add_requires("levilamina dab5005c569ae9984ed62f20d209e02f77da9f89", {configs = {target_type = "server"}})
else
add_requires("levilamina dab5005c569ae9984ed62f20d209e02f77da9f89", {configs = {target_type = "client"}})
end
set_toolchains("clang-cl")
add_requires("levibuildscript")
add_requires("legacyremotecall 0c9d2595276013ba36a3ef721bd97c3810c6be1c", {configs = {target_type = get_config(target_type)}})
add_requires("legacymoney e677306c00fcf81e62ea52095d1a97e171220fb6", {configs = {target_type = get_config(target_type)}})
add_requires(
"lightwebsocketclient 1.0.1",
"magic_enum v0.9.7",
"nlohmann_json v3.11.3",
"simpleini v4.22",
"sqlite3 3.43.0+200",
"toml++ v3.4.0",
"ctre 3.8.1"
)
add_requires("openssl3")
add_requires("cpp-httplib 0.26.0", { configs = { ssl = true, zlib = true } })
if is_config("backend", "lua") then
add_requires("mariadb-connector-c 3.4.8")
add_requires("scriptx 2026.4.1", { configs = { backend = "Lua" } })
elseif is_config("backend", "quickjs") then
add_requires("mariadb-connector-c 3.4.8")
add_requires("scriptx 2026.4.1", { configs = { backend = "QuickJs" } })
elseif is_config("backend", "python") then
add_requires("mariadb-connector-c 3.4.8")
add_requires("scriptx 2026.4.1", { configs = { backend = "Python" } })
elseif is_config("backend", "nodejs") then
add_requires("mariadb-connector-c 3.4.8")
add_requires("scriptx 2026.4.1", { configs = { backend = "V8" } })
end
if not has_config("vs_runtime") then
set_runtimes("MD")
end
option("levimc_repo")
set_default("https://github.com/LiteLDev/xmake-repo.git")
set_showmenu(true)
set_description("Set the levimc-repo path or url")
option_end()
option("publish")
set_default(false)
set_showmenu(true)
option_end()
option("target_type")
set_default("server")
set_showmenu(true)
set_values("server", "client")
option_end()
option("backend")
set_default("lua")
set_values("lua", "quickjs", "python", "nodejs")
target("LegacyScriptEngine")
add_rules("@levibuildscript/linkrule")
add_cxflags(
"/EHa",
"/utf-8",
"/W4",
"/w44265",
"/w44289",
"/w44296",
"/w45263",
"/w44738",
"/w45204",
"/Zm2000",
"/wd4100",
{force = true}
)
add_defines(
"NOMINMAX",
"UNICODE",
"_AMD64_"
)
add_packages(
"cpp-httplib",
"legacymoney",
"legacyremotecall",
"levilamina",
"lightwebsocketclient",
"magic_enum",
"nlohmann_json",
"scriptx",
"simpleini",
"sqlite3",
"toml++",
"mariadb-connector-c",
"ctre"
)
set_exceptions("none")
set_kind("shared")
set_languages("cxx20")
set_symbols("debug")
set_configdir("$(builddir)/config")
set_configvar("LSE_WORKSPACE_FOLDER", "$(projectdir)")
add_configfiles("src/(lse/Version.h.in)")
add_files(
"src/**.cpp",
"src/**.rc"
)
add_includedirs(
"src",
"$(builddir)/config"
)
if is_config("target_type", "server") then
add_defines("LL_PLAT_S")
add_files("src-server/**.cpp")
add_includedirs("src-server")
else
add_defines("LL_PLAT_C")
add_files("src-client/**.cpp")
add_includedirs("src-client")
end
if has_config("publish") then
add_defines("LSE_VERSION_PUBLISH")
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
local versionStr = major.."."..minor.."."..patch
if suffix then
prerelease = suffix:match("-(.*)")
if prerelease then
prerelease = prerelease:gsub("\n", "")
end
if prerelease then
target:set("configvar", "LSE_VERSION_PRERELEASE", prerelease)
versionStr = versionStr.."-"..prerelease
end
end
target:set("configvar", "LSE_VERSION_MAJOR", major)
target:set("configvar", "LSE_VERSION_MINOR", minor)
target:set("configvar", "LSE_VERSION_PATCH", patch)
if not has_config("publish") then
local hash = os.iorun("git rev-parse --short HEAD")
versionStr = versionStr.."+"..hash:gsub("\n", "")
end
target:add("rules", "@levibuildscript/modpacker",{
modName = target:basename(),
modVersion = versionStr
})
end)
if is_config("backend", "lua") then
add_defines(
"LSE_BACKEND_LUA"
)
remove_files("src/legacy/main/NodeJsHelper.cpp")
remove_files("src/legacy/main/PythonHelper.cpp")
set_basename("legacy-script-engine-lua")
after_build(function(target)
local baselibPath = path.join(os.projectdir(), "src/baselib/BaseLib.lua")
local langPath = path.join(os.projectdir(), "src/lang/")
local outputPath = path.join(os.projectdir(), "bin/" .. target:basename())
local baselibOutputPath = path.join(outputPath, "baselib")
os.mkdir(baselibOutputPath)
os.cp(baselibPath, baselibOutputPath)
os.cp(langPath, outputPath)
end)
elseif is_config("backend", "quickjs") then
add_defines(
"LSE_BACKEND_QUICKJS"
)
remove_files("src/legacy/main/NodeJsHelper.cpp")
remove_files("src/legacy/main/PythonHelper.cpp")
set_basename("legacy-script-engine-quickjs")
after_build(function(target)
local baselibPath = path.join(os.projectdir(), "src/baselib/BaseLib.js")
local langPath = path.join(os.projectdir(), "src/lang/")
local outputPath = path.join(os.projectdir(), "bin/" .. target:basename())
local baselibOutputPath = path.join(outputPath, "baselib")
os.mkdir(baselibOutputPath)
os.cp(baselibPath, baselibOutputPath)
os.cp(langPath, outputPath)
end)
elseif is_config("backend", "python") then
add_defines(
"LSE_BACKEND_PYTHON"
)
remove_files("src/legacy/main/NodeJsHelper.cpp")
set_basename("legacy-script-engine-python")
after_build(function(target)
local baselibPath = path.join(os.projectdir(), "src/baselib/BaseLib.py")
local langPath = path.join(os.projectdir(), "src/lang/")
local outputPath = path.join(os.projectdir(), "bin/" .. target:basename())
local baselibOutputPath = path.join(outputPath, "baselib")
os.mkdir(baselibOutputPath)
os.cp(baselibPath, baselibOutputPath)
os.cp(langPath, outputPath)
end)
elseif is_config("backend", "nodejs") then
add_defines(
"LSE_BACKEND_NODEJS"
)
remove_files("src/legacy/main/PythonHelper.cpp")
set_basename("legacy-script-engine-nodejs")
after_build(function(target)
local langPath = path.join(os.projectdir(), "src/lang/")
local outputPath = path.join(os.projectdir(), "bin/" .. target:basename())
os.mkdir(outputPath)
os.cp(langPath, outputPath)
end)
end