-
Notifications
You must be signed in to change notification settings - Fork 0
/
premake5.lua
109 lines (85 loc) · 2.97 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
-- this can be either CLIENT or SERVER
local realm = "SERVER"
-- set this to true if youre compiling for windows systems
local is_windows = false
-- this only has an effect on WINDOWS builds
local arch = "x32" -- x32 for 32-bit, x64 for 64-bit
-- name of your module
local module_name = "websocket"
-- optional install directory for the 'install' action
local install_dir = "/home/gmod_exp01/serverfiles/garrysmod/lua/bin/" -- should end with /
function getModulePrefix()
return (realm == "SERVER") and "gmsv" or "gmcl"
end
workspace ("lunar-" .. module_name)
location "makefiles"
architecture "x32"
language "C++"
cppdialect "C++17"
targetdir "build/bin"
objdir "build/obj"
targetname (module_name)
targetprefix (getModulePrefix() .. "_")
targetsuffix "_linux"
targetextension ".dll"
configurations { "debug", "release" }
filter { "configurations:debug" }
symbols "On"
buildoptions { "-Wall", "-Wextra", "-Wpedantic", "-Wnull-dereference", "-Wmisleading-indentation" }
filter { "configurations:release" }
optimize "On"
buildoptions { "-O3", "-Wall", "-Wextra", "-Wpedantic", "-Wnull-dereference", "-Wmisleading-indentation" }
filter { }
project (module_name)
kind "SharedLib"
files "**"
includedirs { ".", "sol2/include" }
if realm == "CLIENT" then
defines { "LUNAR_CLIENT_MODULE" }
end
if is_windows and arch == "x64" then
defines { "LUNAR_WINDOWS_x64" }
end
function getCompiledBinaryPath()
return "./build/bin/" .. getModulePrefix() .. "_" .. module_name .. "_linux.dll"
end
function getInstallpath()
return install_dir .. getModulePrefix() .. "_" .. module_name .. "_linux.dll"
end
newaction {
trigger = "clean",
description = "clean the software",
execute = function()
os.rmdir("./build")
os.rmdir("./makefiles")
end
}
newaction {
trigger = "verify",
description = "verify the compiled binary",
execute = function()
local out = os.outputof("file " .. getCompiledBinaryPath())
if out:find("ELF 32-bit LSB pie executable", 1, true) then
if out:find("debug_info", 1, true) then
print("Binary is valid and is a debug build")
else
print("Binary is valid and is a release build")
end
else
print("Error: Invalid binary format")
end
end
}
newaction {
trigger = "install",
description = "install the library",
execute = function()
if not os.copyfile(getCompiledBinaryPath(), getInstallpath()) then
print("Error: Could not copy file. File permissions issue?")
else
print("~ cp " .. getCompiledBinaryPath() .. " " .. getInstallpath())
print("Installed module successfully. Remember that gmod caches modules so you will" ..
" need to restart your server for changes to take effect.")
end
end
}