From 16bfa1e8727d8f7bd43c86f52646c2d26e7cadb7 Mon Sep 17 00:00:00 2001 From: ruki Date: Sat, 8 Dec 2018 00:51:42 +0800 Subject: improve windows environment --- xmake/platforms/windows/environment.lua | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/xmake/platforms/windows/environment.lua b/xmake/platforms/windows/environment.lua index e1c37f7d8..fd634c110 100644 --- a/xmake/platforms/windows/environment.lua +++ b/xmake/platforms/windows/environment.lua @@ -25,6 +25,7 @@ -- imports import("core.project.config") import("core.base.global") +import("detect.sdks.find_vstudio") -- enter the given environment function _enter(name) @@ -41,6 +42,25 @@ function _enter(name) -- get vs environment for the current arch local vsenv = vcvarsall[arch] or {} + -- switch vstudio environment if vs_sdkver has been changed + local switch_vsenv = false + local vs = config.get("vs") + local vs_sdkver = config.get("vs_sdkver") + if vs and vs_sdkver and vsenv.WindowsSDKVersion and vs_sdkver ~= vsenv.WindowsSDKVersion then + switch_vsenv = true + end + if switch_vsenv then + -- find vstudio + local vstudio = find_vstudio({vcvars_ver = config.get("vs_toolset"), sdkver = vs_sdkver}) + if vstudio then + vcvarsall = (vstudio[vs] or {}).vcvarsall or {} + vsenv = vcvarsall[arch] or {} + if vsenv and vsenv.path and vsenv.include and vsenv.lib then + config.set("__vcvarsall", vcvarsall) + end + end + end + -- get the pathes for the vs environment local old = nil local new = vsenv[name] -- cgit v1.3.1