summaryrefslogtreecommitdiff
path: root/tests/projects
diff options
context:
space:
mode:
authorruki <[email protected]>2020-04-22 23:44:03 +0800
committerruki <[email protected]>2020-04-22 16:24:20 +0800
commit05df31effcfc9bc701387e1383b678f0914241be (patch)
treead03fc1658358ed939e1bb479289f4a3e9515130 /tests/projects
parenta69f20d2daf4ed61b58b036eee7bf20a3034a30e (diff)
improve engine
Diffstat (limited to 'tests/projects')
-rw-r--r--tests/projects/xmake_cli/hello/src/lni/main.c32
-rw-r--r--tests/projects/xmake_cli/hello/src/lua/main.lua5
-rw-r--r--tests/projects/xmake_cli/hello/xmake.lua2
-rw-r--r--tests/projects/xmake_cli/xmake/src/main.c13
4 files changed, 8 insertions, 44 deletions
diff --git a/tests/projects/xmake_cli/hello/src/lni/main.c b/tests/projects/xmake_cli/hello/src/lni/main.c
index a2601687a..d1ab0b0fb 100644
--- a/tests/projects/xmake_cli/hello/src/lni/main.c
+++ b/tests/projects/xmake_cli/hello/src/lni/main.c
@@ -16,34 +16,10 @@ static tb_void_t lni_initalizer(xm_engine_ref_t engine, lua_State* lua)
}
tb_int_t main(tb_int_t argc, tb_char_t** argv)
{
- tb_int_t ok = -1;
- if (xm_init())
- {
- xm_engine_ref_t engine = xm_engine_init(lni_initalizer);
- if (engine)
- {
-#if 0
- tb_int_t argc2 = argc + 2;
- tb_char_t* argv2[argc2 + 1];
- argv2[0] = argv[0];
- argv2[1] = "lua";
- argv2[2] = "lua.main";
- if (argc > 1) tb_memcpy(argv2 + 3, argv + 1, (argc - 1) * sizeof(tb_char_t*));
- argv2[argc2] = tb_null;
+#ifdef __tb_debug__
+ tb_char_t const* luaopts = "-vD";
#else
- tb_int_t argc2 = argc + 3;
- tb_char_t* argv2[argc2 + 1];
- argv2[0] = argv[0];
- argv2[1] = "lua";
- argv2[2] = "-vD";
- argv2[3] = "lua.main";
- if (argc > 1) tb_memcpy(argv2 + 4, argv + 1, (argc - 1) * sizeof(tb_char_t*));
- argv2[argc2] = tb_null;
+ tb_char_t const* luaopts = "-D";
#endif
- ok = xm_engine_main(engine, argc2, argv2);
- xm_engine_exit(engine);
- }
- xm_exit();
- }
- return ok;
+ return xm_engine_run_lua(argc, argv, lni_initalizer, luaopts);
}
diff --git a/tests/projects/xmake_cli/hello/src/lua/main.lua b/tests/projects/xmake_cli/hello/src/lua/main.lua
index 0a1590543..d87daf102 100644
--- a/tests/projects/xmake_cli/hello/src/lua/main.lua
+++ b/tests/projects/xmake_cli/hello/src/lua/main.lua
@@ -1,9 +1,8 @@
import("core.base.option")
-import("lib.lni")
+import("lib.lni.test")
function main ()
- print(lni)
- print("hello xmake!")
+ print(test.hello())
local argv = option.get("arguments")
if argv then
print(argv)
diff --git a/tests/projects/xmake_cli/hello/xmake.lua b/tests/projects/xmake_cli/hello/xmake.lua
index e2e410e03..e4c0aba32 100644
--- a/tests/projects/xmake_cli/hello/xmake.lua
+++ b/tests/projects/xmake_cli/hello/xmake.lua
@@ -1,5 +1,5 @@
add_rules("mode.debug", "mode.release")
-add_requires("libxmake")
+add_requires("libxmake", {debug = is_mode("debug")})
target("hello")
add_rules("xmake.cli")
add_files("src/lni/*.c")
diff --git a/tests/projects/xmake_cli/xmake/src/main.c b/tests/projects/xmake_cli/xmake/src/main.c
index b84c5b500..68403c6c4 100644
--- a/tests/projects/xmake_cli/xmake/src/main.c
+++ b/tests/projects/xmake_cli/xmake/src/main.c
@@ -2,16 +2,5 @@
tb_int_t main(tb_int_t argc, tb_char_t** argv)
{
- tb_int_t ok = -1;
- if (xm_init())
- {
- xm_engine_ref_t engine = xm_engine_init(tb_null);
- if (engine)
- {
- ok = xm_engine_main(engine, argc, argv);
- xm_engine_exit(engine);
- }
- xm_exit();
- }
- return ok;
+ return xm_engine_run(argc, argv, tb_null);
}