diff options
| author | Saikari <[email protected]> | 2026-02-06 15:37:26 +0300 |
|---|---|---|
| committer | Saikari <[email protected]> | 2026-02-06 15:37:26 +0300 |
| commit | 6007059c47a51d5847772fb68e357e4869ba85b3 (patch) | |
| tree | ca76a02a2bd620185e310dfa78f8c345a83bdd08 | |
| parent | 12d3bbcb05dd4393da1ec472c9e1ad135afa3e20 (diff) | |
cleanup
| -rw-r--r-- | tests/projects/windows/windows_links/xmake.lua | 2 | ||||
| -rw-r--r-- | xmake/core/sandbox/modules/os.lua | 34 |
2 files changed, 19 insertions, 17 deletions
diff --git a/tests/projects/windows/windows_links/xmake.lua b/tests/projects/windows/windows_links/xmake.lua index a38616132..dcb7e4e2c 100644 --- a/tests/projects/windows/windows_links/xmake.lua +++ b/tests/projects/windows/windows_links/xmake.lua @@ -6,7 +6,7 @@ target("foo") set_kind("shared")
add_files("src/foo.c")
-target("test_mingw_dll")
+target("test_foo_dll_presence")
set_kind("binary")
add_files("src/main.c")
add_deps("foo")
diff --git a/xmake/core/sandbox/modules/os.lua b/xmake/core/sandbox/modules/os.lua index 25242f3f4..ce2cf6504 100644 --- a/xmake/core/sandbox/modules/os.lua +++ b/xmake/core/sandbox/modules/os.lua @@ -340,34 +340,36 @@ function sandbox_os.exec(cmd, ...) end end --- execute command with arguments list -- get missing dlls -local function _get_missing_dlls(program) - local missing = {} - local program_dir = path.directory(program) +function sandbox_os._get_missing_dlls(program) + + -- check + assert(program) + + -- get paths local pathenv = os.getenv("PATH") or "" local paths = path.splitenv(pathenv) - table.insert(paths, 1, program_dir) + table.insert(paths, 1, path.directory(program)) - local function _find_dll(name) + -- find missing dlls + local missing = {} + local imports = binutils.deplibs(program) or {} + for _, dll in ipairs(imports) do + local found = false for _, p in ipairs(paths) do - if os.isfile(path.join(p, name)) then - return true + if os.isfile(path.join(p, dll)) then + found = true + break end end - return false - end - - local imports = binutils.deplibs(program) or {} - - for _, dll in ipairs(imports) do - if not _find_dll(dll) then + if not found then table.insert(missing, dll) end end return missing end +-- execute command with arguments list function sandbox_os.execv(program, argv, opt) -- make program @@ -418,7 +420,7 @@ function sandbox_os.execv(program, argv, opt) -- get errors if ok ~= nil then if ok == -1073741515 then -- 0xC0000135 - local missing_dlls = _get_missing_dlls(program) + local missing_dlls = sandbox_os._get_missing_dlls(program) if #missing_dlls > 0 then errors = string.format("execv(%s) failed(%d): system error 0xC0000135 (STATUS_DLL_NOT_FOUND).\nThe application failed to start because the following DLLs were not found:\n - %s\nPlease check your PATH environment variable or copy the missing DLLs to the executable directory.", cmd, ok, table.concat(missing_dlls, "\n - ")) else |
