-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathxmake.lua
186 lines (165 loc) · 6.09 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
add_rules("mode.debug", "mode.release")
add_repositories("liteldev-repo https://github.com/LiteLDev/xmake-repo.git")
if is_config("target_type", "server") then
add_requires("levilamina 1.0.1", {configs = {target_type = "server"}})
else
add_requires("levilamina 1.0.1", {configs = {target_type = "client"}})
end
add_requires("levibuildscript")
add_requires(
"legacymoney 0.9.0-rc.1",
"legacyparticleapi 0.9.0-rc.1",
"legacyremotecall 0.9.0-rc.1",
"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"
)
if is_config("backend", "lua") then
add_requires("mariadb-connector-c 3.3.9")
add_requires("scriptx main", {configs={backend="Lua"}})
elseif is_config("backend", "quickjs") then
add_requires("mariadb-connector-c 3.3.9")
add_requires("scriptx main", {configs={backend="QuickJs"}})
elseif is_config("backend", "python") then
add_requires("mariadb-connector-c 3.3.9")
add_requires("scriptx main", {configs={backend="Python"}})
elseif is_config("backend", "nodejs") then
add_requires("scriptx main", {configs={backend="V8"}})
end
add_requires("cpp-httplib 0.14.3", {configs = {ssl = true, zlib = true}})
if not has_config("vs_runtime") then
set_runtimes("MD")
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("legacy-script-engine")
add_rules("@levibuildscript/linkrule")
add_cxflags("/EHa", "/utf-8", "/W4", "/w44265", "/w44289", "/w44296", "/w45263", "/w44738", "/w45204","/Zm2000", {force = true})
add_defines(
"NOMINMAX",
"UNICODE",
"_AMD64_"
)
add_packages(
"cpp-httplib",
"legacymoney",
"legacyparticleapi",
"legacyremotecall",
"levilamina",
"lightwebsocketclient",
"magic_enum",
"nlohmann_json",
"scriptx",
"simpleini",
"sqlite3",
"toml++",
"mariadb-connector-c"
)
set_exceptions("none")
set_kind("shared")
set_languages("cxx20")
set_symbols("debug")
add_files(
"src/**.cpp"
)
add_includedirs(
"src",
"src/legacy"
)
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
end
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(
"LEGACY_SCRIPT_ENGINE_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(
"LEGACY_SCRIPT_ENGINE_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(
"LEGACY_SCRIPT_ENGINE_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(
"LEGACY_SCRIPT_ENGINE_BACKEND_NODEJS"
)
remove_files("src/legacy/main/PythonHelper.cpp")
remove_files("src/legacy/legacyapi/db/impl/mysql/*.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