summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorruki <[email protected]>2020-04-22 22:43:03 +0800
committerruki <[email protected]>2020-04-22 10:18:18 +0800
commit762a7bc9386a0acaede7d54453611999a589c776 (patch)
tree23973800aa279410ee545ee3e36513dbce502fe1
parenteb53ce52d978925f285991556d2354ceb4cfd654 (diff)
improve to run xmake/cli
-rw-r--r--tests/projects/xmake_cli/hello/src/lni/main.c9
-rw-r--r--tests/projects/xmake_cli/hello/src/lua/main.lua5
-rw-r--r--xmake/rules/xmake_cli/xmake.lua1
3 files changed, 14 insertions, 1 deletions
diff --git a/tests/projects/xmake_cli/hello/src/lni/main.c b/tests/projects/xmake_cli/hello/src/lni/main.c
index 6e75791ed..3e27cf554 100644
--- a/tests/projects/xmake_cli/hello/src/lni/main.c
+++ b/tests/projects/xmake_cli/hello/src/lni/main.c
@@ -8,7 +8,14 @@ tb_int_t main(tb_int_t argc, tb_char_t** argv)
xm_engine_ref_t engine = xm_engine_init();
if (engine)
{
- ok = xm_engine_main(engine, argc, argv);
+ 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;
+ ok = xm_engine_main(engine, argc2, argv2);
xm_engine_exit(engine);
}
xm_exit();
diff --git a/tests/projects/xmake_cli/hello/src/lua/main.lua b/tests/projects/xmake_cli/hello/src/lua/main.lua
index f83baddf8..1ce83e728 100644
--- a/tests/projects/xmake_cli/hello/src/lua/main.lua
+++ b/tests/projects/xmake_cli/hello/src/lua/main.lua
@@ -1,3 +1,8 @@
+import("core.base.option")
function main ()
print("hello xmake!")
+ local argv = option.get("arguments")
+ if argv then
+ print(argv)
+ end
end
diff --git a/xmake/rules/xmake_cli/xmake.lua b/xmake/rules/xmake_cli/xmake.lua
index 415b59015..a8d891ab1 100644
--- a/xmake/rules/xmake_cli/xmake.lua
+++ b/xmake/rules/xmake_cli/xmake.lua
@@ -29,4 +29,5 @@ rule("xmake.cli")
local programdir = path.join(path.directory(libxmake:get("linkdirs")), "share", "xmake")
assert(os.isdir(programdir), "%s not found!", programdir)
os.setenv("XMAKE_PROGRAM_DIR", programdir)
+ os.setenv("XMAKE_MODULES_DIR", path.join(target:scriptdir(), "src"))
end)