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 | |
| parent | 039cd576af844dc146b7517160648765b90b81b1 (diff) | |
move autogen tests
Diffstat (limited to 'tests/projects/other/native_module')
16 files changed, 55 insertions, 0 deletions
diff --git a/tests/projects/other/native_module/.gitignore b/tests/projects/other/native_module/cjson/.gitignore index 152105761..152105761 100644 --- a/tests/projects/other/native_module/.gitignore +++ b/tests/projects/other/native_module/cjson/.gitignore diff --git a/tests/projects/other/native_module/cjson/modules/lua/cjson/src/cjson.c b/tests/projects/other/native_module/cjson/modules/lua/cjson/src/cjson.c new file mode 100644 index 000000000..d8c2e49ef --- /dev/null +++ b/tests/projects/other/native_module/cjson/modules/lua/cjson/src/cjson.c @@ -0,0 +1,7 @@ +#include <xmi.h> + +int luaopen_cjson(lua_State* lua); + +int luaopen(cjson, lua_State* lua) { + return luaopen_cjson(lua); +} diff --git a/tests/projects/other/native_module/cjson/modules/lua/cjson/xmake.lua b/tests/projects/other/native_module/cjson/modules/lua/cjson/xmake.lua new file mode 100644 index 000000000..434746541 --- /dev/null +++ b/tests/projects/other/native_module/cjson/modules/lua/cjson/xmake.lua @@ -0,0 +1,19 @@ +add_rules("mode.debug", "mode.release") + +target("cjson") + add_rules("module.shared") + set_warnings("all") + if is_plat("windows") then + set_languages("c89") + end + add_files("src/*.c") + add_files("../../../../../../../core/src/lua-cjson/lua-cjson/*.c|fpconv.c") + -- Use internal strtod() / g_fmt() code for performance and disable multi-thread + add_defines("NDEBUG", "USE_INTERNAL_FPCONV") + add_defines("XM_CONFIG_API_HAVE_LUA_CJSON") + if is_plat("windows") then + -- Windows sprintf()/strtod() handle NaN/inf differently. Not supported. + add_defines("DISABLE_INVALID_NUMBERS") + add_defines("inline=__inline") + end + diff --git a/tests/projects/other/native_module/src/main.cpp b/tests/projects/other/native_module/cjson/src/main.cpp index 7c775d288..7c775d288 100644 --- a/tests/projects/other/native_module/src/main.cpp +++ b/tests/projects/other/native_module/cjson/src/main.cpp diff --git a/tests/projects/other/native_module/test.lua b/tests/projects/other/native_module/cjson/test.lua index b57362078..b57362078 100644 --- a/tests/projects/other/native_module/test.lua +++ b/tests/projects/other/native_module/cjson/test.lua diff --git a/tests/projects/other/native_module/cjson/xmake.lua b/tests/projects/other/native_module/cjson/xmake.lua new file mode 100644 index 000000000..8768aca3e --- /dev/null +++ b/tests/projects/other/native_module/cjson/xmake.lua @@ -0,0 +1,12 @@ +add_rules("mode.debug", "mode.release") + +add_moduledirs("modules") + +target("test") + set_kind("binary") + add_files("src/*.cpp") + on_config(function (target) + import("lua.cjson", {always_build = true}) + print(cjson.decode('{"foo": 1, "bar": [1, 2, 3]}')) + end) + diff --git a/tests/projects/other/native_module/modules/binary/bar/.gitignore b/tests/projects/other/native_module/hello/.gitignore index 152105761..152105761 100644 --- a/tests/projects/other/native_module/modules/binary/bar/.gitignore +++ b/tests/projects/other/native_module/hello/.gitignore 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/modules/binary/bar/src/add.cpp b/tests/projects/other/native_module/hello/modules/binary/bar/src/add.cpp index e19d07e12..e19d07e12 100644 --- a/tests/projects/other/native_module/modules/binary/bar/src/add.cpp +++ b/tests/projects/other/native_module/hello/modules/binary/bar/src/add.cpp diff --git a/tests/projects/other/native_module/modules/binary/bar/src/sub.cpp b/tests/projects/other/native_module/hello/modules/binary/bar/src/sub.cpp index 980289d1a..980289d1a 100644 --- a/tests/projects/other/native_module/modules/binary/bar/src/sub.cpp +++ b/tests/projects/other/native_module/hello/modules/binary/bar/src/sub.cpp diff --git a/tests/projects/other/native_module/modules/binary/bar/xmake.lua b/tests/projects/other/native_module/hello/modules/binary/bar/xmake.lua index add3c6e97..add3c6e97 100644 --- a/tests/projects/other/native_module/modules/binary/bar/xmake.lua +++ b/tests/projects/other/native_module/hello/modules/binary/bar/xmake.lua diff --git a/tests/projects/other/native_module/modules/shared/foo/src/foo.c b/tests/projects/other/native_module/hello/modules/shared/foo/src/foo.c index 0555b071f..0555b071f 100644 --- a/tests/projects/other/native_module/modules/shared/foo/src/foo.c +++ b/tests/projects/other/native_module/hello/modules/shared/foo/src/foo.c diff --git a/tests/projects/other/native_module/modules/shared/foo/xmake.lua b/tests/projects/other/native_module/hello/modules/shared/foo/xmake.lua index 035573d9f..035573d9f 100644 --- a/tests/projects/other/native_module/modules/shared/foo/xmake.lua +++ b/tests/projects/other/native_module/hello/modules/shared/foo/xmake.lua diff --git a/tests/projects/other/native_module/hello/src/main.cpp b/tests/projects/other/native_module/hello/src/main.cpp new file mode 100644 index 000000000..7c775d288 --- /dev/null +++ b/tests/projects/other/native_module/hello/src/main.cpp @@ -0,0 +1,6 @@ +#include <iostream> + +int main(int argc, char** argv) { + std::cout << "hello world!" << std::endl; + return 0; +} diff --git a/tests/projects/other/native_module/hello/test.lua b/tests/projects/other/native_module/hello/test.lua new file mode 100644 index 000000000..b57362078 --- /dev/null +++ b/tests/projects/other/native_module/hello/test.lua @@ -0,0 +1,3 @@ +function main(t) + t:build() +end diff --git a/tests/projects/other/native_module/xmake.lua b/tests/projects/other/native_module/hello/xmake.lua index 211e839d3..211e839d3 100644 --- a/tests/projects/other/native_module/xmake.lua +++ b/tests/projects/other/native_module/hello/xmake.lua |
