diff options
| author | ruki <[email protected]> | 2021-09-27 22:35:24 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2021-09-27 22:35:24 +0800 |
| commit | 9128fe7d5b84a27831ae2535a16547bb0b9b7d8e (patch) | |
| tree | 299f6a0ff0c871ca149cf327ef9665bae55e6f31 /tests/projects/swig/lua_c | |
| parent | d00138d98064b84db0c76dde99587b5ea425fdf4 (diff) | |
add lua_c swig test
Diffstat (limited to 'tests/projects/swig/lua_c')
| -rw-r--r-- | tests/projects/swig/lua_c/src/example.c | 25 | ||||
| -rw-r--r-- | tests/projects/swig/lua_c/src/example.i | 6 | ||||
| -rw-r--r-- | tests/projects/swig/lua_c/xmake.lua | 8 |
3 files changed, 39 insertions, 0 deletions
diff --git a/tests/projects/swig/lua_c/src/example.c b/tests/projects/swig/lua_c/src/example.c new file mode 100644 index 000000000..c4afe9779 --- /dev/null +++ b/tests/projects/swig/lua_c/src/example.c @@ -0,0 +1,25 @@ +#include <stdio.h> +#include "lua.h" +#include "lualib.h" +#include "lauxlib.h" + +extern int luaopen_example(lua_State* L); // declare the wrapped module + +int main(int argc,char* argv[]) +{ + lua_State *L; + if (argc<2) + { + printf("%s: <filename.lua>\n",argv[0]); + return 0; + } + L=lua_open(); + luaopen_base(L); // load basic libs (eg. print) + luaopen_example(L); // load the wrappered module + if (luaL_loadfile(L,argv[1])==0) // load and run the file + lua_pcall(L,0,0,0); + else + printf("unable to load %s\n",argv[1]); + lua_close(L); + return 0; +} diff --git a/tests/projects/swig/lua_c/src/example.i b/tests/projects/swig/lua_c/src/example.i new file mode 100644 index 000000000..f17b34a82 --- /dev/null +++ b/tests/projects/swig/lua_c/src/example.i @@ -0,0 +1,6 @@ +%module example +%{ +#include "example.h" +%} +int gcd(int x, int y); +extern double Foo; diff --git a/tests/projects/swig/lua_c/xmake.lua b/tests/projects/swig/lua_c/xmake.lua new file mode 100644 index 000000000..fc6e3dd7b --- /dev/null +++ b/tests/projects/swig/lua_c/xmake.lua @@ -0,0 +1,8 @@ +add_rules("mode.release", "mode.debug") +add_requires("lua") + +target("example") + add_rules("swig.c") + add_files("src/example.i", {moduletype = "lua", scriptdir = "share"}) + add_files("src/example.c") + add_packages("lua") |
