diff options
author | David Walter Seikel | 2014-04-20 15:24:46 +1000 |
---|---|---|
committer | David Walter Seikel | 2014-04-20 15:24:46 +1000 |
commit | c501a8c75e6fce2e91d52f60a5454de5aa3ef8f1 (patch) | |
tree | 0c6d24aef960df463c2ed6c399aa4eb535f2e66f /build.lua | |
parent | elm_naviframe_item_title_visible_set() was deprecated, replace it. (diff) | |
download | SledjHamr-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 '')
-rwxr-xr-x | build.lua | 86 |
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 | |||
3 | local args = ... | ||
4 | local tmpFile = os.tmpname() | ||
5 | |||
6 | readCommand = 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 | ||
12 | end | ||
13 | |||
14 | pkgConfig = function (what, name) | ||
15 | return readCommand('pkg-config --' .. what .. ' ' .. name) | ||
16 | end | ||
17 | |||
18 | removeFiles = function (dir, files) | ||
19 | print('clean') | ||
20 | for i, v in ipairs(files) do | ||
21 | os.execute('rm -f ' .. dir .. '/' .. v) | ||
22 | end | ||
23 | end | ||
24 | |||
25 | runCommand = function (name, dir, command) | ||
26 | if name then print('\n' .. name) end | ||
27 | os.execute('cd ' .. dir .. '; ' .. command) | ||
28 | end | ||
29 | |||
30 | compileFiles = 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) | ||
39 | end | ||
40 | |||
41 | local 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 | ||
50 | end | ||
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. | ||
54 | CFLAGOPTS = readCommand('echo "$CFLAGOPTS"') | ||
55 | |||
56 | LOCALDIR = readCommand('pwd')readCommand('pwd') | ||
57 | CFLAGS = '-g -Wall -I include -I ' .. LOCALDIR .. ' -I ../../libraries' | ||
58 | CFLAGS = CFLAGS .. ' ' .. pkgConfig('cflags', 'luajit') | ||
59 | CFLAGS = CFLAGS .. ' ' .. pkgConfig('cflags', 'eo') | ||
60 | CFLAGS = CFLAGS .. ' ' .. pkgConfig('cflags', 'eet') | ||
61 | CFLAGS = CFLAGS .. ' ' .. pkgConfig('cflags', 'ecore-con') | ||
62 | CFLAGS = CFLAGS .. ' ' .. pkgConfig('cflags', 'ecore-evas') | ||
63 | CFLAGS = CFLAGS .. ' ' .. pkgConfig('cflags', 'ecore-file') | ||
64 | CFLAGS = CFLAGS .. ' ' .. pkgConfig('cflags', 'edje') | ||
65 | CFLAGS = CFLAGS .. ' ' .. pkgConfig('cflags', 'elementary') | ||
66 | CFLAGS = CFLAGS .. ' -DPACKAGE_BIN_DIR=\\"' .. LOCALDIR .. '\\"' | ||
67 | CFLAGS = CFLAGS .. ' -DPACKAGE_LIB_DIR=\\"' .. LOCALDIR .. '\\"' | ||
68 | CFLAGS = CFLAGS .. ' -DPACKAGE_DATA_DIR=\\"' .. LOCALDIR .. '\\"' | ||
69 | CFLAGS = CFLAGS .. ' ' .. CFLAGOPTS | ||
70 | |||
71 | LDFLAGS = '-L ' .. LOCALDIR .. ' ' .. pkgConfig('libs-only-L', 'luajit') .. ' -L lib -L /usr/lib -L /lib' | ||
72 | libs = pkgConfig('libs', 'elementary') .. ' ' .. pkgConfig('libs', 'luajit') .. ' -lpthread -lm' | ||
73 | LFLAGS = '-d' | ||
74 | EDJE_FLAGS = '-id images -fd fonts' | ||
75 | |||
76 | |||
77 | if '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') | ||
86 | end | ||