Skip to content

Commit 684692a

Browse files
committed
improve find_program
1 parent c7395c4 commit 684692a

File tree

1 file changed

+13
-10
lines changed

1 file changed

+13
-10
lines changed

xmake/core/sandbox/modules/import/lib/detect/find_program.lua

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -239,18 +239,12 @@ function sandbox_lib_detect_find_program._find(name, paths, opt)
239239
end
240240
end
241241

242-
-- attempt to find it directly in current environment
243-
--
244-
-- @note must be detected at the end, because full path is more accurate
245-
--
246-
local program_path_real = sandbox_lib_detect_find_program._check(name, opt)
247-
if program_path_real then
248-
return program_path_real
249-
end
250-
251242
-- attempt to find it use `where.exe program.exe` command
252-
--
253243
-- and we need to add `.exe` suffix to avoid find some incorrect programs. e.g. pkg-config.bat
244+
--
245+
-- it will return the absolute path, so we call it first
246+
-- https://github.com/xmake-io/xmake/discussions/6223#discussioncomment-12537122
247+
--
254248
if os.host() == "windows" then
255249
local program_name = name:lower()
256250
if not program_name:endswith(".exe") then
@@ -269,6 +263,15 @@ function sandbox_lib_detect_find_program._find(name, paths, opt)
269263
end
270264
end
271265
end
266+
267+
-- attempt to find it directly in current environment
268+
--
269+
-- @note must be detected at the end, because full path is more accurate
270+
--
271+
local program_path_real = sandbox_lib_detect_find_program._check(name, opt)
272+
if program_path_real then
273+
return program_path_real
274+
end
272275
end
273276

274277
-- find program

0 commit comments

Comments
 (0)