diff options
| author | ruki <[email protected]> | 2024-07-25 00:54:13 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2024-07-25 00:54:13 +0800 |
| commit | c7c412f6458f5aceeb02e9bfc292dc7aac0852d3 (patch) | |
| tree | 90fc1076e7dd5a2971d7033bee28825a80e59477 /tests/projects/other/native_module/hello/modules | |
| parent | 039cd576af844dc146b7517160648765b90b81b1 (diff) | |
move autogen tests
Diffstat (limited to 'tests/projects/other/native_module/hello/modules')
6 files changed, 69 insertions, 0 deletions
diff --git a/tests/projects/other/native_module/hello/modules/binary/bar/.gitignore b/tests/projects/other/native_module/hello/modules/binary/bar/.gitignore new file mode 100644 index 000000000..152105761 --- /dev/null +++ b/tests/projects/other/native_module/hello/modules/binary/bar/.gitignore @@ -0,0 +1,8 @@ +# Xmake cache +.xmake/ +build/ + +# MacOS Cache +.DS_Store + + diff --git a/tests/projects/other/native_module/hello/modules/binary/bar/src/add.cpp b/tests/projects/other/native_module/hello/modules/binary/bar/src/add.cpp new file mode 100644 index 000000000..e19d07e12 --- /dev/null +++ b/tests/projects/other/native_module/hello/modules/binary/bar/src/add.cpp @@ -0,0 +1,9 @@ +#include <stdio.h> +#include <stdlib.h> + +int main(int argc, char** argv) { + int a = atoi(argv[1]); + int b = atoi(argv[2]); + printf("%d", a + b); + return 0; +} diff --git a/tests/projects/other/native_module/hello/modules/binary/bar/src/sub.cpp b/tests/projects/other/native_module/hello/modules/binary/bar/src/sub.cpp new file mode 100644 index 000000000..980289d1a --- /dev/null +++ b/tests/projects/other/native_module/hello/modules/binary/bar/src/sub.cpp @@ -0,0 +1,10 @@ +#include <stdio.h> +#include <stdlib.h> + +int main(int argc, char** argv) { + int a = atoi(argv[1]); + int b = atoi(argv[2]); + printf("%d", a - b); + return 0; +} + diff --git a/tests/projects/other/native_module/hello/modules/binary/bar/xmake.lua b/tests/projects/other/native_module/hello/modules/binary/bar/xmake.lua new file mode 100644 index 000000000..add3c6e97 --- /dev/null +++ b/tests/projects/other/native_module/hello/modules/binary/bar/xmake.lua @@ -0,0 +1,10 @@ +add_rules("mode.debug", "mode.release") + +target("add") + add_rules("module.binary") + add_files("src/add.cpp") + +target("sub") + add_rules("module.binary") + add_files("src/sub.cpp") + diff --git a/tests/projects/other/native_module/hello/modules/shared/foo/src/foo.c b/tests/projects/other/native_module/hello/modules/shared/foo/src/foo.c new file mode 100644 index 000000000..0555b071f --- /dev/null +++ b/tests/projects/other/native_module/hello/modules/shared/foo/src/foo.c @@ -0,0 +1,26 @@ +#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/tests/projects/other/native_module/hello/modules/shared/foo/xmake.lua b/tests/projects/other/native_module/hello/modules/shared/foo/xmake.lua new file mode 100644 index 000000000..035573d9f --- /dev/null +++ b/tests/projects/other/native_module/hello/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.c") + |
