diff options
| -rw-r--r-- | xmake/core/base/os.lua | 17 | ||||
| -rw-r--r-- | xmake/core/sandbox/modules/os.lua | 13 | ||||
| -rw-r--r-- | xmake/core/tool/tool.lua | 2 |
3 files changed, 31 insertions, 1 deletions
diff --git a/xmake/core/base/os.lua b/xmake/core/base/os.lua index 702d97c82..b668647e2 100644 --- a/xmake/core/base/os.lua +++ b/xmake/core/base/os.lua @@ -360,6 +360,23 @@ function os.raise(msg, ...) end end +-- is executable program? +function os.isexec(filepath) + + -- check + assert(filepath) + + -- TODO + -- check permission + + -- is *.exe for windows? + if xmake._HOST == "windows" and not filepath:find("%.exe") then + filepath = filepath .. ".exe" + end + + -- file exists? + return os.isfile(filepath) +end -- return module return os diff --git a/xmake/core/sandbox/modules/os.lua b/xmake/core/sandbox/modules/os.lua index 963ba3f55..7930ae3b2 100644 --- a/xmake/core/sandbox/modules/os.lua +++ b/xmake/core/sandbox/modules/os.lua @@ -294,6 +294,19 @@ function sandbox_os.isfile(filepath) return os.isfile(filepath) end +-- is execute program? +function sandbox_os.isexec(filepath) + + -- check + assert(filepath) + + -- format it first + filepath = vformat(filepath) + + -- done + return os.isexec(filepath) +end + -- exists file or directory? function sandbox_os.exists(file_or_dir) diff --git a/xmake/core/tool/tool.lua b/xmake/core/tool/tool.lua index 209673e6e..8bd41d498 100644 --- a/xmake/core/tool/tool.lua +++ b/xmake/core/tool/tool.lua @@ -255,7 +255,7 @@ function tool.check(shellname, dirs, check) -- the tool path local toolpath = path.join(dir, shellname) - if os.isfile(toolpath) then + if os.isexec(toolpath) then -- check it if tool._check(toolpath, check) then |
