diff options
| author | ruki <[email protected]> | 2026-02-07 00:52:20 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2026-02-07 00:52:20 +0800 |
| commit | 791292f2ee65a4ca8566c3e7a38cbcbf965ddd08 (patch) | |
| tree | b3d1bd6944c3e704828d904a0698fb8e44bf328d /xmake/core/base/process.lua | |
| parent | 6007059c47a51d5847772fb68e357e4869ba85b3 (diff) | |
improve run policy and missing dll
Diffstat (limited to 'xmake/core/base/process.lua')
| -rw-r--r-- | xmake/core/base/process.lua | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/xmake/core/base/process.lua b/xmake/core/base/process.lua index 5436115ed..bea469346 100644 --- a/xmake/core/base/process.lua +++ b/xmake/core/base/process.lua @@ -271,5 +271,48 @@ function process.openv(program, argv, opt) end end +-- get missing dlls +function process._get_missing_dlls(program) + + -- get paths + local pathenv = os.getenv("PATH") or "" + local paths = path.splitenv(pathenv) + table.insert(paths, 1, path.directory(program)) + + -- find missing dlls + local missing = {} + local binutils = require("base/binutils") + 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, dll)) then + found = true + break + end + end + if not found then + table.insert(missing, dll) + end + end + return missing +end + +-- get process exit errors +function process.get_exit_errors(program, exitcode) + if is_host("windows") then + -- DLL is missing, 0xC0000135 + if exitcode == -1073741515 and os.isexec(program) then + local missing_dlls = process._get_missing_dlls(program) + if #missing_dlls > 0 then + errors = string.format("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.", table.concat(missing_dlls, "\n - ")) + else + errors = string.format("system error 0xC0000135 (STATUS_DLL_NOT_FOUND).\nThe application failed to start because a dependent DLL was not found.\nPlease check your PATH environment variable or copy the missing DLL to the executable directory.") + end + end + end +end + + -- return module: process return process |
