summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorruki <[email protected]>2020-04-23 22:49:32 +0800
committerruki <[email protected]>2020-04-23 10:57:14 +0800
commit639f71ed0bf1ba2e2abf0cb91e784793a540c019 (patch)
tree9b10fac75bbedad1d4ca6276540dd569d9a1e1da
parentc6c35ff6929f6e49d300b0b586588347a5a97e2c (diff)
add xmake.cli template
-rw-r--r--xmake/templates/c/xmake.cli/project/src/lni/main.c25
-rw-r--r--xmake/templates/c/xmake.cli/project/src/lua/main.lua10
-rw-r--r--xmake/templates/c/xmake.cli/project/xmake.lua8
-rw-r--r--xmake/templates/c/xmake.cli/template.lua3
4 files changed, 46 insertions, 0 deletions
diff --git a/xmake/templates/c/xmake.cli/project/src/lni/main.c b/xmake/templates/c/xmake.cli/project/src/lni/main.c
new file mode 100644
index 000000000..e385c8971
--- /dev/null
+++ b/xmake/templates/c/xmake.cli/project/src/lni/main.c
@@ -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")