summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorruki <[email protected]>2020-04-22 22:37:38 +0800
committerruki <[email protected]>2020-04-22 09:45:50 +0800
commit56d0939297f81d8a6790e4b638ff516e4a6c3e08 (patch)
tree33d2901ba9cfe03ad19aae394c511d3d8b6bbb48
parent15dc39430ed49d42709bba3ef2acab8500414a3a (diff)
add xmake_cli/hello test
-rw-r--r--tests/projects/xmake_cli/hello/src/lni/main.c17
-rw-r--r--tests/projects/xmake_cli/hello/src/lua/main.lua3
-rw-r--r--tests/projects/xmake_cli/hello/xmake.lua7
-rw-r--r--xmake/rules/xmake_cli/xmake.lua7
4 files changed, 34 insertions, 0 deletions
diff --git a/tests/projects/xmake_cli/hello/src/lni/main.c b/tests/projects/xmake_cli/hello/src/lni/main.c
new file mode 100644
index 000000000..6e75791ed
--- /dev/null
+++ b/tests/projects/xmake_cli/hello/src/lni/main.c
@@ -0,0 +1,17 @@
+#include <xmake/xmake.h>
+
+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();
+ if (engine)
+ {
+ ok = xm_engine_main(engine, argc, argv);
+ xm_engine_exit(engine);
+ }
+ xm_exit();
+ }
+ return ok;
+}
diff --git a/tests/projects/xmake_cli/hello/src/lua/main.lua b/tests/projects/xmake_cli/hello/src/lua/main.lua
new file mode 100644
index 000000000..f83baddf8
--- /dev/null
+++ b/tests/projects/xmake_cli/hello/src/lua/main.lua
@@ -0,0 +1,3 @@
+function main ()
+ print("hello xmake!")
+end
diff --git a/tests/projects/xmake_cli/hello/xmake.lua b/tests/projects/xmake_cli/hello/xmake.lua
new file mode 100644
index 000000000..e2e410e03
--- /dev/null
+++ b/tests/projects/xmake_cli/hello/xmake.lua
@@ -0,0 +1,7 @@
+add_rules("mode.debug", "mode.release")
+add_requires("libxmake")
+target("hello")
+ add_rules("xmake.cli")
+ add_files("src/lni/*.c")
+ add_packages("libxmake")
+
diff --git a/xmake/rules/xmake_cli/xmake.lua b/xmake/rules/xmake_cli/xmake.lua
index 25acf0568..415b59015 100644
--- a/xmake/rules/xmake_cli/xmake.lua
+++ b/xmake/rules/xmake_cli/xmake.lua
@@ -22,4 +22,11 @@
rule("xmake.cli")
before_load(function (target)
target:set("kind", "binary")
+ assert(target:pkg("libxmake"), 'please add_packages("libxmake") to target(%s) first!', target:name())
+ end)
+ before_run(function (target)
+ local libxmake = target:pkg("libxmake")
+ 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)
end)