summaryrefslogtreecommitdiff
path: root/xmake/modules
diff options
context:
space:
mode:
authorruki <[email protected]>2021-11-06 20:39:16 +0800
committerGitHub <[email protected]>2021-11-06 20:39:16 +0800
commit736dc4db6368fa4dd1770e768c5577bc8d55255d (patch)
tree7909ee3cf27c5bb190fd7f80c7e36dbb07d9ddbc /xmake/modules
parent95dea5af25edb9f1eda15ad8412342e26ef39525 (diff)
parent6bbb5f94c3beadf5d5dfc6db59d05a686647a39b (diff)
Merge pull request #1808 from xq114/dev
improve env config
Diffstat (limited to 'xmake/modules')
-rw-r--r--xmake/modules/detect/sdks/find_vstudio.lua100
-rw-r--r--xmake/modules/private/xrepo/action/env.lua8
2 files changed, 68 insertions, 40 deletions
diff --git a/xmake/modules/detect/sdks/find_vstudio.lua b/xmake/modules/detect/sdks/find_vstudio.lua
index 2934d23c8..0abbb131c 100644
--- a/xmake/modules/detect/sdks/find_vstudio.lua
+++ b/xmake/modules/detect/sdks/find_vstudio.lua
@@ -28,15 +28,72 @@ local vcvars = {"path",
"libpath",
"include",
"DevEnvdir",
- "VSInstallDir",
- "VCInstallDir",
+ "VSINSTALLDIR",
+ "VCINSTALLDIR",
"WindowsSdkDir",
"WindowsLibPath",
"WindowsSDKVersion",
"WindowsSdkBinPath",
+ "WindowsSdkVerBinPath",
+ "ExtensionSdkDir",
"UniversalCRTSdkDir",
"UCRTVersion",
- "VCToolsVersion"}
+ "VCToolsVersion",
+ "VCIDEInstallDir",
+ "VCToolsInstallDir",
+ "VCToolsRedistDir",
+ "VisualStudioVersion",
+ "VSCMD_VER",
+ "VSCMD_ARG_app_plat",
+ "VSCMD_ARG_HOST_ARCH",
+ "VSCMD_ARG_TGT_ARCH"}
+
+-- init vsvers
+local vsvers =
+{
+ ["17.0"] = "2022"
+, ["16.0"] = "2019"
+, ["15.0"] = "2017"
+, ["14.0"] = "2015"
+, ["12.0"] = "2013"
+, ["11.0"] = "2012"
+, ["10.0"] = "2010"
+, ["9.0"] = "2008"
+, ["8.0"] = "2005"
+, ["7.1"] = "2003"
+, ["7.0"] = "7.0"
+, ["6.0"] = "6.0"
+, ["5.0"] = "5.0"
+, ["4.2"] = "4.2"
+}
+
+-- init vsenvs
+local vsenvs =
+{
+ ["17.0"] = "VS170COMNTOOLS"
+, ["16.0"] = "VS160COMNTOOLS"
+, ["15.0"] = "VS150COMNTOOLS"
+, ["14.0"] = "VS140COMNTOOLS"
+, ["12.0"] = "VS120COMNTOOLS"
+, ["11.0"] = "VS110COMNTOOLS"
+, ["10.0"] = "VS100COMNTOOLS"
+, ["9.0"] = "VS90COMNTOOLS"
+, ["8.0"] = "VS80COMNTOOLS"
+, ["7.1"] = "VS71COMNTOOLS"
+, ["7.0"] = "VS70COMNTOOLS"
+, ["6.0"] = "VS60COMNTOOLS"
+, ["5.0"] = "VS50COMNTOOLS"
+, ["4.2"] = "VS42COMNTOOLS"
+}
+
+-- get all known Visual Studio environment variables
+function get_vcvars()
+ local realvcvars = vcvars
+ for _, v in pairs(vsenvs) do
+ table.insert(realvcvars, v)
+ end
+ return realvcvars
+end
-- load vcvarsall environment variables
function _load_vcvarsall(vcvarsall, vsver, arch, opt)
@@ -59,7 +116,7 @@ function _load_vcvarsall(vcvarsall, vsver, arch, opt)
else
file:print("call \"%s\" %s %s > nul", vcvarsall, arch, opt.sdkver and opt.sdkver or "")
end
- for idx, var in ipairs(vcvars) do
+ for idx, var in ipairs(get_vcvars()) do
file:print("echo " .. var .. " = %%" .. var .. "%%")
end
file:close()
@@ -148,41 +205,6 @@ function main(opt)
return
end
- -- init vsvers
- local vsvers =
- {
- ["17.0"] = "2022"
- , ["16.0"] = "2019"
- , ["15.0"] = "2017"
- , ["14.0"] = "2015"
- , ["12.0"] = "2013"
- , ["11.0"] = "2012"
- , ["10.0"] = "2010"
- , ["9.0"] = "2008"
- , ["8.0"] = "2005"
- , ["7.1"] = "2003"
- , ["7.0"] = "7.0"
- , ["6.0"] = "6.0"
- , ["5.0"] = "5.0"
- , ["4.2"] = "4.2"
- }
-
- -- init vsenvs
- local vsenvs =
- {
- ["14.0"] = "VS140COMNTOOLS"
- , ["12.0"] = "VS120COMNTOOLS"
- , ["11.0"] = "VS110COMNTOOLS"
- , ["10.0"] = "VS100COMNTOOLS"
- , ["9.0"] = "VS90COMNTOOLS"
- , ["8.0"] = "VS80COMNTOOLS"
- , ["7.1"] = "VS71COMNTOOLS"
- , ["7.0"] = "VS70COMNTOOLS"
- , ["6.0"] = "VS60COMNTOOLS"
- , ["5.0"] = "VS50COMNTOOLS"
- , ["4.2"] = "VS42COMNTOOLS"
- }
-
-- init options
opt = opt or {}
diff --git a/xmake/modules/private/xrepo/action/env.lua b/xmake/modules/private/xrepo/action/env.lua
index 18b59c0e6..07709b7bd 100644
--- a/xmake/modules/private/xrepo/action/env.lua
+++ b/xmake/modules/private/xrepo/action/env.lua
@@ -381,7 +381,13 @@ function info(key, bnd)
elseif key == "envfile" then
print(os.tmpfile())
elseif key == "config" then
- if not bnd and os.isfile(os.projectfile()) then
+ local boundenv = _get_boundenv({bind = bnd})
+ local has_envfile = (boundenv and os.isfile(boundenv)) and true or false
+ if has_envfile or os.isfile(os.projectfile()) then
+ if has_envfile then
+ _enter_project({enteronly = true})
+ table.insert(project.rcfiles(), boundenv)
+ end
task.run("config", {target = "all"}, {disable_dump = true})
end
elseif key:startswith("script.") then