diff options
| author | ruki <[email protected]> | 2025-09-17 00:50:16 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2025-09-17 00:50:16 +0800 |
| commit | f9e895a3d33d021d4ddda6be9dfc4bacf358e6ea (patch) | |
| tree | 21efaf57eb9af312d26d9842c88348203999c286 | |
| parent | d8a33ac4341a747119b151efdfa50d9d50660926 (diff) | |
improve to find program
| -rw-r--r-- | xmake/core/sandbox/modules/import/lib/detect/find_program.lua | 28 |
1 files changed, 18 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 e1379bf44..7c53d0a03 100644 --- a/xmake/core/sandbox/modules/import/lib/detect/find_program.lua +++ b/xmake/core/sandbox/modules/import/lib/detect/find_program.lua @@ -178,11 +178,6 @@ end -- find program function sandbox_lib_detect_find_program._find(name, paths, opt) - -- valid program file? - if path.is_absolute(name) and os.isfile(name) then - return name - end - -- attempt to find it from the given directories local program_path = sandbox_lib_detect_find_program._find_from_paths(name, paths, opt) if program_path and opt.system ~= false then @@ -205,7 +200,11 @@ function sandbox_lib_detect_find_program._find(name, paths, opt) if not program_name:endswith(".exe") then program_name = program_name .. ".exe" end - program_path = winos.registry_query("HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\App Paths\\" .. program_name) + if path.is_absolute(program_name) and os.isfile(program_name) then + program_path = program_name + else + program_path = winos.registry_query("HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\App Paths\\" .. program_name) + end if program_path then program_path = program_path:trim() if os.isexec(program_path) then @@ -216,10 +215,19 @@ function sandbox_lib_detect_find_program._find(name, paths, opt) end end else - -- attempt to find it use `which program` command - local ok, program_path = os.iorunv("which", {name}) - if ok and program_path then - program_path = program_path:trim() + if path.is_absolute(name) and os.isfile(name) then + program_path = name + else + -- attempt to find it use `which program` command + local ok, result = os.iorunv("which", {name}) + if ok and result then + program_path = result:trim() + else + program_path = nil + end + end + + if program_path then local program_path_real = sandbox_lib_detect_find_program._check(program_path, opt) if program_path_real then return program_path_real |
