From 6953ca0c43ff4cb08fc9f76eabb5415a892e5167 Mon Sep 17 00:00:00 2001 From: ruki Date: Tue, 2 Apr 2024 21:01:59 +0800 Subject: add multiple interfaces for bar --- .../other/native_module/modules/binary/bar/src/add.cpp | 9 +++++++++ .../other/native_module/modules/binary/bar/src/main.cpp | 6 ------ .../other/native_module/modules/binary/bar/src/sub.cpp | 10 ++++++++++ .../projects/other/native_module/modules/binary/bar/xmake.lua | 7 +++++-- tests/projects/other/native_module/xmake.lua | 6 ++++-- 5 files changed, 28 insertions(+), 10 deletions(-) create mode 100644 tests/projects/other/native_module/modules/binary/bar/src/add.cpp delete mode 100644 tests/projects/other/native_module/modules/binary/bar/src/main.cpp create mode 100644 tests/projects/other/native_module/modules/binary/bar/src/sub.cpp diff --git a/tests/projects/other/native_module/modules/binary/bar/src/add.cpp b/tests/projects/other/native_module/modules/binary/bar/src/add.cpp new file mode 100644 index 000000000..87ef97e6c --- /dev/null +++ b/tests/projects/other/native_module/modules/binary/bar/src/add.cpp @@ -0,0 +1,9 @@ +#include +#include + +int main(int argc, char** argv) { + int a = atoi(argv[1]); + int b = atoi(argv[2]); + printf("%s\n", a + b); + return 0; +} diff --git a/tests/projects/other/native_module/modules/binary/bar/src/main.cpp b/tests/projects/other/native_module/modules/binary/bar/src/main.cpp deleted file mode 100644 index 740142372..000000000 --- a/tests/projects/other/native_module/modules/binary/bar/src/main.cpp +++ /dev/null @@ -1,6 +0,0 @@ -#include - -int main(int argc, char** argv) { - printf("%s %s\n", argv[1], argv[2]); - return 0; -} diff --git a/tests/projects/other/native_module/modules/binary/bar/src/sub.cpp b/tests/projects/other/native_module/modules/binary/bar/src/sub.cpp new file mode 100644 index 000000000..524930500 --- /dev/null +++ b/tests/projects/other/native_module/modules/binary/bar/src/sub.cpp @@ -0,0 +1,10 @@ +#include +#include + +int main(int argc, char** argv) { + int a = atoi(argv[1]); + int b = atoi(argv[2]); + printf("%s\n", a - b); + return 0; +} + diff --git a/tests/projects/other/native_module/modules/binary/bar/xmake.lua b/tests/projects/other/native_module/modules/binary/bar/xmake.lua index 8f4526071..add3c6e97 100644 --- a/tests/projects/other/native_module/modules/binary/bar/xmake.lua +++ b/tests/projects/other/native_module/modules/binary/bar/xmake.lua @@ -1,7 +1,10 @@ add_rules("mode.debug", "mode.release") -target("bar") +target("add") add_rules("module.binary") - add_files("src/*.cpp") + add_files("src/add.cpp") +target("sub") + add_rules("module.binary") + add_files("src/sub.cpp") diff --git a/tests/projects/other/native_module/xmake.lua b/tests/projects/other/native_module/xmake.lua index 628248534..44b310649 100644 --- a/tests/projects/other/native_module/xmake.lua +++ b/tests/projects/other/native_module/xmake.lua @@ -8,7 +8,9 @@ target("test") on_config(function (target) -- import("shared.foo") import("binary.bar") --- print("1 + 1 = %d", foo.add(1, 1)) - print("%s", bar("hello", "xmake!")) +-- 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) -- cgit v1.3.1