aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/build.lua
diff options
context:
space:
mode:
authorDavid Walter Seikel2014-04-20 15:24:46 +1000
committerDavid Walter Seikel2014-04-20 15:24:46 +1000
commitc501a8c75e6fce2e91d52f60a5454de5aa3ef8f1 (patch)
tree0c6d24aef960df463c2ed6c399aa4eb535f2e66f /build.lua
parentelm_naviframe_item_title_visible_set() was deprecated, replace it. (diff)
downloadSledjHamr-c501a8c75e6fce2e91d52f60a5454de5aa3ef8f1.zip
SledjHamr-c501a8c75e6fce2e91d52f60a5454de5aa3ef8f1.tar.gz
SledjHamr-c501a8c75e6fce2e91d52f60a5454de5aa3ef8f1.tar.bz2
SledjHamr-c501a8c75e6fce2e91d52f60a5454de5aa3ef8f1.tar.xz
Convert build shell scripts to Lua, with common infrastructure.
Diffstat (limited to 'build.lua')
-rwxr-xr-xbuild.lua86
1 files changed, 86 insertions, 0 deletions
diff --git a/build.lua b/build.lua
new file mode 100755
index 0000000..de337de
--- /dev/null
+++ b/build.lua
@@ -0,0 +1,86 @@
1#!/usr/bin/env lua
2
3local args = ...
4local tmpFile = os.tmpname()
5
6readCommand = function (command)
7 os.execute(command .. ' >' .. tmpFile)
8 local tf = io.open(tmpFile, 'r')
9 local result = tf:read()
10 tf:close()
11 return result
12end
13
14pkgConfig = function (what, name)
15 return readCommand('pkg-config --' .. what .. ' ' .. name)
16end
17
18removeFiles = function (dir, files)
19 print('clean')
20 for i, v in ipairs(files) do
21 os.execute('rm -f ' .. dir .. '/' .. v)
22 end
23end
24
25runCommand = function (name, dir, command)
26 if name then print('\n' .. name) end
27 os.execute('cd ' .. dir .. '; ' .. command)
28end
29
30compileFiles = function (name, dir, files)
31 local objects = ''
32 print('\n' .. name)
33 for i, v in ipairs(files) do
34 print(' ' .. v)
35 os.execute('cd ' .. dir .. '; gcc ' .. CFLAGS .. ' -c -o ' .. v .. '.o ' .. v .. '.c')
36 objects = objects .. ' ' .. v .. '.o'
37 end
38 os.execute('cd ' .. dir .. '; gcc ' .. CFLAGS .. ' -o ' .. name .. ' ' .. objects .. ' ' .. LDFLAGS .. ' ' .. libs)
39end
40
41local buildSub = function (name, dir)
42 print('_______________ BUILDING ' .. name .. ' _______________')
43 local build, err = loadfile(LOCALDIR .. '/' .. dir .. '/build.lua')
44 if build then
45 setfenv(build, getfenv(2))
46 build(LOCALDIR .. '/' .. dir)
47 else
48 print("ERROR - " .. err)
49 end
50end
51
52-- Likely this will fail, coz Lua likes to strip out environmont variables.
53-- On the other hand, there's a more direct way to get to environment variables, it would fail to.
54CFLAGOPTS = readCommand('echo "$CFLAGOPTS"')
55
56LOCALDIR = readCommand('pwd')readCommand('pwd')
57CFLAGS = '-g -Wall -I include -I ' .. LOCALDIR .. ' -I ../../libraries'
58CFLAGS = CFLAGS .. ' ' .. pkgConfig('cflags', 'luajit')
59CFLAGS = CFLAGS .. ' ' .. pkgConfig('cflags', 'eo')
60CFLAGS = CFLAGS .. ' ' .. pkgConfig('cflags', 'eet')
61CFLAGS = CFLAGS .. ' ' .. pkgConfig('cflags', 'ecore-con')
62CFLAGS = CFLAGS .. ' ' .. pkgConfig('cflags', 'ecore-evas')
63CFLAGS = CFLAGS .. ' ' .. pkgConfig('cflags', 'ecore-file')
64CFLAGS = CFLAGS .. ' ' .. pkgConfig('cflags', 'edje')
65CFLAGS = CFLAGS .. ' ' .. pkgConfig('cflags', 'elementary')
66CFLAGS = CFLAGS .. ' -DPACKAGE_BIN_DIR=\\"' .. LOCALDIR .. '\\"'
67CFLAGS = CFLAGS .. ' -DPACKAGE_LIB_DIR=\\"' .. LOCALDIR .. '\\"'
68CFLAGS = CFLAGS .. ' -DPACKAGE_DATA_DIR=\\"' .. LOCALDIR .. '\\"'
69CFLAGS = CFLAGS .. ' ' .. CFLAGOPTS
70
71LDFLAGS = '-L ' .. LOCALDIR .. ' ' .. pkgConfig('libs-only-L', 'luajit') .. ' -L lib -L /usr/lib -L /lib'
72libs = pkgConfig('libs', 'elementary') .. ' ' .. pkgConfig('libs', 'luajit') .. ' -lpthread -lm'
73LFLAGS = '-d'
74EDJE_FLAGS = '-id images -fd fonts'
75
76
77if 'nil' == type(args) then
78 print('_______________ BUILDING lemon _______________')
79 removeFiles(LOCALDIR .. '/libraries/lemon', {'*.o', 'lemon'})
80 compileFiles('lemon', LOCALDIR .. '/libraries/lemon', {'lemon'})
81 print('_______________ BUILDING Irrlicht _______________')
82 runCommand('Irrlicht', 'libraries/irrlicht-1.8.1/source/Irrlicht', 'make')
83 buildSub('LuaSL', 'LuaSL')
84 buildSub('GuiLua', 'ClientHamr/GuiLua')
85 buildSub('extantz', 'ClientHamr/extantz')
86end