diff options
| author | ruki <[email protected]> | 2024-04-02 00:00:12 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2024-04-02 00:00:12 +0800 |
| commit | 72985a034146f40d460ea1fcf7bd017c00b520d7 (patch) | |
| tree | 113535bd45cc430c085086947736feabfde79534 | |
| parent | a881ec111510bd47d7dc374880ff6bcce2e3d42d (diff) | |
improve binary test
| -rw-r--r-- | tests/projects/other/native_module/modules/binary/src/main.cpp | 9 | ||||
| -rw-r--r-- | tests/projects/other/native_module/xmake.lua | 2 | ||||
| -rw-r--r-- | xmake/core/sandbox/modules/import/core/sandbox/module.lua | 20 |
3 files changed, 16 insertions, 15 deletions
diff --git a/tests/projects/other/native_module/modules/binary/src/main.cpp b/tests/projects/other/native_module/modules/binary/src/main.cpp index 7c435d251..740142372 100644 --- a/tests/projects/other/native_module/modules/binary/src/main.cpp +++ b/tests/projects/other/native_module/modules/binary/src/main.cpp @@ -1,9 +1,6 @@ -#include <iostream> +#include <stdio.h> -using namespace std; - -int main(int argc, char** argv) -{ - cout << "hello world!" << endl; +int main(int argc, char** argv) { + printf("%s %s\n", argv[1], argv[2]); return 0; } diff --git a/tests/projects/other/native_module/xmake.lua b/tests/projects/other/native_module/xmake.lua index 3e7f0f4f1..628248534 100644 --- a/tests/projects/other/native_module/xmake.lua +++ b/tests/projects/other/native_module/xmake.lua @@ -9,6 +9,6 @@ target("test") -- import("shared.foo") import("binary.bar") -- print("1 + 1 = %d", foo.add(1, 1)) - print("1 - 1 = %s", bar("1", "1")) + print("%s", bar("hello", "xmake!")) end) diff --git a/xmake/core/sandbox/modules/import/core/sandbox/module.lua b/xmake/core/sandbox/modules/import/core/sandbox/module.lua index 28b327568..c1ee0d902 100644 --- a/xmake/core/sandbox/modules/import/core/sandbox/module.lua +++ b/xmake/core/sandbox/modules/import/core/sandbox/module.lua @@ -181,6 +181,14 @@ function core_sandbox_module._load_from_scriptdir(module_fullpath, opt) return module, script end +-- load module from the binary module +function core_sandbox_module._load_from_binary(module_fullpath, opt) +end + +-- load module from the shared module +function core_sandbox_module._load_from_shared(module_fullpath, opt) +end + -- load module function core_sandbox_module._load(dir, name, opt) opt = opt or {} @@ -201,7 +209,10 @@ function core_sandbox_module._load(dir, name, opt) module, script = core_sandbox_module._load_from_scriptfile(module_fullpath, opt) elseif modulekind == MODULE_KIND_LUADIR then module, script = core_sandbox_module._load_from_scriptdir(module_fullpath, opt) - elseif modulekind == MODULE_KIND_BINARY then -- load binary module + elseif modulekind == MODULE_KIND_BINARY then + module, script = core_sandbox_module._load_from_binary(module_fullpath, opt) + elseif modulekind == MODULE_KIND_SHARED then + module, script = core_sandbox_module._load_from_shared(module_fullpath, opt) end if not module then local errors = script @@ -251,17 +262,10 @@ end -- get module name function core_sandbox_module.name(name) - - -- check - assert(name) - - -- find modulename local i = name:lastof(".", true) if i then name = name:sub(i + 1) end - - -- get it return name end |
