-
-
Notifications
You must be signed in to change notification settings - Fork 44
/
premake5.lua
223 lines (176 loc) · 5.03 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
-------------------------------------------------
-- DEPENDENCIES
-------------------------------------------------
dependencies = { base = path.getrelative(os.getcwd(), path.getabsolute("deps")) }
function dependencies.load()
dir = path.join(dependencies.base, "*.lua")
deps = os.matchfiles(dir)
for i, dep in pairs(deps) do
dep = dep:gsub(".lua", "")
require(dep)
end
end
dependencies.load()
-------------------------------------------------
-- VERSIONING
-------------------------------------------------
function version_split(version, revision)
array = {}
for num in string.gmatch(version or "", "%d+") do
if #array < 3 then
table.insert(array, tonumber(num))
end
end
while #array < 3 do
table.insert(array, 0)
end
table.insert(array, tonumber(revision))
return array
end
function generate_version()
-- get current version
local proc1 = assert(io.popen("git describe --tags --abbrev=0", "r"))
local version = assert(proc1:read('*a')):gsub("%s+", "")
proc1:close()
-- get current branch
local proc2 = assert(io.popen("git symbolic-ref -q --short HEAD", "r"))
local branch = assert(proc2:read('*a')):gsub("%s+", "")
proc2:close()
-- get revision number
local proc3 = assert(io.popen("git rev-list --count HEAD", "r"))
local revision = assert(proc3:read("*a")):gsub("%s+", "")
proc3:close()
local split = version_split(version, revision)
local verstr = split[1] .. "." .. split[2] .. "." .. split[3] .. "." .. split[4]
if branch ~= "" then
verstr = verstr .. "-" .. branch
end
local file = assert(io.open("include/xsk/version.hpp", "w"))
file:write("// Generated by premake - do not edit\n\n")
file:write("#define XSK_VERSION_MAJOR " .. split[1] .. "\n")
file:write("#define XSK_VERSION_MINOR " .. split[2] .. "\n")
file:write("#define XSK_VERSION_PATCH " .. split[3] .. "\n")
file:write("#define XSK_VERSION_BUILD " .. split[4] .. "\n")
file:write("#define XSK_VERSION_BRANCH \"" .. branch .. "\"\n")
file:write("#define XSK_VERSION_STR \"" .. verstr .. "\"\n")
file:close()
end
generate_version()
-------------------------------------------------
-- PROJECTS
-------------------------------------------------
workspace "gsc-tool"
startproject "xsk-tool"
location "./build"
objdir "%{wks.location}/obj/%{cfg.buildcfg}/%{prj.name}"
targetdir "%{wks.location}/bin/%{cfg.platform}/%{cfg.buildcfg}"
targetname "%{prj.name}"
configurations { "debug", "release" }
if os.istarget("linux") or os.istarget("macosx") then
platforms { "x64", "arm64" }
else
platforms { "x86", "x64", "arm64" }
end
filter "platforms:x86"
architecture "x86"
filter {}
filter "platforms:x64"
architecture "x86_64"
filter {}
filter "platforms:arm64"
architecture "ARM64"
filter {}
filter { "language:C++", "toolset:not msc*" }
buildoptions "-std=c++20"
filter {}
filter "toolset:msc*"
buildoptions "/bigobj"
buildoptions "/Zc:__cplusplus"
buildoptions "/std:c++20"
filter {}
filter { "system:windows" }
systemversion "latest"
filter {}
staticruntime "On"
warnings "Extra"
filter "system:linux"
linkoptions "-fuse-ld=lld"
filter {}
filter { "system:linux", "platforms:arm64" }
buildoptions "--target=arm64-linux-gnu"
linkoptions "--target=arm64-linux-gnu"
filter {}
filter { "system:macosx", "platforms:arm64" }
buildoptions "-arch arm64"
linkoptions "-arch arm64"
filter {}
filter "configurations:release"
optimize "Full"
symbols "Off"
defines "NDEBUG"
flags "FatalCompileWarnings"
filter {}
filter "configurations:debug"
optimize "Debug"
symbols "On"
defines { "DEBUG", "_DEBUG" }
filter {}
project "xsk-tool"
kind "ConsoleApp"
language "C++"
targetname "gsc-tool"
dependson "xsk-utils"
dependson "xsk-arc"
dependson "xsk-gsc"
files {
"./include/*.hpp",
"./src/tool/**.h",
"./src/tool/**.hpp",
"./src/tool/**.cpp"
}
links {
"xsk-utils",
"xsk-arc",
"xsk-gsc",
}
includedirs {
"./include",
}
cxxopts:link()
zlib:link()
project "xsk-utils"
kind "StaticLib"
language "C++"
files {
"./src/utils/**.h",
"./src/utils/**.hpp",
"./src/utils/**.cpp"
}
includedirs {
"./include",
}
zlib:include()
project "xsk-arc"
kind "StaticLib"
language "C++"
files {
"./src/arc/**.h",
"./src/arc/**.hpp",
"./src/arc/**.cpp"
}
includedirs {
"./include",
}
project "xsk-gsc"
kind "StaticLib"
language "C++"
files {
"./src/gsc/**.h",
"./src/gsc/**.hpp",
"./src/gsc/**.cpp"
}
includedirs {
"./include",
}
group "Dependencies"
zlib:project()