diff options
| author | ruki <[email protected]> | 2020-04-23 23:51:19 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2020-04-23 17:07:56 +0800 |
| commit | 277b66dba40e865570ff73be0376ce3e05909c73 (patch) | |
| tree | f0331ae5d83c6ad9d57a2135c792dde8ce76516e | |
| parent | 4cbd8253bbbd38863b5f746e98fee4ec109d79e4 (diff) | |
add xmake.cli c++ template
4 files changed, 46 insertions, 0 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 new file mode 100644 index 000000000..e385c8971 --- /dev/null +++ b/xmake/templates/c++/xmake.cli/project/src/lni/main.cpp @@ -0,0 +1,25 @@ +#include <xmake/xmake.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[] = + { + {"hello", lni_test_hello} + , {tb_null, tb_null} + }; + xm_engine_register(engine, "test", lni_test_funcs); +} +tb_int_t main(tb_int_t argc, tb_char_t** argv) +{ +#ifdef __tb_debug__ + tb_char_t const* luaopts = "-vD"; +#else + tb_char_t const* luaopts = "-D"; +#endif + return xm_engine_run_lua("${TARGETNAME}", argc, argv, lni_initalizer, luaopts); +} diff --git a/xmake/templates/c++/xmake.cli/project/src/lua/main.lua b/xmake/templates/c++/xmake.cli/project/src/lua/main.lua new file mode 100644 index 000000000..d87daf102 --- /dev/null +++ b/xmake/templates/c++/xmake.cli/project/src/lua/main.lua @@ -0,0 +1,10 @@ +import("core.base.option") +import("lib.lni.test") + +function main () + print(test.hello()) + local argv = option.get("arguments") + if argv then + print(argv) + end +end diff --git a/xmake/templates/c++/xmake.cli/project/xmake.lua b/xmake/templates/c++/xmake.cli/project/xmake.lua new file mode 100644 index 000000000..b2a20a592 --- /dev/null +++ b/xmake/templates/c++/xmake.cli/project/xmake.lua @@ -0,0 +1,8 @@ +add_rules("mode.debug", "mode.release") +add_requires("libxmake", {debug = is_mode("debug")}) +target("${TARGETNAME}") + add_rules("xmake.cli") + add_files("src/lni/*.c") + add_packages("libxmake") + +${FAQ}
\ No newline at end of file diff --git a/xmake/templates/c++/xmake.cli/template.lua b/xmake/templates/c++/xmake.cli/template.lua new file mode 100644 index 000000000..b6fe720c2 --- /dev/null +++ b/xmake/templates/c++/xmake.cli/template.lua @@ -0,0 +1,3 @@ +template("xmake.cli") + add_configfiles("src/lni/main.c") + add_configfiles("xmake.lua") |
