forked from KrisV-777/Dynamic-Body-Distribution
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathxmake.lua
More file actions
154 lines (136 loc) · 4.94 KB
/
Copy pathxmake.lua
File metadata and controls
154 lines (136 loc) · 4.94 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
set_xmakever("2.9.5")
-- Globals
PROJECT_NAME = "DynamicBodyDistribution"
-- Project
set_project(PROJECT_NAME)
set_version("0.5.1")
set_languages("cxx23")
set_license("apache-2.0")
set_warnings("allextra", "error")
-- Options
option("copy_to_papyrus")
set_default(true)
set_description("Copy finished build to Papyrus SKSE folder")
option_end()
option("package")
set_default(true)
set_description("Copy finished build to Papyrus SKSE folder")
option_end()
-- Dependencies & Includes
-- https://github.com/xmake-io/xmake-repo/tree/dev
add_requires("yaml-cpp", "frozen", "magic_enum", "rapidxml")
includes("lib/CommonLibVR")
target("detours")
set_kind("static")
set_languages("c++17")
add_headerfiles("lib/detours/src/*.h", { prefixdir = "detours" })
add_includedirs("lib/detours/src")
add_files("lib/detours/src/*.cpp")
remove_files("lib/detours/src/uimports.cpp")
set_installdir("build/detours")
target_end()
-- 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_config("skse_xbyak", true)
set_config("skyrim_se", true)
set_config("skyrim_ae", true)
set_config("skyrim_vr", true)
-- Target
target(PROJECT_NAME)
-- Dependencies
add_packages("yaml-cpp", "frozen", "magic_enum", "rapidxml")
add_deps("detours")
add_includedirs("lib/detours/src")
-- CommonLibSSE
add_deps("commonlibsse-ng")
add_rules("commonlibsse-ng.plugin", {
name = PROJECT_NAME,
author = "Kris",
description = "Dynamically replace body textures and sliders"
})
-- 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
"cl::/we4189" -- `variable` : local variable is initialized but not referenced
)
-- 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
-- Post Build
after_build(function (target)
local mod_folder = os.getenv("XSE_TES5_MODS_PATH")
local game_folder = os.getenv("XSE_TES5_GAME_PATH")
if game_folder then
local compiler_folder = path.join(game_folder, "Papyrus Compiler/PapyrusCompiler.exe")
local script_source = "dist/source/scripts"
local script_output = "dist/scripts"
local flags_file = path.join(game_folder, "Data/Source/Scripts/TESV_Papyrus_Flags.flg")
os.execv(compiler_folder, { script_source,
"-i=" .. script_source .. ";" .. path.join(game_folder, "Data/Source/Scripts") .. ";"
.. path.join(mod_folder, "ConsoleUtil Extended/Source/Scripts"),
"-o=" .. script_output,
"-f=" .. flags_file,
"-optimize", "-all" })
local plugin_folder = "dist/SKSE/Plugins"
if not os.isdir(plugin_folder) then
os.mkdir(plugin_folder)
end
os.cp(target:targetfile(), plugin_folder)
os.cp(target:symbolfile(), plugin_folder)
if (is_mode("release")) then
local release_folder = path.join(os.projectdir(), ".release")
local zipfile = path.join(release_folder, target:basename() .. "-" .. target:version() .. ".7z")
local files = path.join(os.projectdir(), "dist/*")
if not os.isdir(release_folder) then
os.mkdir(release_folder)
end
os.exec("7z a " .. zipfile .. " " .. files)
end
else
print("Warning: GamePath not defined. Skipping script compilation.")
end
if mod_folder and has_config("copy_to_papyrus") then
local SkyrimPath = path.join(mod_folder, target:basename())
os.cp("dist/*", SkyrimPath)
else
print("Warning: SkyrimPath not defined. Skipping post-build copy.")
end
end)
target_end()