diff options
| author | ruki <[email protected]> | 2018-09-21 23:30:53 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2018-09-21 15:05:23 +0800 |
| commit | 77f1de5eea59bef799343336c960e9983ffd5cf5 (patch) | |
| tree | c944eeb9be9671a2cc10ec9373bf0943a3a63b6a /xmake/core/sandbox/modules | |
| parent | e4ce9f64923260de45e83ca735d025e19cce45ad (diff) | |
add find python and python3
Diffstat (limited to 'xmake/core/sandbox/modules')
| -rw-r--r-- | xmake/core/sandbox/modules/import/lib/detect/find_program.lua | 21 | ||||
| -rw-r--r-- | xmake/core/sandbox/modules/import/lib/detect/find_programver.lua | 3 |
2 files changed, 22 insertions, 2 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 7136d05ed..dbeb4a47e 100644 --- a/xmake/core/sandbox/modules/import/lib/detect/find_program.lua +++ b/xmake/core/sandbox/modules/import/lib/detect/find_program.lua @@ -28,6 +28,7 @@ local sandbox_lib_detect_find_program = sandbox_lib_detect_find_program or {} -- load modules local os = require("base/os") local path = require("base/path") +local option = require("base/winos") local table = require("base/table") local utils = require("base/utils") local option = require("base/option") @@ -118,8 +119,24 @@ function sandbox_lib_detect_find_program._find(name, pathes, opt) end end - -- attempt to check it use `which program` command - if os.host() ~= "windows" then + -- attempt to check it from regists + if os.host() == "windows" then + local program_name = name:lower() + if not program_name:endswith(".exe") then + program_name = program_name .. ".exe" + end + local program_path = winos.registry_query("HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\App Paths\\" .. program_name) + if program_path then + -- check it + program_path = program_path:trim() + if os.isexec(program_path) then + if sandbox_lib_detect_find_program._check(program_path, opt) then + return program_path + end + end + end + else + -- attempt to check it use `which program` command local ok, program_path = os.iorunv("which", {name}) if ok and program_path then -- check it diff --git a/xmake/core/sandbox/modules/import/lib/detect/find_programver.lua b/xmake/core/sandbox/modules/import/lib/detect/find_programver.lua index 6c59d631a..276cd7a1d 100644 --- a/xmake/core/sandbox/modules/import/lib/detect/find_programver.lua +++ b/xmake/core/sandbox/modules/import/lib/detect/find_programver.lua @@ -95,6 +95,9 @@ function sandbox_lib_detect_find_programver.main(program, opt) end elseif parse == nil or type(parse) == "string" then result = outdata:match(parse or "(%d+%.?%d*%.?%d*.-)%s") + if not result then + result = outdata:match(parse or "(%d+%.?%d*%.?%d*.-)") + end end end |
