Engine 0.0.6
Game engine in lua
Loading...
Searching...
No Matches
build.lua
Go to the documentation of this file.
1local os = require('os')
2local zeebo_bundler = require('src/lib/cli/bundler')
3local zeebo_builder = require('src/lib/cli/builder')
4local zeebo_meta = require('src/lib/cli/meta')
5local zeebo_fs = require('src/lib/cli/fs')
6
7local function build(args)
8 local bundler = ''
9 local screen = args.screen
10 local dist = args.dist
11
12 local core_list = {
13 repl={
14 src='src/engine/core/repl/main.lua',
15 post_exe='lua dist/main.lua'
16 },
17 love={
18 src='src/engine/core/love/main.lua',
19 post_exe='love dist -'..'-screen '..screen
20 },
21 ginga={
22 src='src/engine/core/ginga/main.lua',
23 post_exe='ginga dist/main.ncl -s '..screen,
24 extras={
25 'src/engine/core/ginga/main.ncl'
26 }
27 },
28 native={
29 src='src/engine/core/native/main.lua',
30 },
31 html5_webos={
32 src='src/engine/core/native/main.lua',
33 post_exe='webos24 $(pwd)/dist',
34 pipeline={
35 zeebo_meta.late(dist..'game.lua'):file(dist..'index.html'):file(dist..'appinfo.json'):pipe()
36 },
37 extras={
38 'src/engine/meta/html5_webos/appinfo.json',
39 'src/engine/core/html5/index.html',
40 'src/engine/core/html5/index.html',
41 'src/engine/core/html5/engine.js',
42 'assets/icon80x80.png'
43 }
44 },
45 html5_tizen={
46 src='src/engine/core/native/main.lua',
47 pipeline={
48 zeebo_meta.late(dist..'game.lua'):file(dist..'index.html'):file(dist..'config.xml'):pipe(),
49 function() os.execute('cd '..dist..';~/tizen-studio/tools/ide/bin/tizen.sh package -t wgt;true') end
50 },
51 extras={
52 'src/engine/meta/html5_tizen/config.xml',
53 'src/engine/meta/html5_tizen/.tproject',
54 'src/engine/core/html5/index.html',
55 'src/engine/core/html5/index.html',
56 'src/engine/core/html5/engine.js',
57 'assets/icon80x80.png'
58 }
59 },
60 html5_ginga={
61 src='src/engine/core/native/main.lua',
62 post_exe='ginga dist/main.ncl -s '..screen,
63 pipeline={
64 zeebo_meta.late(dist..'game.lua'):file(dist..'index.html'):pipe()
65 },
66 extras={
67 'src/engine/meta/html5_ginga/main.ncl',
68 'src/engine/core/html5/index.html',
69 'src/engine/core/html5/index.html',
70 'src/engine/core/html5/engine.js',
71 }
72 },
73 html5={
74 src='src/engine/core/native/main.lua',
75 pipeline={
76 zeebo_meta.late(dist..'game.lua'):file(dist..'index.html'):pipe()
77 },
78 extras={
79 'src/engine/core/html5/index.html',
80 'src/engine/core/html5/engine.js'
81 }
82 },
83 nintendo_wii={
84 src='src/engine/core/nintendo_wii/main.lua',
85 pipeline={
86 zeebo_meta.late(dist..'game.lua'):file(dist..'meta.xml'):pipe()
87 },
88 extras={
89 'assets/icon128x48.png',
90 'src/engine/meta/nintendo_wii/meta.xml'
91 }
92 }
93 }
94
95 -- clean dist
96 zeebo_fs.clear(args.dist)
97
98 -- check core
99 if not core_list[args.core] then
100 return false, 'this core cannot be build!'
101 end
102
103 -- force html5 to bundler
104 if args.core:find('html5') then
105 args.bundler = true
106 end
107
108 -- pre bundler
109 if args.bundler then
110 bundler = '_bundler/'
111 zeebo_fs.clear(dist..bundler)
112 end
113
114 -- move game
115 if args.game then
116 zeebo_fs.move(args.game, dist..'game.lua')
117 end
118
119 -- core move
120 local index = 1
121 local core = core_list[args.core]
122 zeebo_builder.build(core.src, dist..bundler)
123 if core.extras then
124 while index <= #core.extras do
125 local file = core.extras[index]
126 zeebo_fs.move(file, dist..file:gsub('.*/', ''))
127 index = index + 1
128 end
129 end
130
131 -- combine files
132 if #bundler > 0 then
133 zeebo_bundler.build(dist..bundler, 'main.lua', dist..'main.lua')
134 zeebo_fs.clear(dist..bundler)
135 os.remove(dist..bundler)
136 end
137
138 -- post process
139 if core.pipeline then
140 local index = 1
141 while index <= #core.pipeline do
142 local eval = core.pipeline[index]
143 while type(eval) == 'function' do
144 eval = eval()
145 end
146 index = index + 1
147 end
148 end
149
150 if args.run then
151 if not core.post_exe then
152 return false, 'this core cannot be runned after build!'
153 end
154 return os.execute(core.post_exe)
155 end
156
157 return true
158end
159
160return {
161 build = build
162}
local function bundler(args)
local function meta()
build
Definition build.lua:20
local zeebo_meta
Definition build.lua:4
local zeebo_builder
Definition build.lua:3
local zeebo_bundler
Definition build.lua:2
local zeebo_fs
Definition build.lua:5
local os
Definition build.lua:1
local function pipe(self)
local function file(self, file)
local function move(src_in, dist_path, dist_file)
local function require(std, game, application)
local game
Definition main.lua:17