-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathxmake.lua
More file actions
225 lines (185 loc) · 7.62 KB
/
Copy pathxmake.lua
File metadata and controls
225 lines (185 loc) · 7.62 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
add_repositories("package_repo_singleton https://github.com/MasterLaplace/Singleton.git")
add_rules("mode.debug", "mode.release", "plugin.vsxmake.autoupdate")
option("with-autoupdate")
set_default(true)
set_showmenu(true)
set_description("Enable automatic game download/update feature")
option_end()
option("pack-server")
set_default(true)
set_showmenu(true)
set_description("Include server in package")
option_end()
option("pack-client")
set_default(true)
set_showmenu(true)
set_description("Include client library in package")
option_end()
add_requires("nlohmann_json", "singleton")
if has_config("with-autoupdate") then
add_requires("libcurl", {configs = {openssl3 = is_plat("linux", "macosx")}})
add_requires("libgit2", {configs = {https = is_plat("windows") and "winhttp" or "openssl3", tools = false}})
end
includes("@builtin/xpack")
includes("examples")
set_project("Flakkari")
set_license("MIT")
target("flakkari-server")
set_kind("binary")
set_default(true)
set_languages("cxx20")
set_policy("build.warning", true)
set_version("0.10.0")
add_packages("nlohmann_json", "singleton")
if has_config("with-autoupdate") then
add_packages("libcurl", "libgit2")
add_defines("FLAKKARI_AUTO_UPDATE")
set_policy("check.target_package_licenses", false)
end
if is_mode("debug") then
add_defines("_DEBUG")
set_symbols("debug")
set_optimize("none")
elseif is_mode("release") then
add_defines("NDEBUG")
set_optimize("fastest")
end
add_files("Flakkari/**.cpp")
remove_files("Flakkari/Client/**.cpp")
if not has_config("with-autoupdate") then
remove_files("Flakkari/Server/Internals/GameDownloader.cpp")
end
add_headerfiles("Flakkari/**.h", { public = true })
add_headerfiles("Flakkari/**.hpp", { public = true })
remove_headerfiles("Flakkari/Client/**.hpp")
add_includedirs("Flakkari/", { public = true })
add_includedirs("Flakkari/Engine", { public = true })
add_includedirs("Flakkari/Engine/EntityComponentSystem", { public = true })
add_includedirs("Flakkari/Engine/EntityComponentSystem/Components", { public = true })
add_includedirs("Flakkari/Engine/EntityComponentSystem/Systems", { public = true })
add_includedirs("Flakkari/Engine/Math", { public = true })
add_includedirs("Flakkari/Logger", { public = true })
add_includedirs("Flakkari/Network", { public = true })
add_includedirs("Flakkari/Protocol", { public = true })
add_includedirs("Flakkari/Server", { public = true })
add_includedirs("Flakkari/Server/Client", { public = true })
add_includedirs("Flakkari/Server/Game", { public = true })
add_includedirs("Flakkari/Server/Internals", { public = true })
if is_plat("windows") then
add_syslinks("Iphlpapi")
end
target_end()
target("flakkari-client")
set_kind("static")
set_default(false)
set_languages("cxx20")
set_policy("build.warning", true)
set_version("0.10.0")
if is_mode("debug") then
add_defines("_DEBUG")
set_symbols("debug")
set_optimize("none")
elseif is_mode("release") then
add_defines("NDEBUG")
set_optimize("fastest")
end
add_files("Flakkari/**.cpp")
remove_files("Flakkari/*.cpp")
remove_files("Flakkari/Server/**.cpp")
remove_files("Flakkari/Engine/**.cpp")
remove_files("Flakkari/Protocol/Engine/**.cpp")
add_headerfiles("Flakkari/**.h", { public = true })
add_headerfiles("Flakkari/**.hpp", { public = true })
remove_headerfiles("Flakkari/Server/**.hpp")
remove_headerfiles("Flakkari/Engine/**.hpp")
remove_headerfiles("Flakkari/Protocol/Engine/**.hpp")
add_includedirs("Flakkari/", { public = true })
add_includedirs("Flakkari/Logger", { public = true })
add_includedirs("Flakkari/Network", { public = true })
add_includedirs("Flakkari/Protocol", { public = true })
target_end()
-- Doc: https://xmake.io/#/manual/xpack
xpack("flakkari")
set_formats("nsis", "zip", "srczip", "targz", "srctargz", "runself")
set_title("Flakkari Full v$(version) ($(arch))")
set_author("MasterLaplace")
set_company("ME.inc")
set_description("Flakkari is a UDP/TCP game server and client library initially developed for the R-Type Epitech project and updated for the Video Games course at University Laval.")
set_homepage("https://github.com/MasterLaplace/Flakkari")
set_licensefile("LICENSE")
set_copyright("Copyright (C) 2023-present, Me.inc & MasterLaplace")
set_version("0.10.0")
if has_config("pack-server") then
add_targets("flakkari-server")
end
if has_config("pack-client") then
add_targets("flakkari-client")
end
set_iconfile("docs/Images/icon.ico")
add_sourcefiles("Flakkari/**.cpp")
add_sourcefiles("Flakkari/**.hpp")
add_sourcefiles("Flakkari/**.h")
add_installfiles("Flakkari/**.h", {prefixdir = "include"})
add_installfiles("Flakkari/**.hpp", {prefixdir = "include"})
add_installfiles("doc/*.md", {prefixdir = "share/docs"})
add_installfiles("*.md", {prefixdir = "share/docs"})
on_load(function (package)
local pack_server = has_config("pack-server")
local pack_client = has_config("pack-client")
local pack_type = ""
if pack_server and pack_client then
pack_type = "full"
elseif pack_server then
pack_type = "server"
elseif pack_client then
pack_type = "client"
end
if package:from_source() then
package:set("basename", "flakkari-" .. pack_type .. "-$(plat)-src-v$(version)")
else
package:set("basename", "flakkari-" .. pack_type .. "-$(plat)-$(arch)-v$(version)")
end
local format = package:format()
if format == "srpm" then
package:add("buildrequires", "make")
package:add("buildrequires", "gcc")
package:add("buildrequires", "gcc-c++")
end
end)
after_installcmd(function (package, batchcmds)
if not has_config("pack-server") then
return
end
batchcmds:mkdir(package:installdir("Games"))
batchcmds:cp("Games/*", package:installdir("Games"), {rootdir = "."})
local games_dir = package:installdir("Games")
if is_plat("windows") then
batchcmds:runv(string.format('setx FLAKKARI_INSTALL_GAME_DIR "%s"', games_dir))
elseif is_plat("linux") or is_plat("macosx") then
local shell_config = os.getenv("SHELL") == "/bin/zsh" and "~/.zshrc" or "~/.bashrc"
batchcmds:runv(string.format(
'echo \'export FLAKKARI_INSTALL_GAME_DIR="%s"\' >> %s',
games_dir, shell_config
))
else
batchcmds:showmsg("Please set the environment variable FLAKKARI_INSTALL_GAME_DIR manually to: " .. games_dir)
end
end)
after_uninstallcmd(function (package, batchcmds)
if not has_config("pack-server") then
return
end
batchcmds:rmdir(package:installdir("Games"))
if is_plat("windows") then
batchcmds:runv('reg delete "HKCU\\Environment" /F /V FLAKKARI_INSTALL_GAME_DIR')
elseif is_plat("linux") or is_plat("macosx") then
local shell_config = os.getenv("SHELL") == "/bin/zsh" and "~/.zshrc" or "~/.bashrc"
batchcmds:runv(string.format(
'sed -i "/export FLAKKARI_INSTALL_GAME_DIR=.*/d" %s',
shell_config
))
else
batchcmds:showmsg("Please remove the environment variable FLAKKARI_INSTALL_GAME_DIR manually if it was set.")
end
end)
xpack_end()