-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathxmake.lua
More file actions
247 lines (199 loc) · 9.6 KB
/
xmake.lua
File metadata and controls
247 lines (199 loc) · 9.6 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
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
---------------------------- bootstrap ----------------------------
local allowed_modes = {
"debug",
"release",
"releasedbg",
"profile",
}
add_repositories("tapzcrew-repo https://github.com/Tapzcrew/xmake-repo main")
set_xmakever("3.0.0")
set_project("StormKit")
set_version("0.1.0", { build = "%Y%m%d%H%M" })
includes("xmake/rules/*.lua")
---------------------------- options ----------------------------
includes("xmake/options.xmake.lua")
if get_config("devmode") then
set_policy("build.c++.modules.non_cascading_changes", true)
set_policy("build.c++.modules.hide_dependencies", true)
end
---------------------------- global rules ----------------------------
if get_config("vsxmake") then add_rules("plugin.vsxmake.autoupdate") end
if get_config("compile_commands") then
if test then
if test2 then
end
end
add_rules("plugin.compile_commands.autoupdate", { outputdir = "build", lsp = "clangd" })
end
for _, mode in ipairs(allowed_modes) do
add_rules("mode." .. mode)
end
if not is_host("windows") then add_rules("mode.valgrind") end
set_fpmodels("fast")
add_vectorexts("fma")
add_vectorexts("neon")
add_vectorexts("avx", "avx2")
add_vectorexts("sse", "sse2", "sse3", "ssse3", "sse4.2")
---------------------------- global configs ----------------------------
set_allowedmodes(allowed_modes)
set_allowedplats("windows", "mingw", "linux", "macosx", "wasm")
set_allowedarchs("windows|x64", "windows|arm64", "linux|x86_64", "linux|aarch64", "macosx|x86_64", "macosx|arm64")
add_defines("ANKERL_UNORDERED_DENSE_STD_MODULE=1", "FROZEN_STD_MODULE=1")
includes("xmake/dependencies.xmake.lua")
includes("xmake/targets.xmake.lua")
---------------------------- dependencies ----------------------------
for name, module in pairs(modules) do
if name == "core" or name == "main" or name == "test" or get_config(name) then
for _, package in ipairs(module.public_packages) do
add_requires_with_conf_transitive(package)
end
for _, package in ipairs(module.packages) do
add_requires_with_conf(package)
end
end
end
---------------------------- targets ----------------------------
namespace("stormkit", function()
for _, name in ipairs({ "log", "entities", "image", "wsi", "gpu" }) do
if get_config(name) then set_configvar("STORMKIT_LIB_" .. string.upper(name) .. "_ENABLED", "true") end
end
for name, module in pairs(modules) do
local modulename = module.modulename
if name == "core" or name == "main" or name == "test" or get_config(name) then
target(name, function()
set_group("libraries")
if module.custom then module.custom() end
if name == "main" or name == "test" then
set_kind("static")
else
set_kind("$(kind)")
end
set_languages("cxxlatest", "clatest")
add_rules("stormkit.flags")
add_defines("STORMKIT_BUILD")
if is_mode("debug") then
add_defines("STORMKIT_BUILD_DEBUG")
set_suffixname("-d")
end
if is_kind("static") then add_defines("STORMKIT_STATIC", { public = true }) end
local src_path = path.join("src", modulename)
local module_path = path.join("modules", "stormkit", modulename)
local include_path = path.join("include", "(stormkit", modulename)
for _, file in ipairs(os.files(path.join(src_path, "**.mpp"))) do
add_files(file)
end
for _, file in ipairs(os.files(path.join(src_path, "**.cpp"))) do
add_files(file)
end
for _, file in ipairs(os.files(path.join(src_path, "**.mm"))) do
add_files(file, { mxxflags = "-std=c++23" })
end
for _, file in ipairs(os.files(path.join(src_path, "**.m"))) do
add_files(file)
end
for _, file in ipairs(os.files(path.join(src_path, "**.inl"))) do
add_files(file)
end
if os.exists(module_path .. ".mpp") then add_files(module_path .. ".mpp", { public = true }) end
if os.files(module_path) then
for _, file in ipairs(os.files(path.join(module_path, "**.mpp"))) do
add_files(file, { public = true })
end
for _, file in ipairs(os.files(path.join(module_path, "**.inl"))) do
add_headerfiles(file)
end
end
local _include_path = include_path:gsub("%(", "")
if os.exists(_include_path) then
add_headerfiles(path.join(include_path, "**.inl)"))
add_headerfiles(path.join(include_path, "**.hpp)"))
end
if is_plat("windows") or is_plat("mingw") then
for _, plat in ipairs({ "posix", "linux", "darwin", "macos", "ios", "bsd", "android" }) do
remove_files(path.join(src_path, plat, "**"))
remove_headerfiles(path.join(src_path, plat, "**"))
end
elseif is_plat("macosx") then
for _, plat in ipairs({ "linux", "win32", "ios", "bsd", "android" }) do
remove_files(path.join(src_path, plat, "**"))
remove_headerfiles(path.join(src_path, plat, "**"))
end
elseif is_plat("ios") then
for _, plat in ipairs({ "linux", "macos", "win32", "bsd", "android" }) do
remove_files(path.join(src_path, plat, "**"))
remove_headerfiles(path.join(src_path, plat, "**"))
end
elseif is_plat("android") then
for _, plat in ipairs({ "linux", "darwin", "macos", "ios", "bsd", "win32" }) do
remove_files(path.join(src_path, plat, "**"))
remove_headerfiles(path.join(src_path, plat, "**"))
end
elseif is_plat("linux") then
for _, plat in ipairs({ "win32", "darwin", "macos", "ios", "bsd", "android" }) do
remove_files(path.join(src_path, plat, "**"))
remove_headerfiles(path.join(src_path, plat, "**"))
end
end
add_includedirs("$(projectdir)/include", { public = true })
if module.defines then add_defines(module.defines) end
if module.public_defines then add_defines(module.public_defines, { public = true }) end
if module.cxxflags then
add_cxxflags(module.cxxflags)
add_mxxflags(module.cxxflags)
end
if module.deps then add_deps(module.deps) end
if module.public_deps then add_deps(module.public_deps, { public = true }) end
if module.packages then
local packages = {}
for _, package in ipairs(module.packages) do
table.insert(packages, package:split(" ")[1])
end
add_packages(packages, { public = is_kind("static") })
end
if module.public_packages then
local packages = {}
for _, package in ipairs(module.public_packages) do
table.insert(packages, package:split(" ")[1])
end
add_packages(packages, { public = true })
end
if module.frameworks then add_frameworks(module.frameworks, { public = is_kind("static") }) end
add_options("sanitizers")
end)
end
end
target("stormkit", function()
set_group("libraries")
set_kind("moduleonly")
set_languages("cxxlatest", "clatest")
add_rules("stormkit.flags")
add_files("modules/stormkit.mpp")
add_deps("core", "main")
for _, name in ipairs({ "log", "entities", "image", "wsi", "gpu" }) do
if get_config(name) then
add_deps(name)
set_configvar("STORMKIT_LIB_" .. string.upper(name) .. "_ENABLED", "true")
end
end
add_headerfiles("$(builddir)/.gens/include/(stormkit/*.hpp)")
end)
add_includedirs("$(builddir)/.gens/include")
-- if not is_host("windows") then add_requireconfs("**.pkg-config", { override = true, system = true }) end
-- add_requireconfs("**.bison", { override = true, system = true })
-- add_requireconfs("**.m4", { override = true, system = true })
-- add_requireconfs("**.python", { override = true, system = true })
-- add_requireconfs("**.meson", { override = true, system = true })
-- add_requireconfs("**.autoconf", { override = true, system = true })
-- add_requireconfs("**.cmake", { override = true, system = true })
-- add_requireconfs("**.nasm", { override = true, system = true })
for name, _ in pairs(modules) do
if get_config("examples_" .. name) then
local example_dir = path.join("examples", name)
if os.exists(example_dir) and has_config("" .. name) then
includes(path.join(example_dir, "**", "xmake.lua"))
end
end
end
if get_config("tests") then includes("xmake/tests.xmake.lua") end
if get_config("tools") then includes("tools/**.lua") end
end)