summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorruki <[email protected]>2025-03-19 09:05:42 +0800
committerGitHub <[email protected]>2025-03-19 09:05:42 +0800
commit8ed7230306285162bf36aca054a30ac8258e05f7 (patch)
tree7395afe4d6128bb8fba945b9657e5f28056e09ac
parentc7395c42a703cd604109d16fd58a135daa1f0450 (diff)
parent684692a74814895c2aee7b51bd33cf27e6903838 (diff)
Merge pull request #6229 from xmake-io/find
improve find_program
-rw-r--r--xmake/core/sandbox/modules/import/lib/detect/find_program.lua23
1 files changed, 13 insertions, 10 deletions
diff --git a/xmake/core/sandbox/modules/import/lib/detect/find_program.lua b/xmake/core/sandbox/modules/import/lib/detect/find_program.lua
index fcf552f20..5eeac134b 100644
--- a/xmake/core/sandbox/modules/import/lib/detect/find_program.lua
+++ b/xmake/core/sandbox/modules/import/lib/detect/find_program.lua
@@ -239,18 +239,12 @@ function sandbox_lib_detect_find_program._find(name, paths, opt)
end
end
- -- attempt to find it directly in current environment
- --
- -- @note must be detected at the end, because full path is more accurate
- --
- local program_path_real = sandbox_lib_detect_find_program._check(name, opt)
- if program_path_real then
- return program_path_real
- end
-
-- attempt to find it use `where.exe program.exe` command
- --
-- and we need to add `.exe` suffix to avoid find some incorrect programs. e.g. pkg-config.bat
+ --
+ -- it will return the absolute path, so we call it first
+ -- https://github.com/xmake-io/xmake/discussions/6223#discussioncomment-12537122
+ --
if os.host() == "windows" then
local program_name = name:lower()
if not program_name:endswith(".exe") then
@@ -269,6 +263,15 @@ function sandbox_lib_detect_find_program._find(name, paths, opt)
end
end
end
+
+ -- attempt to find it directly in current environment
+ --
+ -- @note must be detected at the end, because full path is more accurate
+ --
+ local program_path_real = sandbox_lib_detect_find_program._check(name, opt)
+ if program_path_real then
+ return program_path_real
+ end
end
-- find program