diff options
| author | ruki <[email protected]> | 2025-02-07 00:51:59 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2025-02-07 00:51:59 +0800 |
| commit | 10fa86560ba4fb831d7aadf20ef9dd170c815b61 (patch) | |
| tree | 6558cd1b0f6bc2425d4190910bc871b594d576ca | |
| parent | 94262ef203d602f0ae84433b834173373633bebf (diff) | |
update template
| -rw-r--r-- | xmake/templates/c++/xmake.cli/project/src/lni/main.cpp | 21 | ||||
| -rw-r--r-- | xmake/templates/c++/xmake.cli/project/xmake.lua | 10 | ||||
| -rw-r--r-- | xmake/templates/c/xmake.cli/project/src/lni/main.c | 6 | ||||
| -rw-r--r-- | xmake/templates/c/xmake.cli/project/xmake.lua | 7 |
4 files changed, 31 insertions, 13 deletions
diff --git a/xmake/templates/c++/xmake.cli/project/src/lni/main.cpp b/xmake/templates/c++/xmake.cli/project/src/lni/main.cpp index 57f3b6715..8b9bc4524 100644 --- a/xmake/templates/c++/xmake.cli/project/src/lni/main.cpp +++ b/xmake/templates/c++/xmake.cli/project/src/lni/main.cpp @@ -1,21 +1,26 @@ #include <xmake/xmake.h> -static tb_int_t lni_test_hello(lua_State* lua) -{ +static tb_byte_t const g_luafiles_data[] = { + #include "luafiles.xmz.h" +}; + +static tb_int_t lni_test_hello(lua_State* lua) { lua_pushliteral(lua, "hello xmake!"); return 1; } -static tb_void_t lni_initalizer(xm_engine_ref_t engine, lua_State* lua) -{ - static luaL_Reg const lni_test_funcs[] = - { + +static tb_void_t lni_initalizer(xm_engine_ref_t engine, lua_State* lua) { + static luaL_Reg const lni_test_funcs[] = { {"hello", lni_test_hello} , {tb_null, tb_null} }; xm_engine_register(engine, "test", lni_test_funcs); + xm_engine_add_embedfiles(engine, g_luafiles_data, sizeof(g_luafiles_data)); } -tb_int_t main(tb_int_t argc, tb_char_t** argv) -{ + +tb_int_t main(tb_int_t argc, tb_char_t** argv) { tb_char_t* taskargv[] = {"lua", "-D", "lua.main", tb_null}; return xm_engine_run("${TARGETNAME}", argc, argv, taskargv, lni_initalizer); } + + diff --git a/xmake/templates/c++/xmake.cli/project/xmake.lua b/xmake/templates/c++/xmake.cli/project/xmake.lua index b2a20a592..5fa81aa45 100644 --- a/xmake/templates/c++/xmake.cli/project/xmake.lua +++ b/xmake/templates/c++/xmake.cli/project/xmake.lua @@ -1,8 +1,12 @@ add_rules("mode.debug", "mode.release") -add_requires("libxmake", {debug = is_mode("debug")}) + +add_requires("libxmake") + target("${TARGETNAME}") add_rules("xmake.cli") - add_files("src/lni/*.c") + add_files("src/lni/*.cpp") + add_files("src/lua/*.lua", {rootdir = "src"}) add_packages("libxmake") -${FAQ}
\ No newline at end of file +${FAQ} + diff --git a/xmake/templates/c/xmake.cli/project/src/lni/main.c b/xmake/templates/c/xmake.cli/project/src/lni/main.c index 7d16d50b9..98a4c19ce 100644 --- a/xmake/templates/c/xmake.cli/project/src/lni/main.c +++ b/xmake/templates/c/xmake.cli/project/src/lni/main.c @@ -1,5 +1,9 @@ #include <xmake/xmake.h> +static tb_byte_t const g_luafiles_data[] = { + #include "luafiles.xmz.h" +}; + static tb_int_t lni_test_hello(lua_State* lua) { lua_pushliteral(lua, "hello xmake!"); return 1; @@ -11,9 +15,11 @@ static tb_void_t lni_initalizer(xm_engine_ref_t engine, lua_State* lua) { , {tb_null, tb_null} }; xm_engine_register(engine, "test", lni_test_funcs); + xm_engine_add_embedfiles(engine, g_luafiles_data, sizeof(g_luafiles_data)); } tb_int_t main(tb_int_t argc, tb_char_t** argv) { tb_char_t* taskargv[] = {"lua", "-D", "lua.main", tb_null}; return xm_engine_run("${TARGETNAME}", argc, argv, taskargv, lni_initalizer); } + diff --git a/xmake/templates/c/xmake.cli/project/xmake.lua b/xmake/templates/c/xmake.cli/project/xmake.lua index b2a20a592..678c5ba3a 100644 --- a/xmake/templates/c/xmake.cli/project/xmake.lua +++ b/xmake/templates/c/xmake.cli/project/xmake.lua @@ -1,8 +1,11 @@ add_rules("mode.debug", "mode.release") -add_requires("libxmake", {debug = is_mode("debug")}) + +add_requires("libxmake") + target("${TARGETNAME}") add_rules("xmake.cli") add_files("src/lni/*.c") + add_files("src/lua/*.lua", {rootdir = "src"}) add_packages("libxmake") -${FAQ}
\ No newline at end of file +${FAQ} |
