Skip to content

Commit

Permalink
feat: revision 0.0.11 (#115)
Browse files Browse the repository at this point in the history
* feat: add core none
* feat: add core lite
* feat: add core html5_lite
* fix: pause in core-native-html5
* ci: add linter to `cli`
* ci: add linter to `lite`
* ci: add linter to `repl`
* style: refact build
* fix: support cli in windows
* docs: add topic languages
  • Loading branch information
RodrigoDornelles authored Nov 5, 2024
1 parent 4ade7de commit c9902a6
Show file tree
Hide file tree
Showing 36 changed files with 735 additions and 207 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ jobs:
bash <(curl -s https://codecov.io/bash) -t ${{ secrets.CODECOV_TOKEN }}
version:
if: github.event_name == 'push'
if: github.event_name == 'push' || github.event.pull_request.draft == false
name: test version
runs-on: ubuntu-latest
steps:
Expand All @@ -60,7 +60,7 @@ jobs:
strategy:
fail-fast: false
matrix:
core: ['native', 'love']
core: ['cli', 'repl', 'lite', 'native', 'love']
steps:
-
uses: actions/checkout@master
Expand Down
8 changes: 7 additions & 1 deletion .luaurc
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@
"arg",
"bit",
"Buffer",
"BOOTSTRAP",
"BOOTSTRAP_DIRS",
"BOOTSTRAP_LIST",
"canvas",
"event",
"io",
Expand All @@ -14,6 +17,8 @@
"load",
"loadfile",
"love",
"mock_separator",
"native_dict_secret",
"native_dict_game",
"native_dict_http",
"native_dict_json",
Expand All @@ -29,6 +34,7 @@
"native_draw_start",
"native_draw_text_tui",
"native_draw_text",
"native_get_system_lang"
"native_get_system_lang",
"package"
]
}
2 changes: 1 addition & 1 deletion Doxyfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Custom Configs
DOXYFILE_ENCODING = UTF-8
PROJECT_NAME = "Gly Game Engine"
PROJECT_NUMBER = 0.0.10
PROJECT_NUMBER = 0.0.11
PROJECT_BRIEF = "Game engine in lua"
PROJECT_LOGO = assets/icon80x80.png
GENERATE_RTF = NO
Expand Down
59 changes: 59 additions & 0 deletions docs/lang_esc_g.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
@defgroup Languages
@{

@defgroup lang_esc_g ESC G
@{

@par Backus–Naur Form
@startebnf
protocol_esc_g = esc, "G", command (* 7 bits *), size (* MSB command\ndefines x1024 *), [ buffer ], checksum (* DJB2 *);
esc = "\x1b";
command = byte;
size = byte;
buffer = 4 * byte | 1024 * byte;
checksum = 4 * byte;
@endebnf

@par Commands

| | command name | parameters | sizes in bytes|
| :-: | :------------- | :-------------- | :------------ |
| 0 | hello | | 0 |
| 1 | hdmi cec | command | 4..20 |
| 2 | press menu key | | 0 |
| 3 | gamepad update | z,x,c,v,w,a,s,d | 8 |
| 44 | set img index | index,type,w,h | 4 or 8 |
| 45 | update image | image | 0..254000 |
| 46 | set text index | index | 4 |
| 47 | update text | text | 0..254000 |
| 48 | draw mode | m1, m2, s1, s2 | 4 |
| 49 | draw color | r, g, b, a | 4 |
| 50 | draw rect | x, y, w, h | 4, 8 or 16 |
| 51 | draw line | x1, y1, x2, y2 | 4, 8 or 16 |
| 52 | draw text | x, y, id, size | 4 |
| 52 | draw image | x, y, id | 4 |
| 64..127 | custom | | 0..254000 |

@par Modes

@li @b 0 tint fill
@li @b 1 tint frame
@li @b 2 tint open
@li @b 4 tint save
@li @b 5 erase fill
@li @b 6 erase frame
@li @b 7 erase open

@par Image Types

@li @b 0 RGB 15bits
@li @b 1 RGBA 32bits
@li @b 2 BMP
@li @b 3 PNG

@par Examples

@li @c std.draw.clear(0xAABBCCDD) @n ESC G 0x48 0x00000003 0x00000000 @n ESC G 0x49 0x01 0xAABBCCDD 0x00000000 @n ESC G 0x50 0x01 0x0000FFFFF 0x00000000

@}
@}
2 changes: 1 addition & 1 deletion ee/engine/core/ginga/main.lua
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
local zeebo_module = require('src/lib/engine/raw/module')
local zeebo_module = require('src/lib/common/module')
--
local core_draw = require('ee/engine/core/ginga/draw')
local core_keys = require('ee/engine/core/ginga/keys')
Expand Down
67 changes: 47 additions & 20 deletions src/cli/commands/build.lua
Original file line number Diff line number Diff line change
Expand Up @@ -3,33 +3,40 @@ local zeebo_bundler = require('src/lib/cli/bundler')
local zeebo_builder = require('src/lib/cli/builder')
local zeebo_meta = require('src/lib/cli/meta')
local zeebo_fs = require('src/lib/cli/fs')
local util_fs = require('src/lib/util/fs')

