forked from mwilsnd/SkyrimSE-SmoothCam
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpremake5.lua
265 lines (227 loc) · 6.93 KB
/
premake5.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
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
newoption {
trigger = "VS_PLATFORM",
value = "vs2019",
description = "Select the version of Visual Studio Community to use.",
allowed = {
{ "vs2017", "Visual Studio Community 2017" },
{ "vs2019", "Visual Studio Community 2019" },
}
}
newoption {
trigger = "INTRIN",
value = "ON",
description = "Enable use of hardware SIMD intrinsics.",
allowed = {
{ "ON", "Use SIMD instructions" },
{ "OFF", "Disable SIMD instructions" },
}
}
if not _OPTIONS["VS_PLATFORM"] then
return error( "No visual studio platform selected, please set --VS_PLATFORM to vs2017 or vs2019" )
end
if _OPTIONS["INTRIN"] == "ON" then
_SIMD_MODE = "AVX"
print "Using AVX instructions"
else
_SIMD_MODE = "SSE"
print "Building for old CPUs"
end
local function rewriteFile(strPath, strData)
local f = io.open(strPath, "w")
assert(f, "Failed to open file ".. strPath.. "!\n")
f:write(strData)
f:close()
end
newaction {
trigger = "dd",
description = "Auto download all required dependencies and place them in the correct location",
execute = function()
term.pushColor( term.lightGreen )
print( "Checking for command line tools..." )
term.popColor()
local found_7z = false
for str in os.getenv( "PATH" ):gmatch( "([^;]+)" ) do
if str:find("7-Zip") ~= nil then
found_7z = true
end
end
if not found_7z then
term.pushColor( term.errorColor )
print( "7-Zip not found! Please install 7-Zip for windows and place the folder containing 7z.exe in the system PATH." )
term.popColor()
return
end
term.pushColor( term.lightGreen )
print( "Downloading dependencies, please wait..." )
term.popColor()
os.mkdir( "Deps" )
local deps = {
{
ok = false, name = "SKSE64", path = "BuildScripts/download_file.lua",
args = { "Deps/temp_downloads", "Deps", "skse64_2_00_19.7z", "http://skse.silverlock.org/beta/skse64_2_00_19.7z" },
postExec = function(tbl)
--Gross hack to deal with SKSE macros and our use of versionlib
--We blank the macros from this file, then force include our own version with the edits we need
local root = tbl.args[2].. "/skse64_2_00_19/src"
rewriteFile(root.. "/skse64/skse64_common/Utilities.h", [[
#pragma once
// this is the solution to getting a pointer-to-member-function pointer
template <typename T>
uintptr_t GetFnAddr(T src)
{
union
{
uintptr_t u;
T t;
} data;
data.t = src;
return data.u;
}
std::string GetRuntimePath();
std::string GetRuntimeName();
const std::string & GetRuntimeDirectory();
const std::string & GetConfigPath();
std::string GetConfigOption(const char * section, const char * key);
bool GetConfigOption_UInt32(const char * section, const char * key, UInt32 * dataOut);
const std::string & GetOSInfoStr();
void * GetIATAddr(void * module, const char * searchDllName, const char * searchImportName);
const char * GetObjectClassName(void * objBase);
void DumpClass(void * theClassPtr, UInt64 nIntsToDump);]])
--And rewrite this one to use our own impl
rewriteFile(root.. "/skse64/skse64_common/Relocation.h", [[
#pragma once
#include "addrlib/relocation.h"
]])
end,
},
}
for k, v in ipairs( deps ) do
term.pushColor( term.lightGreen )
printf( "Downloading %s...", v.name )
term.popColor()
v.ok = dofile( v.path )( table.unpack(v.args) )
if v.ok then
if v.postExec then v.postExec(v) end
end
end
for k, v in ipairs( deps ) do
if not v.ok then
term.pushColor( term.errorColor )
printf( "Error downloading %s! Please aquire this dependency manually.", v.name )
term.popColor()
else
term.pushColor( term.lightGreen )
printf( "Finished downloading %s!", v.name )
term.popColor()
end
end
end,
}
newaction {
trigger = "dmake",
description = "Build dependencies",
execute = function()
term.pushColor( term.lightGreen )
print( "Building Microsoft Detours..." )
term.popColor()
print( dofile( "BuildScripts/project_ms_detours.lua" )( os.getcwd().. "/Deps/Detours", _OPTIONS["VS_PLATFORM"] ) )
term.pushColor( term.lightGreen )
print( "Done." )
term.popColor()
end,
}
workspace "SmoothCam"
architecture "x64"
configurations { "Debug", "Release" }
startproject "SmoothCam"
dofile( "BuildScripts/project_common_skse64.lua" )
dofile( "BuildScripts/project_skse64_common.lua" )
dofile( "BuildScripts/project_skse64.lua" )
dofile( "BuildScripts/project_polyhook.lua" )
local outputDir = "%{cfg.buildcfg}-%{cfg.system}-%{cfg.architecture}"
project "SmoothCam"
location "SmoothCam"
language "C++"
compileas "C++"
cppdialect "C++17"
kind "SharedLib"
staticruntime "On"
targetdir( "SmoothCam/bin/".. outputDir.. "/%{prj.name}" )
objdir( "SmoothCam/bin-obj/".. outputDir.. "/%{prj.name}" )
dependson { "common_skse64", "skse64_common", "skse64", "PolyHook2" }
files { "SmoothCam/**.h", "SmoothCam/**.cpp", "SmoothCam/**.rc", "SmoothCam/**.def", "SmoothCam/**.ini" }
pchheader "pch.h"
pchsource "SmoothCam/source/pch.cpp"
forceincludes {
"../Deps/skse64_2_00_19/src/common/IPrefix.h",
"../SmoothCam/include/addrlib/skse_macros.h",
"pch.h"
}
includedirs {
"./SmoothCam/include",
"Deps/skse64_2_00_19/src/skse64",
"Deps/skse64_2_00_19/src",
"Deps/glm",
"Deps/PolyHook_2_0",
"Deps/eternal/include",
"Deps/json/single_include",
}
filter "system:windows"
systemversion "latest"
debugdir( "../bin/".. outputDir.. "/%{prj.name}" )
vectorextensions( _SIMD_MODE )
characterset "Unicode"
intrinsics "On"
fpu "Hardware"
filter "configurations:Debug"
defines { "DEBUG", "SMOOTHCAM_IMPL" }
buildoptions { "/bigobj" }
symbols "On"
editandcontinue "On"
floatingpoint "Strict"
functionlevellinking "On"
flags {
"MultiProcessorCompile"
}
libdirs {
"Deps/skse64_2_00_19/src/common/bin/Debug-windows-x86_64/common_skse64",
"Deps/skse64_2_00_19/src/skse64/skse64_common/bin/Debug-windows-x86_64/skse64_common",
"Deps/skse64_2_00_19/src/skse64/skse64/bin/Debug-windows-x86_64/skse64",
"Deps/Detours/lib.X64",
"Deps/PolyHook_2_0/bin/Debug-windows-x86_64/PolyHook2",
}
links {
"common_skse64.lib",
"skse64_common.lib",
"skse64.lib",
"detours.lib",
"PolyHook2.lib",
}
filter "configurations:Release"
defines { "NODEBUG", "NDEBUG", "SMOOTHCAM_IMPL" }
linkoptions { "/LTCG" }
buildoptions { "/Ob2", "/Ot" }
optimize "Speed"
editandcontinue "Off"
floatingpoint "Fast"
functionlevellinking "Off"
runtime "Release"
omitframepointer "On"
flags {
"LinkTimeOptimization", "FatalWarnings", "NoBufferSecurityCheck",
"NoMinimalRebuild", "NoRuntimeChecks", "MultiProcessorCompile"
}
libdirs {
"Deps/skse64_2_00_19/src/common/bin/Release-windows-x86_64/common_skse64",
"Deps/skse64_2_00_19/src/skse64/skse64_common/bin/Release-windows-x86_64/skse64_common",
"Deps/skse64_2_00_19/src/skse64/skse64/bin/Release-windows-x86_64/skse64",
"Deps/Detours/lib.X64",
"Deps/PolyHook_2_0/bin/Release-windows-x86_64/PolyHook2",
}
links {
"common_skse64.lib",
"skse64_common.lib",
"skse64.lib",
"detours.lib",
"PolyHook2.lib",
}