diff options
| author | ruki <[email protected]> | 2017-05-30 23:14:27 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2017-05-30 23:14:27 +0800 |
| commit | f01d5364141a3e2a965bd9d46e65a2bd851e27ec (patch) | |
| tree | 6d56fb256655efa493021ee1a340368407c2c7c2 /xmake | |
| parent | af5040e4c197ce261062b925743201358dc5e43c (diff) | |
add winreg.query and improve program
Diffstat (limited to 'xmake')
| -rw-r--r-- | xmake/core/sandbox/modules/import/lib/detect/find_program.lua | 46 | ||||
| -rw-r--r-- | xmake/modules/detect/tool/find_ollydbg.lua | 18 | ||||
| -rw-r--r-- | xmake/modules/detect/tool/find_vsjitdebugger.lua | 18 | ||||
| -rw-r--r-- | xmake/modules/detect/tool/find_windbg.lua | 18 | ||||
| -rw-r--r-- | xmake/modules/detect/tool/find_x64dbg.lua | 18 | ||||
| -rw-r--r-- | xmake/platforms/windows/check.lua | 59 |
6 files changed, 62 insertions, 115 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 2f6f8b2ab..7ee0fb5a9 100644 --- a/xmake/core/sandbox/modules/import/lib/detect/find_program.lua +++ b/xmake/core/sandbox/modules/import/lib/detect/find_program.lua @@ -63,7 +63,7 @@ function sandbox_lib_detect_find_program._check(program, check) end -- find program -function sandbox_lib_detect_find_program._find(name, dirs, check) +function sandbox_lib_detect_find_program._find(name, pathes, check) -- attempt to check it directly in current environment if sandbox_lib_detect_find_program._check(name, check) then @@ -72,14 +72,36 @@ function sandbox_lib_detect_find_program._find(name, dirs, check) -- attempt to check it from the given directories if not path.is_absolute(name) then - for _, dir in ipairs(table.wrap(dirs)) do + for _, _path in ipairs(table.wrap(pathes)) do - -- TODO - -- dir is registry path? + -- handle winreg value .e.g [HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\XXXX;Name]\\dir\\file + _path = _path:gsub("%[(.*)%]", function (regpath) + + -- get registry value + local value, errors = winreg.query(regpath) + if not value then + raise(errors) + end + + -- file path not exists? attempt to parse path from `"path" xxx` + if not os.exists(value) then + value = value:match("\"(.-)\"") + end + + -- ok + return value + end) + + -- get program path + local program_path = nil + if os.isfile(_path) then + program_path = _path + elseif os.isdir(_path) then + program_path = path.join(_path, name) + end -- the program path - local program_path = path.join(dir, name) - if os.isexec(program_path) then + if program_path and os.isexec(program_path) then -- check it if sandbox_lib_detect_find_program._check(program_path, check) then return program_path @@ -105,11 +127,11 @@ end -- find program -- --- @param name the program name --- @param dirs the program directories --- @param check the check script or command +-- @param name the program name +-- @param pathes the program pathes (.e.g dirs, pathes, winreg pathes) +-- @param check the check script or command -- --- @return the program name or path +-- @return the program name or path -- -- @code -- @@ -120,7 +142,7 @@ end -- -- @endcode -- -function sandbox_lib_detect_find_program.main(name, dirs, check) +function sandbox_lib_detect_find_program.main(name, pathes, check) -- get detect cache local detectcache = cache(utils.ifelse(os.isfile(project.file()), "local.detect", "memory.detect")) @@ -133,7 +155,7 @@ function sandbox_lib_detect_find_program.main(name, dirs, check) end -- find executable program - result = sandbox_lib_detect_find_program._find(name, dirs, check) + result = sandbox_lib_detect_find_program._find(name, pathes, check) -- cache result cacheinfo[name] = utils.ifelse(result, result, false) diff --git a/xmake/modules/detect/tool/find_ollydbg.lua b/xmake/modules/detect/tool/find_ollydbg.lua index 0075e9eb8..3afd51276 100644 --- a/xmake/modules/detect/tool/find_ollydbg.lua +++ b/xmake/modules/detect/tool/find_ollydbg.lua @@ -46,16 +46,12 @@ function main(opt) if os.host() ~= "windows" then return end - - -- find program, TODO from winreg - local program = find_program(opt.program or "ollydbg", {}) - - -- find program version - local version = nil - if program and opt and opt.version then - version = find_programver(program) - end - -- ok? - return program, version + -- init options + opt = opt or {} + + -- find program + return find_program(opt.program or "ollydbg", {"[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\AeDebug;Debugger]" + "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Wow6432Node\\Microsoft\\Windows NT\\CurrentVersion\\AeDebug;Debugger]"} + , function (program) if not os.isfile(program) then raise() end end) end diff --git a/xmake/modules/detect/tool/find_vsjitdebugger.lua b/xmake/modules/detect/tool/find_vsjitdebugger.lua index bc7b12144..0d3368c72 100644 --- a/xmake/modules/detect/tool/find_vsjitdebugger.lua +++ b/xmake/modules/detect/tool/find_vsjitdebugger.lua @@ -46,16 +46,12 @@ function main(opt) if os.host() ~= "windows" then return end - - -- find program, TODO from winreg - local program = find_program(opt.program or "vsjitdebugger", {}) - - -- find program version - local version = nil - if program and opt and opt.version then - version = find_programver(program) - end - -- ok? - return program, version + -- init options + opt = opt or {} + + -- find program + return find_program(opt.program or "vsjitdebugger", {"[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\AeDebug;Debugger]" + "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Wow6432Node\\Microsoft\\Windows NT\\CurrentVersion\\AeDebug;Debugger]"} + , function (program) if not os.isfile(program) then raise() end end) end diff --git a/xmake/modules/detect/tool/find_windbg.lua b/xmake/modules/detect/tool/find_windbg.lua index 89d9e2563..f42469698 100644 --- a/xmake/modules/detect/tool/find_windbg.lua +++ b/xmake/modules/detect/tool/find_windbg.lua @@ -47,15 +47,11 @@ function main(opt) return end - -- find program, TODO from winreg - local program = find_program(opt.program or "windbg", {}) - - -- find program version - local version = nil - if program and opt and opt.version then - version = find_programver(program) - end - - -- ok? - return program, version + -- init options + opt = opt or {} + + -- find program + return find_program(opt.program or "windbg", {"[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\AeDebug;Debugger]" + "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Wow6432Node\\Microsoft\\Windows NT\\CurrentVersion\\AeDebug;Debugger]"} + , function (program) if not os.isfile(program) then raise() end end) end diff --git a/xmake/modules/detect/tool/find_x64dbg.lua b/xmake/modules/detect/tool/find_x64dbg.lua index be6c73155..38b8a5004 100644 --- a/xmake/modules/detect/tool/find_x64dbg.lua +++ b/xmake/modules/detect/tool/find_x64dbg.lua @@ -46,16 +46,12 @@ function main(opt) if os.host() ~= "windows" then return end - - -- find program, TODO from winreg - local program = find_program(opt.program or "x64dbg", {}) - - -- find program version - local version = nil - if program and opt and opt.version then - version = find_programver(program) - end - -- ok? - return program, version + -- init options + opt = opt or {} + + -- find program + return find_program(opt.program or "x64dbg", {"[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\AeDebug;Debugger]" + "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Wow6432Node\\Microsoft\\Windows NT\\CurrentVersion\\AeDebug;Debugger]"} + , function (program) if not os.isfile(program) then raise() end end) end diff --git a/xmake/platforms/windows/check.lua b/xmake/platforms/windows/check.lua index cb7e78eb1..8a442a0fe 100644 --- a/xmake/platforms/windows/check.lua +++ b/xmake/platforms/windows/check.lua @@ -199,64 +199,6 @@ function _check_vs(config) end end --- check the debugger -function _check_debugger(config) - - -- get debugger - local debugger = config.get("dg") - if debugger then - return - end - - -- query the debugger info for x64 - local info = try - { - function () - return os.iorun("reg query \"HKEY_LOCAL_MACHINE\\SOFTWARE\\Wow6432Node\\Microsoft\\Windows NT\\CurrentVersion\\AeDebug\" /v Debugger") - end - } - -- query the debugger info for x86 - if not info then - info = try - { - function () - return os.iorun("reg query \"HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\AeDebug\" /v Debugger") - end - } - end - - -- parse the debugger path - -- - -- ! REG.EXE VERSION 3.0 - -- - -- HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\AeDebug - -- Debugger REG_SZ "C:\WINDOWS\system32\vsjitdebugger.exe" -p %ld -e %ld - if info then - debugger = info:match("Debugger%s+REG_SZ%s+\"(.+)\"") - if debugger then - debugger = debugger:trim() - end - end - - -- this debugger exists? - if debugger and path.is_absolute(debugger) and not os.isfile(debugger) then - debugger = nil - end - - -- check ok? update it - if debugger then - - -- save it - config.set("dg", debugger) - - -- trace - print("checking for the debugger ... %s", path.filename(debugger)) - else - -- failed - print("checking for the debugger ... no") - end -end - -- get toolchains function _toolchains(config) @@ -350,7 +292,6 @@ function main(kind, toolkind) { { checker.check_arch, "x86" } , _check_vs - , _check_debugger } -- init the check list of global |
