diff options
| author | ruki <[email protected]> | 2017-06-01 10:45:02 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2017-06-01 10:45:02 +0800 |
| commit | 95a3f4499e5fb575613b4192519a53d323a7a19c (patch) | |
| tree | 4d0f1b48eb8fd186cc832a81941b1a804f7269c0 | |
| parent | f5fd7001a09b782c3aa2263738a07c38d7ddc351 (diff) | |
rename get api to val and fix get sandbox instance
| -rw-r--r-- | xmake/core/sandbox/modules/import/lib/detect/find_file.lua | 20 | ||||
| -rw-r--r-- | xmake/core/sandbox/modules/import/lib/detect/find_path.lua | 20 | ||||
| -rw-r--r-- | xmake/core/sandbox/modules/import/lib/detect/find_program.lua | 20 | ||||
| -rw-r--r-- | xmake/core/sandbox/modules/val.lua (renamed from xmake/core/sandbox/modules/get.lua) | 0 | ||||
| -rw-r--r-- | xmake/core/sandbox/sandbox.lua | 2 | ||||
| -rw-r--r-- | xmake/modules/detect/sdk/find_vstudio.lua | 8 | ||||
| -rw-r--r-- | xmake/modules/detect/tool/find_vsjitdebugger.lua | 4 |
7 files changed, 16 insertions, 58 deletions
diff --git a/xmake/core/sandbox/modules/import/lib/detect/find_file.lua b/xmake/core/sandbox/modules/import/lib/detect/find_file.lua index bcec5ec81..ef9f52784 100644 --- a/xmake/core/sandbox/modules/import/lib/detect/find_file.lua +++ b/xmake/core/sandbox/modules/import/lib/detect/find_file.lua @@ -31,6 +31,7 @@ local path = require("base/path") local utils = require("base/utils") local table = require("base/table") local raise = require("sandbox/modules/raise") +local vformat = require("sandbox/modules/vformat") -- find file -- @@ -52,23 +53,8 @@ function sandbox_lib_detect_find_file.main(name, pathes) local result = nil for _, _path in ipairs(table.wrap(pathes)) do - -- 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 - utils.verror(errors) - end - - -- file path not exists? attempt to parse path from `"path" xxx` - if value and not os.exists(value) then - value = value:match("\"(.-)\"") - end - - -- ok - return value - end) + -- format path for builtin variables + _path = vformat(_path) -- get file path local filepath = nil diff --git a/xmake/core/sandbox/modules/import/lib/detect/find_path.lua b/xmake/core/sandbox/modules/import/lib/detect/find_path.lua index 5decaffb7..4e83291f3 100644 --- a/xmake/core/sandbox/modules/import/lib/detect/find_path.lua +++ b/xmake/core/sandbox/modules/import/lib/detect/find_path.lua @@ -30,6 +30,7 @@ local os = require("base/os") local path = require("base/path") local table = require("base/table") local raise = require("sandbox/modules/raise") +local vformat = require("sandbox/modules/vformat") -- find path -- @@ -51,23 +52,8 @@ function sandbox_lib_detect_find_path.main(name, pathes) local result = nil for _, _path in ipairs(table.wrap(pathes)) do - -- 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 - utils.verror(errors) - end - - -- file path not exists? attempt to parse path from `"path" xxx` - if value and not os.exists(value) then - value = value:match("\"(.-)\"") - end - - -- ok - return value - end) + -- format path for builtin variables + _path = vformat(_path) -- get file path local filepath = nil 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 81fdc285b..8f53cfe2a 100644 --- a/xmake/core/sandbox/modules/import/lib/detect/find_program.lua +++ b/xmake/core/sandbox/modules/import/lib/detect/find_program.lua @@ -35,6 +35,7 @@ local cache = require("project/cache") local project = require("project/project") local sandbox = require("sandbox/sandbox") local raise = require("sandbox/modules/raise") +local vformat = require("sandbox/modules/vformat") -- check program function sandbox_lib_detect_find_program._check(program, check) @@ -74,23 +75,8 @@ function sandbox_lib_detect_find_program._find(name, pathes, check) if not path.is_absolute(name) then for _, _path in ipairs(table.wrap(pathes)) do - -- 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 - utils.verror(errors) - end - - -- file path not exists? attempt to parse path from `"path" xxx` - if value and not os.exists(value) then - value = value:match("\"(.-)\"") - end - - -- ok - return value - end) + -- format path for builtin variables + _path = vformat(_path) -- get program path local program_path = nil diff --git a/xmake/core/sandbox/modules/get.lua b/xmake/core/sandbox/modules/val.lua index fe02addae..fe02addae 100644 --- a/xmake/core/sandbox/modules/get.lua +++ b/xmake/core/sandbox/modules/val.lua diff --git a/xmake/core/sandbox/sandbox.lua b/xmake/core/sandbox/sandbox.lua index 1ca11e4fd..77b7003e2 100644 --- a/xmake/core/sandbox/sandbox.lua +++ b/xmake/core/sandbox/sandbox.lua @@ -293,7 +293,7 @@ function sandbox.instance() -- find self instance for the current sandbox local instance = nil local level = 2 - while level < 16 do + while level < 32 do -- get scope local scope = getfenv(level) diff --git a/xmake/modules/detect/sdk/find_vstudio.lua b/xmake/modules/detect/sdk/find_vstudio.lua index eaa0b21fe..d1a071c1f 100644 --- a/xmake/modules/detect/sdk/find_vstudio.lua +++ b/xmake/modules/detect/sdk/find_vstudio.lua @@ -54,10 +54,10 @@ function main() for _, version in ipairs({"15.0", "14.0", "12.0", "11.0", "10.0", "9.0", "8.0", "7.1", "7.0", "6.0", "5.0", "4.2"}) do -- find vcvarsall.bat - local vcvarsall = find_file("vcvarsall.bat", {format("[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\VisualStudio\\SxS\\VS7;%s]\\VC", version), - format("[HKEY_LOCAL_MACHINE\\SOFTWARE\\Wow6432Node\\Microsoft\\VisualStudio\\SxS\\VS7;%s]\\VC", version), - format("[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\VisualStudio\\SxS\\VS7;%s]\\VC\\Auxiliary\\Build", version), - format("[HKEY_LOCAL_MACHINE\\SOFTWARE\\Wow6432Node\\Microsoft\\VisualStudio\\SxS\\VS7;%s]\\VC\\Auxiliary\\Build", version)}) + local vcvarsall = find_file("vcvarsall.bat", {format("$(reg HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\VisualStudio\\SxS\\VS7;%s)\\VC", version), + format("$(reg HKEY_LOCAL_MACHINE\\SOFTWARE\\Wow6432Node\\Microsoft\\VisualStudio\\SxS\\VS7;%s)\\VC", version), + format("$(reg HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\VisualStudio\\SxS\\VS7;%s)\\VC\\Auxiliary\\Build", version), + format("$(reg HKEY_LOCAL_MACHINE\\SOFTWARE\\Wow6432Node\\Microsoft\\VisualStudio\\SxS\\VS7;%s)\\VC\\Auxiliary\\Build", version)}) -- found? if vcvarsall then diff --git a/xmake/modules/detect/tool/find_vsjitdebugger.lua b/xmake/modules/detect/tool/find_vsjitdebugger.lua index 8aed63fb9..922d3fdf3 100644 --- a/xmake/modules/detect/tool/find_vsjitdebugger.lua +++ b/xmake/modules/detect/tool/find_vsjitdebugger.lua @@ -51,7 +51,7 @@ function main(opt) 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]"} + return find_program(opt.program or "vsjitdebugger", {"$(reg HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\AeDebug;Debugger)", + "$(reg HKEY_LOCAL_MACHINE\\SOFTWARE\\Wow6432Node\\Microsoft\\Windows NT\\CurrentVersion\\AeDebug;Debugger)"} , function (program) if not os.isfile(program) then raise() end end) end |
