diff options
| author | ruki <[email protected]> | 2026-01-30 22:46:13 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2026-01-30 22:46:13 +0800 |
| commit | 6ea3339899b25d15209f46a73546e94835321c62 (patch) | |
| tree | 4f618f30cee7e58f947461921d1a65240a61deb6 /xmake/core/base/os.lua | |
| parent | 438a5a9dea35a42bd65c4983d5654ee99ed17bc0 (diff) | |
optimize os.isexec
Diffstat (limited to 'xmake/core/base/os.lua')
| -rw-r--r-- | xmake/core/base/os.lua | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/xmake/core/base/os.lua b/xmake/core/base/os.lua index 4263cf659..12bc30c1d 100644 --- a/xmake/core/base/os.lua +++ b/xmake/core/base/os.lua @@ -1150,11 +1150,19 @@ end -- is executable program file? function os.isexec(filepath) if os.host() == "windows" then - local exts = {".exe", ".com", ".cmd", ".bat", ".ps1", ".sh"} + local exts_map = os._ISEXEC_WINDOWS_EXTS_MAP + if not exts_map then + local exts = {".exe", ".com", ".cmd", ".bat", ".ps1", ".sh"} + exts_map = {} + for _, ext in ipairs(exts) do + exts_map[ext] = true + end + os._ISEXEC_WINDOWS_EXTS_MAP = exts_map + end if os.isfile(filepath) then local extension = path.extension(filepath) if extension and #extension > 0 then - if table.contains(exts, extension:lower()) then + if exts_map[extension:lower()] then return true end else @@ -1173,7 +1181,7 @@ function os.isexec(filepath) end end end - for _, suffix in ipairs(exts) do + for suffix, _ in pairs(exts_map) do if os.isfile(filepath .. suffix) then return true end |
