forked from RaphaelIT7/gmod-holylib
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpremake5.lua
More file actions
193 lines (165 loc) · 6.08 KB
/
premake5.lua
File metadata and controls
193 lines (165 loc) · 6.08 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
--[[
This premake file is also loaded by our development/module/premake5.lua
If this happens the HOLYLIB_DEVELOPMENT will be set to true
I did this to have 1 premake file instead of 2 separate ones.
]]
PROJECT_GENERATOR_VERSION = 3
if not HOLYLIB_DEVELOPMENT then
newoption({
trigger = "gmcommon",
description = "Sets the path to the garrysmod_common (https://github.com/danielga/garrysmod_common) directory",
default = "../garrysmod_common"
})
newoption({
trigger = "dedicated",
description = "Build for Windows dedicated server (defines DEDICATED)"
})
HOLYLIB_DEDICATED = _OPTIONS["dedicated"] and true or false
end
local gmcommon = assert(_OPTIONS.gmcommon or os.getenv("GARRYSMOD_COMMON"),
"you didn't provide a path to your garrysmod_common (https://github.com/danielga/garrysmod_common) directory")
include(gmcommon)
local rootDir = ""
local sourcePath = "source/"
if HOLYLIB_DEVELOPMENT then
rootDir = "../../"
sourcePath = rootDir .. sourcePath
end
if os.isdir(sourcePath .. "ivp/") then -- Anyone can remove the ivp folder if they don't want HolyLib to include a IVP build.
include(sourcePath .. "ivp/premake5.lua")
end
include(sourcePath .. "bootil/premake5.lua")
include(sourcePath .. "_prebuildtools/_dependency_manager.lua")
--[[
Workflow info variables
]]
local file = io.open("workflow_info.txt", "r") -- Added this file to the workflow so it could also be useful for others.
local run_id = file and file:read("*l") or "1" -- First line = workflow run id
local run_number = file and file:read("*l") or "1" --- Second line = workflow run number
local branch = file and file:read("*l") or "main" -- Third line = branch -> "main"
local additional = file and file:read("*l") or "0" -- Fouth line = Additional data. We set it to 1 for releases.
--[[
Prebuild command setup
]]
local prebuildCommand = ""
local basePath = "cd ../../../"
if os.host() == "windows" then
prebuildCommand = sourcePath .. "_prebuildtools/ && luajit.exe _compilefiles.lua"
else
if os.is64bit() then
prebuildCommand = sourcePath .. "_prebuildtools/ && chmod +x luajit_64 && ./luajit_64 _compilefiles.lua"
else
prebuildCommand = sourcePath .. "_prebuildtools/ && chmod +x luajit_32 && ./luajit_32 _compilefiles.lua"
end
end
os.execute("cd " .. prebuildCommand)
prebuildCommand = basePath .. prebuildCommand -- We add this after execute since the path for premake setup & project build differ
--[[
Project setup
]]
CreateWorkspace({name = "holylib", abi_compatible = true})
-- Serverside module (gmsv prefix)
-- Can define "source_path", where the source files are located
-- Can define "manual_files", which allows you to manually add files to the project,
-- instead of automatically including them from the "source_path"
-- Can also define "abi_compatible", for project specific compatibility
CreateProject({serverside = true, manual_files = false, source_path = sourcePath:sub(0, -2)})
kind "SharedLib"
symbols "On"
-- Remove some or all of these includes if they're not needed
IncludeHelpersExtended()
--IncludeLuaShared()
IncludeSDKCommon()
IncludeSDKTier0()
IncludeSDKTier1()
--IncludeSDKTier2()
--IncludeSDKTier3()
IncludeSDKMathlib()
--IncludeSDKRaytrace()
--IncludeSDKBitmap()
--IncludeSDKVTF()
IncludeSteamAPI()
IncludeDetouring()
IncludeScanning()
if IncludeIVP then
--IncludeIVP() -- Can be removed if anyone doesn't want it.
end
IncludeBootil()
if HOLYLIB_DEVELOPMENT then
defines("HOLYLIB_BUILD_RELEASE=0")
defines("HOLYLIB_DEVELOPMENT=1")
else
defines("HOLYLIB_BUILD_RELEASE=" .. additional)
end
defines("SWDS=1")
defines("PROJECT_NAME=\"holylib\"")
defines("NO_FRAMESNAPSHOTDEF")
defines("NO_VCR")
defines("IVP_NO_PERFORMANCE_TIMER")
defines("PHYSENV_INCLUDEIVPFALLBACK")
defines("CPPHTTPLIB_NO_EXCEPTIONS") -- We don't want exceptions!
defines("NOBASSOVERLOADS")
prebuildcommands(prebuildCommand)
files({
gmcommon .. [[/sourcesdk-minimal/public/filesystem_helpers.cpp]],
sourcePath .. [[opus/*.h]],
sourcePath .. [[modules/*.h]],
sourcePath .. [[modules/*.cpp]],
sourcePath .. [[sourcesdk/*.h]],
sourcePath .. [[sourcesdk/*.cpp]],
sourcePath .. [[public/*.h]],
sourcePath .. [[lua/*.*]],
sourcePath .. [[lz4/*.h]],
sourcePath .. [[lz4/*.c]],
sourcePath .. [[lz4/*.cpp]],
sourcePath .. [[uwebsockets/*.h]],
sourcePath .. [[uwebsockets/*.cpp]],
rootDir .. "lua/*.h",
rootDir .. "source/lua/scripts/*.lua",
rootDir .. "README.md",
rootDir .. ".github/workflows/**.yml",
})
vpaths({
["Source files/sourcesdk/"] = gmcommon .. "/**.*",
["Lua Headers"] = rootDir .. "lua/*.h",
["Lua Scrips"] = rootDir .. "source/lua/scripts/*.lua",
["uWebSockets"] = sourcePath .. "uwebsockets/*.*",
["README"] = rootDir .. "README.md",
["Workflows"] = rootDir .. ".github/workflows/**.yml",
})
removefiles(GetExcludedFiles(sourcePath)) -- Remove source files marked by our dependency manager
includedirs({
sourcePath .. [[sourcesdk/]],
sourcePath .. [[lua]],
})
filter("system:windows")
defines("IVP_NO_MATH_INL")
disablewarnings({"4101"})
links({"lua51_32.lib"})
links({"lua51_64.lib"})
links({"opus_32.lib"})
links({"opus_64.lib"})
filter("system:windows", "platforms:x86")
libdirs(rootDir .. "libs/win32")
filter("system:windows", "platforms:x86_64")
libdirs(rootDir .. "libs/win64")
filter({"system:linux", "platforms:x86_64"})
libdirs(rootDir .. "libs/linux64")
buildoptions({"-mcx16"}) -- Should solve this: undefined reference to `__sync_bool_compare_and_swap_16'
links("luajit_64")
links("opus_64")
filter({"system:linux", "platforms:x86"})
libdirs(rootDir .. "libs/linux32")
links("luajit_32")
links("opus_32")
filter({"platforms:x86_64"})
defines("PLATFORM_64BITS")
filter("system:windows")
if not HOLYLIB_DEDICATED then
defines("NOT_DEDICATED") -- Windows client build
end
filter("system:linux")
disablewarnings({"unused-variable"})
targetextension(".so")
links({"dl", "tier0", "pthread"}) -- this fixes the undefined reference to `dlopen' errors.
defines("DEDICATED") -- All linux build focus Linux dedicated servers.