summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorruki <[email protected]>2024-04-02 23:00:07 +0800
committerruki <[email protected]>2024-04-02 23:00:07 +0800
commit15cb9bc95d2d8df1f9b14f3014c275f6b0032a34 (patch)
tree86cead731f5dafd2f3c2845eeb51e33cad4dffd3 /tests
parentd2c877aa407931a0a385d7937cd06e13b15ecfea (diff)
add module.shared test
Diffstat (limited to 'tests')
-rw-r--r--tests/projects/other/native_module/modules/shared/foo/src/add.cpp9
-rw-r--r--tests/projects/other/native_module/modules/shared/foo/src/sub.cpp10
-rw-r--r--tests/projects/other/native_module/modules/shared/foo/xmake.lua14
-rw-r--r--tests/projects/other/native_module/test.lua3
-rw-r--r--tests/projects/other/native_module/xmake.lua6
5 files changed, 39 insertions, 3 deletions
diff --git a/tests/projects/other/native_module/modules/shared/foo/src/add.cpp b/tests/projects/other/native_module/modules/shared/foo/src/add.cpp
new file mode 100644
index 000000000..e19d07e12
--- /dev/null
+++ b/tests/projects/other/native_module/modules/shared/foo/src/add.cpp
@@ -0,0 +1,9 @@
+#include <stdio.h>
+#include <stdlib.h>
+
+int main(int argc, char** argv) {
+ int a = atoi(argv[1]);
+ int b = atoi(argv[2]);
+ printf("%d", a + b);
+ return 0;
+}
diff --git a/tests/projects/other/native_module/modules/shared/foo/src/sub.cpp b/tests/projects/other/native_module/modules/shared/foo/src/sub.cpp
new file mode 100644
index 000000000..980289d1a
--- /dev/null
+++ b/tests/projects/other/native_module/modules/shared/foo/src/sub.cpp
@@ -0,0 +1,10 @@
+#include <stdio.h>
+#include <stdlib.h>
+
+int main(int argc, char** argv) {
+ int a = atoi(argv[1]);
+ int b = atoi(argv[2]);
+ printf("%d", a - b);
+ return 0;
+}
+
diff --git a/tests/projects/other/native_module/modules/shared/foo/xmake.lua b/tests/projects/other/native_module/modules/shared/foo/xmake.lua
new file mode 100644
index 000000000..61c0a8357
--- /dev/null
+++ b/tests/projects/other/native_module/modules/shared/foo/xmake.lua
@@ -0,0 +1,14 @@
+add_rules("mode.debug", "mode.release")
+
+add_requires("lua")
+
+target("add")
+ add_rules("module.shared")
+ add_files("src/add.cpp")
+ add_packages("lua")
+
+target("sub")
+ add_rules("module.shared")
+ add_files("src/sub.cpp")
+ add_packages("lua")
+
diff --git a/tests/projects/other/native_module/test.lua b/tests/projects/other/native_module/test.lua
new file mode 100644
index 000000000..b57362078
--- /dev/null
+++ b/tests/projects/other/native_module/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/xmake.lua
index e5564cf4f..396921051 100644
--- a/tests/projects/other/native_module/xmake.lua
+++ b/tests/projects/other/native_module/xmake.lua
@@ -6,10 +6,10 @@ target("test")
set_kind("binary")
add_files("src/*.cpp")
on_config(function (target)
--- import("shared.foo")
+ import("shared.foo")
import("binary.bar")
--- print("shared: 1 + 1 = %d", foo.add(1, 1))
--- print("shared: 1 - 1 = %d", foo.sub(1, 1))
+ print("shared: 1 + 1 = %d", foo.add(1, 1))
+ print("shared: 1 - 1 = %d", foo.sub(1, 1))
print("binary: 1 + 1 = %s", bar.add(1, 1))
print("binary: 1 - 1 = %s", bar.sub(1, 1))
end)