local function build(args)
local bundler = ''
local screen = args.screen
local dist = args.dist
local dist = util_fs.path(args.dist).get_unix_path()

local core_list = {
none = {

},
repl={
src='src/engine/core/repl/main.lua',
src='src/engine/core/repl',
post_exe='lua dist/main.lua'
},
love={
src='src/engine/core/love/main.lua',
src='src/engine/core/love',
post_exe='love dist -'..'-screen '..screen
},
ginga={
src='ee/engine/core/ginga/main.lua',
src='ee/engine/core/ginga',
post_exe='ginga dist/main.ncl -s '..screen,
extras={
'ee/engine/meta/ginga/main.ncl'
}
},
lite={
src='src/engine/core/lite',
},
native={
src='src/engine/core/native/main.lua',
src='src/engine/core/native',
},
html5_webos={
src='src/engine/core/native/main.lua',
src='src/engine/core/native',
post_exe='webos24 $(pwd)/dist',
pipeline={
zeebo_meta.late(dist..'game.lua'):file(dist..'index.html'):file(dist..'appinfo.json'):pipe()
Expand All @@ -44,7 +51,7 @@ local function build(args)
}
},
html5_tizen={
src='src/engine/core/native/main.lua',
src='src/engine/core/native',
pipeline={
zeebo_meta.late(dist..'game.lua'):file(dist..'index.html'):file(dist..'config.xml'):pipe(),
function() os.execute('cd '..dist..';~/tizen-studio/tools/ide/bin/tizen.sh package -t wgt;true') end
Expand All @@ -59,8 +66,19 @@ local function build(args)
'assets/icon80x80.png'
}
},
html5_lite={
src='src/engine/core/lite',
pipeline={
zeebo_meta.late(dist..'game.lua'):file(dist..'index.html'):pipe()
},
extras={
'src/engine/core/html5/index.html',
'src/engine/core/html5/driver-wasmoon.js',
'src/engine/core/html5/core-native-html5.js'
}
},
html5={
src='src/engine/core/native/main.lua',
src='src/engine/core/native',
pipeline={
zeebo_meta.late(dist..'game.lua'):file(dist..'index.html'):pipe()
},
Expand All @@ -73,7 +91,7 @@ local function build(args)
}

-- clean dist
zeebo_fs.clear(args.dist)
zeebo_fs.clear(dist)

-- check core
if not core_list[args.core] then
Expand All @@ -93,27 +111,36 @@ local function build(args)

-- move game
if args.game then
local dir, file = args.game:match("(.*/)([^/]+)$")
zeebo_bundler.build(dir, file, dist..'game.lua')
local game = util_fs.file(args.game)
zeebo_builder.build(game.get_unix_path(), game.get_file(), dist..bundler, 'game.lua', 'game_')
end

-- core move
local index = 1
local core = core_list[args.core]
zeebo_builder.build(core.src, dist..bundler)
if core.extras then
while index <= #core.extras do
local file = core.extras[index]
zeebo_fs.move(file, dist..file:gsub('.*/', ''))
index = index + 1
do
local index = 1
if core.src then
zeebo_builder.build(core.src, 'main.lua', dist..bundler, 'main.lua', 'core_')
end
if core.extras then
while index <= #core.extras do
local file = core.extras[index]
zeebo_fs.move(file, dist..file:gsub('.*/', ''))
index = index + 1
end
end
end

-- combine files
if #bundler > 0 then
zeebo_bundler.build(dist..bundler, 'main.lua', dist..'main.lua')
if core.src then
zeebo_bundler.build(dist..bundler, 'main.lua', dist..'main.lua')
end
if args.game then
zeebo_bundler.build(dist..bundler, 'game.lua', dist..'game.lua')
end
zeebo_fs.clear(dist..bundler)
os.remove(dist..bundler)
zeebo_fs.rmdir(dist..bundler)
end

-- post process
Expand Down
12 changes: 3 additions & 9 deletions src/cli/commands/cli.lua
Original file line number Diff line number Diff line change
Expand Up @@ -29,20 +29,14 @@ local function cli_build(args)
return ok, message
end

local function cli_dump(args)
return zeebo_bootstrap.dump(dist)
end

local function cli_init(args)
local project_name = args[1] or 'my_project'
init.init_project(project_name)
local function cli_dump()
return zeebo_bootstrap.dump()
end

local P = {
['cli-build'] = cli_build,
['cli-test'] = cli_test,
['cli-dump'] = cli_dump,
['cli-init'] = cli_init
['cli-dump'] = cli_dump
}

return P
2 changes: 1 addition & 1 deletion src/cli/commands/fs.lua
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ local function vim_xxd_i(args)
end
end

local content, length, column = '', 0, 0
local length, column = 0, 0
local const = args.const and 'const ' or ''
local var_name = args.name or args.file:gsub('[%._/]', '_'):gsub("__+", "_"):gsub('^_', '')

Expand Down
7 changes: 1 addition & 6 deletions src/cli/commands/info.lua
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ local help_message = "Available commands:\n"
.."- To run a game: ./cli.sh run ./examples/asteroids/game.lua " .. "-" .. "-core repl\n"
.."- To display metadata: ./cli.sh meta ./examples/asteroids/game.lua\n"

local version_message = '0.0.10'
local version_message = '0.0.11'

local function help()
return true, help_message
Expand All @@ -53,11 +53,6 @@ local function version()
return true, version_message
end

--! @todo show all commands with complete flags
local function show(args)
return false, 'not implemented!'
end

local function meta()
local description = 'not implemented!'
return {
Expand Down
6 changes: 4 additions & 2 deletions src/cli/commands/init.lua
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
local os = require('os')
local util_cmd = require('src/lib/util/cmd')

local ok = true

local function create_file(filepath, content)
Expand All @@ -13,7 +15,7 @@ local function create_file(filepath, content)
end

local function create_directory(path)
local success = os.execute("mkdir " .. path)
local success = os.execute(util_cmd.mkdir()..path)
if not success then
print("Error while creating directory: " .. path)
ok = false
Expand All @@ -23,7 +25,7 @@ end
local function init_project(args)
local project_name = args.project
local project_template = args.template
local project_gamefile, error_gamefile = io.open(project_template, 'r')
local project_gamefile = io.open(project_template, 'r')

ok = true

Expand Down
28 changes: 18 additions & 10 deletions src/cli/commands/tools.lua
Original file line number Diff line number Diff line change
Expand Up @@ -3,25 +3,33 @@ local zeebo_bundler = require('src/lib/cli/bundler')
local zeebo_package = require('src/lib/cli/package')
local zeebo_filler = require('src/lib/cli/filler')
local zeebo_fs = require('src/lib/cli/fs')
local util_fs = require('src/lib/util/fs')
local util_cmd = require('src/lib/util/cmd')

local function bundler(args)
local path, file = args.file:match("(.-)([^/\\]+)$")
return zeebo_bundler.build(path, file, args.dist..file)
local d = util_fs.path(args.dist)
local f = util_fs.file(args.file)
zeebo_fs.clear(d.get_fullfilepath())
return zeebo_bundler.build(f.get_sys_path(), f.get_file(), d.get_sys_path()..f.get_file())
end

local function compiler(args)
return zeebo_compiler.build(args.file, args.dist)
local file = util_fs.file(args.file).get_fullfilepath()
local dist = util_fs.file(args.dist).get_fullfilepath()
return zeebo_compiler.build(file, dist)
end

local function love_zip(args)
os.execute('mkdir -p '..args.dist..'_love')
os.execute('mv '..args.path..'/* '..args.dist..'_love 2> /dev/null')
local zip_pid = io.popen('cd '..args.dist..'_love && zip -9 -r Game.love .')
local dist = util_fs.path(args.dist).get_fullfilepath()
local path = util_fs.path(args.path).get_fullfilepath()
os.execute(util_cmd.mkdir()..dist..'_love')
os.execute(util_cmd.move()..path..'* '..dist..'_love'..util_cmd.silent())
local zip_pid = io.popen('cd '..dist..'_love && zip -9 -r Game.love .')
local stdout = zip_pid:read('*a')
local ok = zip_pid:close()
zeebo_fs.move(args.dist..'_love/Game.love', args.dist..'Game.love')
zeebo_fs.clear(args.dist..'_love')
os.remove(args.dist..'_love')
local ok = zip_pid:close()
zeebo_fs.move(dist..'_love/Game.love', dist..'Game.love')
zeebo_fs.clear(dist..'_love')
os.remove(dist..'_love')
return ok, stdout
end

Expand Down
Loading

0 comments on commit c9902a6

Please sign in to comment.