diff options
| author | ruki <[email protected]> | 2018-12-08 00:51:42 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2018-12-07 23:10:14 +0800 |
| commit | 16bfa1e8727d8f7bd43c86f52646c2d26e7cadb7 (patch) | |
| tree | ae94762a4f28f67a7ff21752d753f4a601772c65 | |
| parent | f0bc116842f6a3618333ec2eb59a69847cfda727 (diff) | |
improve windows environment
| -rw-r--r-- | xmake/platforms/windows/environment.lua | 20 |
1 files changed, 20 insertions, 0 deletions
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] |
