-
Notifications
You must be signed in to change notification settings - Fork 17
Expand file tree
/
Copy pathxmake.lua
More file actions
325 lines (285 loc) · 9.83 KB
/
xmake.lua
File metadata and controls
325 lines (285 loc) · 9.83 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
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
set_xmakever("2.9.5")
-- Globals
PROJECT_NAME = "SexLabUtil"
PROJECT_VERSION = "2.16.0"
-- Includes
includes("lib/CommonLibSSE-NG/xmake.lua")
includes("xmake/dotenv")
includes("xmake/papyrus")
includes("xmake/spriggit")
add_moduledirs("xmake/modules")
-- Project
set_project(PROJECT_NAME)
set_version(PROJECT_VERSION)
set_languages("cxx23")
set_license("apache-2.0")
set_warnings("allextra", "error")
-- Options
option("papyrus_include")
set_category("papyrus")
set_description("Path to papyrus include directories",
'Defaults to: "%XSE_TES5_MODS_PATH%"')
on_check(function(option)
import("dotenv.check")(option, {"$(env XSE_TES5_MODS_PATH)"})
end)
option_end()
option("papyrus_gamesource")
set_category("papyrus")
set_description('Path to directory containing game\'s "Source\\Scripts"',
'Defaults to: "%XSE_TES5_GAME_PATH%\\Data"')
on_check(function(option)
import("dotenv.check")(option, {"$(env XSE_TES5_GAME_PATH)", "Data"})
end)
option_end()
option("auto_install")
set_category("install")
set_description("Automatically trigger an install after successful build",
"Only if 'install_path' is set")
set_default(false)
after_check("dotenv.check")
option_end()
option("install_path")
set_category("install")
set_description("Set default installation path for commands and auto_install",
'Defaults to: "%XSE_TES5_MODS_PATH%\\SL-Dev"')
on_check(function(option)
import("dotenv.check")(option, {"$(env XSE_TES5_MODS_PATH)", "SL-Dev"})
end)
option_end()
option("build_assets")
set_category("build")
set_description("Enable 'assets' target")
set_default(true)
option("build_dll")
set_category("build")
set_description("Enable '" .. PROJECT_NAME .. "' target")
set_default(true)
option("build_papyrus")
set_category("build")
set_description("Enable 'papyrus' target")
set_default(true)
option("build_spriggit")
set_category("build")
set_description("Enable 'SexLab.esm' target")
set_default(true)
-- ensure dotenv is loaded before imported options
option("papyrus_path")
add_deps("dotenv")
option("spriggit_path")
add_deps("dotenv")
-- hide commonlibsse-ng options
option("rex_ini")
set_showmenu(false)
option("rex_json")
set_showmenu(false)
option("rex_toml")
set_showmenu(false)
option("skse_xbyak")
set_showmenu(false)
option("tests")
set_showmenu(false)
option_end()
-- Dependencies & Includes
-- https://github.com/xmake-io/xmake-repo/tree/dev
add_requires("yaml-cpp", "magic_enum", "nlohmann_json", "simpleini", "glm")
-- policies
set_policy("package.requires_lock", true)
-- rules
add_rules("mode.debug", "mode.release")
if is_mode("debug") then
add_defines("DEBUG")
set_optimize("none")
elseif is_mode("release") then
add_defines("NDEBUG")
set_optimize("fastest")
set_symbols("debug")
end
set_allowedplats("windows")
set_allowedarchs("x64")
set_defaultplat("windows")
set_defaultarchs("x64")
--Applied to ALL targets
rule("common")
after_config(function(target)
-- after_config to ensure install_path overwrites value set by
-- commonlibsse-ng.plugin
import("core.project.config")
local install_path = config.get("install_path")
if install_path then
target:set("installdir", install_path, {readonly = true})
end
end)
after_build(function(target)
import("core.project.config")
import("core.base.task")
local auto_install = config.get("auto_install")
local install_path = config.get("install_path")
if auto_install and install_path and target:name() ~= "commonlibsse-ng" then
task.run("install", {target = target:name()})
end
end)
on_install(function(target)
local srcfiles, dstfiles = target:installfiles()
if srcfiles and dstfiles then
for idx, srcfile in ipairs(srcfiles) do
os.vcp(srcfile, dstfiles[idx], {copy_if_different = true})
end
end
end)
rule_end()
add_rules("common")
-- Target
target(PROJECT_NAME)
set_enabled(get_config("build_dll"))
-- Dependencies
add_packages("yaml-cpp", "magic_enum", "nlohmann_json", "simpleini", "glm")
-- CommonLibSSE
add_deps("commonlibsse-ng")
add_rules("commonlibsse-ng.plugin", {
name = PROJECT_NAME,
author = "Scrab",
description = "Backend for skyrims adult animation framework 'SexLab'."
})
-- Source files
set_pcxxheader("src/PCH.h")
add_files("src/**.cpp")
add_headerfiles("src/**.h")
add_includedirs("src")
-- flags
add_cxxflags(
"cl::/cgthreads4",
"cl::/diagnostics:caret",
"cl::/external:W0",
"cl::/fp:contract",
"cl::/fp:except-",
"cl::/guard:cf-",
"cl::/Zc:enumTypes",
"cl::/Zc:preprocessor",
"cl::/Zc:templateScope",
"cl::/utf-8"
)
-- flags (cl: warnings -> errors)
add_cxxflags("cl::/we4715") -- `function` : not all control paths return a value
-- flags (cl: disable warnings)
add_cxxflags(
"cl::/wd4068", -- unknown pragma 'clang'
"cl::/wd4201", -- nonstandard extension used : nameless struct/union
"cl::/wd4265" -- 'type': class has virtual functions, but its non-trivial destructor is not virtual; instances of this class may not be destructed correctly
)
-- Conditional flags
if is_mode("debug") then
add_cxxflags("cl::/bigobj")
elseif is_mode("release") then
add_cxxflags("cl::/Zc:inline", "cl::/JMC-", "cl::/Ob3")
end
on_load(function(target)
local clib = target:rule("commonlibsse-ng.plugin")
if clib then
-- disable unwanted events
clib:set("install", nil)
clib:set("package", nil)
clib:set("build_after", nil)
end
end)
-- Post Build
after_build(function (target)
import("lib.detect.find_tool")
local python = find_tool("python3")
if python then
os.execv(python.program, {"scripts/generate_config.py"})
else
print("Warning: Python not found. Skipping config generation.")
end
os.vcp(target:targetfile(), "dist/SKSE/Plugins")
os.vcp(target:symbolfile(), "dist/SKSE/Plugins")
os.vcp("scripts/out/*", "dist/SKSE/Plugins", {copy_if_different = true})
target:add("installfiles", "scripts/out/SexLab.ini", {prefixdir = "SKSE/Plugins"})
end)
target_end()
target("papyrus")
set_enabled(get_config("build_papyrus"))
set_kind("object")
set_targetdir("dist/Scripts")
set_basename("SexLab")
--avoid rebuild on mode change
set_policy("build.intermediate_directory", false)
add_rules("papyrus")
add_files("dist/Source/Scripts/*.psc")
add_includedirs("dist/Source/Scripts")
add_includedirs("$(papyrus_include)/SkyrimLovense/Source/Scripts")
add_includedirs("$(papyrus_include)/PapyrusUtil SE - Modders Scripting Utility Functions/Source/Scripts")
add_includedirs("$(papyrus_include)/SkyUI SDK/Source/Scripts")
add_includedirs("$(papyrus_include)/Race Menu Sources/Source/Scripts")
add_includedirs("$(papyrus_include)/MfgFix NG/Source/Scripts")
add_includedirs("$(papyrus_gamesource)/Source/Scripts")
on_load(function(target)
import("core.project.config")
if not config.get("papyrus_include") then
cprint("${color.warning}papyrus_include is not defined")
end
if not config.get("papyrus_gamesource") then
cprint("${color.warning}papyrus_gamesource is not defined")
end
end)
before_build(function(target)
import("core.project.config")
assert(config.get("papyrus_include"), "papyrus_include is not defined")
assert(config.get("papyrus_gamesource"), "papyrus_gamesource is not defined")
end)
target_end()
target("SexLab.esm")
set_enabled(get_config("build_spriggit"))
set_kind("object")
set_targetdir("dist")
--avoid rebuild on mode change
set_policy("build.intermediate_directory", false)
add_rules("spriggit")
set_values("spriggit.srcdir", "res/SexLab.esm")
target_end()
target("assets")
set_enabled(get_config("build_assets"))
set_kind("phony")
add_installfiles("dist/(Interface/SexLab/**)")
add_installfiles("dist/(Interface/Translations/*.txt)")
add_installfiles("dist/(SKSE/CustomConsole/*.yaml)")
add_installfiles("dist/(SKSE/SexLab/**)")
add_installfiles("dist/(meshes/**)")
add_installfiles("dist/(textures/**)")
add_installfiles("dist/(Sound/**)")
target_end()
task("serialize")
on_run(function()
import("core.base.option")
import("core.base.task")
task.run("config")
task.run("spriggit.serialize", {
target = "SexLab.esm",
install = option.get("install"),
})
end)
set_menu {
shortname = 's',
usage = "xmake serialize [-i | <srcfile>]",
description = "Serialize SexLab.esm",
options = {
{'i', "install", "k", nil, "Serialize from installdir." },
{'o', "installdir", "kv", nil, "Override the install directory."},
}
}
task_end()
includes("@builtin/xpack")
xpack("SexLab")
set_formats("zip")
set_extension(".7z")
set_basename("SexLab Framework PPLUS - V$(version)")
add_targets(PROJECT_NAME, "papyrus", "assets", "SexLab.esm")
on_installcmd(function(package, batchcmds)
local installdir = package:installdir()
local install = import("test_ln")() and batchcmds.ln or batchcmds.cp
for _, v in pairs(package:targets()) do
srcfiles, dstfiles = v:installfiles(installdir)
for idx, srcfile in ipairs(srcfiles) do
install(batchcmds, path.absolute(srcfile), dstfiles[idx])
end
end
end)