10local coverage =
zeebo_args.has(arg, 'coverage')
11local core =
zeebo_args.get(arg, 'core', 'ginga')
12local dist =
zeebo_args.get(arg, 'dist', './dist/')
13local screen =
zeebo_args.get(arg, 'screen', '1280x720')
14local command =
zeebo_args.
param(arg, {
'core',
'screen',
'dist'}, 1,
'help')
15local
game =
zeebo_args.param(arg, {
'core',
'screen',
'dist'}, 2,
'')
19 src=
'src/engine/core/repl/main.lua',
20 exe=
'lua src/engine/core/repl/main.lua '..
game,
21 post_exe=
'lua dist/main.lua'
24 src=
'src/engine/core/love/main.lua',
25 exe=
'love src/engine/core/love --screen '..screen..
' '..
game,
26 post_exe=
'love dist --screen '..screen
29 src=
'src/engine/core/ginga/main.lua',
30 post_exe=
'ginga dist/main.ncl -s '..screen,
32 'src/engine/core/ginga/main.ncl'
36 src=
'src/engine/core/native/main.lua',
39 src=
'src/engine/core/native/main.lua',
40 post_exe=
'webos24 $(pwd)/dist',
45 'src/engine/meta/html5_webos/appinfo.json',
46 'src/engine/core/html5/index.html',
47 'src/engine/core/html5/index.html',
48 'src/engine/core/html5/engine.js',
49 'assets/icon80x80.png'
53 src=
'src/engine/core/native/main.lua',
56 function()
os.execute(
'cd '..dist..
';~/tizen-studio/tools/ide/bin/tizen.sh package -t wgt;true') end
59 'src/engine/meta/html5_tizen/config.xml',
60 'src/engine/meta/html5_tizen/.tproject',
61 'src/engine/core/html5/index.html',
62 'src/engine/core/html5/index.html',
63 'src/engine/core/html5/engine.js',
64 'assets/icon80x80.png'
68 src=
'src/engine/core/native/main.lua',
69 post_exe=
'ginga dist/main.ncl -s '..screen,
74 'src/engine/meta/html5_ginga/main.ncl',
75 'src/engine/core/html5/index.html',
76 'src/engine/core/html5/index.html',
77 'src/engine/core/html5/engine.js',
81 src=
'src/engine/core/native/main.lua',
86 'src/engine/core/html5/index.html',
87 'src/engine/core/html5/engine.js'
91 src=
'src/engine/core/nintendo_wii/main.lua',
96 'assets/icon128x48.png',
97 'src/engine/meta/nintendo_wii/meta.xml'
102if command ==
'run' then
106 if not core_list[core] or not core_list[core].exe then
107 print(
'this core cannot be runned!')
110 os.exit(
os.execute(core_list[core].exe) and 0 or 1)
111elseif command ==
'clear' or command ==
'clean' then
113elseif command ==
'meta' then
114 if core ==
'ginga' then
115 core =
'{{title}} {{version}}'
118elseif command ==
'bundler' then
119 local path,
file =
game:match(
"(.-)([^/\\]+)$")
121elseif command ==
'test-self' then
122 coverage = coverage and
'-lluacov' or
''
123 local files =
zeebo_fs.ls(
'./tests')
126 while index <= #files
do
127 ok = ok and
os.execute(
'lua '..coverage..
' ./tests/'..files[index])
130 if #coverage > 0 then
131 os.execute(
'luacov src')
132 os.execute(
'tail -n '..tostring(#files + 5)..
' luacov.report.out')
137elseif command ==
'build' then
142 if not core_list[core] then
143 print(
'this core cannot be build!')
147 -- force html5 to bundler
148 if core:find(
'html5') then
154 bundler =
'_bundler/'
167 local core = core_list[core]
168 zeebo_fs.build(core.src, dist..bundler)
170 while index <= #core.extras
do
171 local
file = core.extras[index]
179 zeebo_bundler.build(dist..bundler,
'main.lua', dist..
'main.lua')
184 if core.pipeline then
186 while index <= #core.pipeline
do
187 local eval = core.pipeline[index]
188 while type(eval) ==
'function' do
196 if not core.post_exe then
197 print(
'this core cannot be runned after build!')
200 os.exit(
os.execute(core.post_exe) and 0 or 1)
202elseif command ==
"help" then
203 local help_message =
"Available commands:\n" ..
204 "- run: Executes the specified core. If no core is specified, defaults to 'love'.\n" ..
205 "- clear | clean: Clears the specified distribution directory.\n" ..
206 "- meta: Displays metadata for the current game.\n" ..
207 "- bundler: Builds the game using the bundler.\n" ..
208 "- test-self: Runs tests located in the './tests' directory.\n" ..
209 "- build: Builds the game and prepares it for distribution.\n" ..
211 "Available cores:\n" ..
212 "- repl: Runs the REPL core.\n" ..
213 "- love: Runs the Love2D core.\n" ..
214 "- ginga: Runs the Ginga core.\n" ..
215 "- html5_webos: Builds for HTML5 on WebOS.\n" ..
216 "- html5_tizen: Builds for HTML5 on Tizen.\n" ..
217 "- html5_ginga: Runs the Ginga core for HTML5.\n" ..
218 "- html5: Runs the standard HTML5 core.\n" ..
219 "- nintendo_wii: Builds for the Nintendo Wii.\n" ..
222 "- To run a command, use: ./cli.sh <command> <game_path> --core <core_name> [options]\n" ..
223 "- For example: ./cli.sh build ./examples/asteroids/game.lua --core ginga"
226 print(
'command not found: '..command)
local function stdout(self, format)
local function pipe(self)
local function file(self, file)
local function move(src_in, dist_out)
local function require(std, game, application)
local function param(self, name, value)