diff options
| author | ruki <[email protected]> | 2018-08-18 00:32:23 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2018-08-17 21:14:22 +0800 |
| commit | c49755cdff88b6e2f79cd6b03eb581509fb8499e (patch) | |
| tree | 0831ab243ae0f1a744814b7cc14fa09b6717fcfa | |
| parent | 56278d4967d2b40f28b23f7c84da7550db31b830 (diff) | |
improve find_vstudio
| -rw-r--r-- | xmake/modules/detect/sdks/find_vstudio.lua | 19 |
1 files changed, 11 insertions, 8 deletions
diff --git a/xmake/modules/detect/sdks/find_vstudio.lua b/xmake/modules/detect/sdks/find_vstudio.lua index 2778846b8..83fa54c59 100644 --- a/xmake/modules/detect/sdks/find_vstudio.lua +++ b/xmake/modules/detect/sdks/find_vstudio.lua @@ -49,22 +49,25 @@ function _load_vcvarsall(vcvarsall, arch) local file = io.open(genvcvars_bat, "w") file:print("@echo off") file:print("call \"%s\" %s > nul", vcvarsall, arch) - file:print("echo { > %s", genvcvars_dat) for idx, var in ipairs(vcvars) do - file:print("echo " .. (idx == 1 and "" or ",") .. " " .. var .. " = \"%%" .. var .. "%%\" >> %s", genvcvars_dat) + file:print("echo " .. var .. " = %%" .. var .. "%% %s %s", idx == 1 and ">" or ">>", genvcvars_dat) end - file:print("echo } >> %s", genvcvars_dat) file:close() -- run genvcvars.bat os.run(genvcvars_bat) - -- replace "\" => "\\" - io.gsub(genvcvars_dat, "\\", "\\\\") - -- load all envirnoment variables - local variables = io.load(genvcvars_dat) - if not variables then + local variables = {} + for _, line in ipairs((io.readfile(genvcvars_dat) or ""):split("\n")) do + local p = line:find('=', 1, true) + if p then + local name = line:sub(1, p - 1):trim() + local value = line:sub(p + 1):trim() + variables[name] = value + end + end + if not variables.path then return end |
