-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.lua
57 lines (42 loc) · 1.17 KB
/
build.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
-- Where the Principia source tree is located
local PREFIX = "src"
-- Common build flags
local COMMON_FLAGS = "-D_NO_TMS -O2"
-- Include dirs
local INCLUDE_DIRS = {
"-I"..PREFIX.."/src/src/",
"-I"..PREFIX.."/src/"}
-- Build function
-- output: Name of util, will be the output
-- libs: Libraries to link against
-- src: List of util source files
-- ext: List of Principia source files
local function build(output, libs, src, ext)
print("Building "..output.."...")
local command = {
"g++",
COMMON_FLAGS,
table.concat(INCLUDE_DIRS, " "),
}
for _, file in ipairs(src) do
table.insert(command, output..'/'..file)
end
for _, file in ipairs(ext) do
table.insert(command, PREFIX.."/src/src/"..file)
end
for _,lib in ipairs(libs) do
table.insert(command, "-l"..lib)
end
table.insert(command, "-o bin/"..output)
local code = os.execute(table.concat(command, ' '))
if code == 0 then
print("Successfully built "..output..".")
else
print("Failed to build "..output..", exiting...")
os.exit(1)
end
end
-- Build utils
os.execute("mkdir -p bin")
build('lvledit', {'z'}, {'main.cc'}, {'pkgman.cc', 'rand.c'})
build('progress-get', {'z'}, {'main.cc'}, {'progress.cc'})