summaryrefslogtreecommitdiff
path: root/xmake/templates/c++/module/shared/modules
diff options
context:
space:
mode:
authorruki <[email protected]>2026-03-02 23:52:25 +0800
committerruki <[email protected]>2026-03-02 23:52:25 +0800
commitb01dcb775c98cc48abe65a91ef9bf093be875682 (patch)
treeaef3e65981edc5506f9d20197be0892ce2957ba1 /xmake/templates/c++/module/shared/modules
parent3c1e3d746b7cc0a1a5dec9448a72a13bfe30f246 (diff)
improve template dirs
Diffstat (limited to 'xmake/templates/c++/module/shared/modules')
-rw-r--r--xmake/templates/c++/module/shared/modules/shared/foo/src/foo.cpp22
-rw-r--r--xmake/templates/c++/module/shared/modules/shared/foo/xmake.lua6
2 files changed, 28 insertions, 0 deletions
diff --git a/xmake/templates/c++/module/shared/modules/shared/foo/src/foo.cpp b/xmake/templates/c++/module/shared/modules/shared/foo/src/foo.cpp
new file mode 100644
index 000000000..adde214ca
--- /dev/null
+++ b/xmake/templates/c++/module/shared/modules/shared/foo/src/foo.cpp
@@ -0,0 +1,22 @@
+#include <xmi.h>
+
+static int add(lua_State *lua) {
+ int a = lua_tointeger(lua, 1);
+ int b = lua_tointeger(lua, 2);
+ lua_pushinteger(lua, a + b);
+ return 1;
+}
+
+static int sub(lua_State *lua) {
+ int a = lua_tointeger(lua, 1);
+ int b = lua_tointeger(lua, 2);
+ lua_pushinteger(lua, a - b);
+ return 1;
+}
+
+int luaopen(foo, lua_State *lua) {
+ static const luaL_Reg funcs[] = { { "add", add }, { "sub", sub }, { NULL, NULL } };
+ lua_newtable(lua);
+ luaL_setfuncs(lua, funcs, 0);
+ return 1;
+}
diff --git a/xmake/templates/c++/module/shared/modules/shared/foo/xmake.lua b/xmake/templates/c++/module/shared/modules/shared/foo/xmake.lua
new file mode 100644
index 000000000..9b3423d41
--- /dev/null
+++ b/xmake/templates/c++/module/shared/modules/shared/foo/xmake.lua
@@ -0,0 +1,6 @@
+add_rules("mode.debug", "mode.release")
+
+target("foo")
+ add_rules("module.shared")
+ add_files("src/foo.cpp")
+