diff options
| author | ruki <[email protected]> | 2023-04-20 22:36:29 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2023-04-20 22:36:29 +0800 |
| commit | 025fbe9559af74fac774b76b39cbd28f1f5bba6d (patch) | |
| tree | 48506896180e550590f6c78a058650e6a1093676 /xmake/modules | |
| parent | f11dad73c0d087f43ea5e016208f0a4a05334fd6 (diff) | |
improve to detect vstudio cache #3652
Diffstat (limited to 'xmake/modules')
| -rw-r--r-- | xmake/modules/detect/sdks/find_vstudio.lua | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/xmake/modules/detect/sdks/find_vstudio.lua b/xmake/modules/detect/sdks/find_vstudio.lua index 50092ff12..d3ff7fd7a 100644 --- a/xmake/modules/detect/sdks/find_vstudio.lua +++ b/xmake/modules/detect/sdks/find_vstudio.lua @@ -343,6 +343,34 @@ function _find_vstudio(opt) return results end +-- get last mtime of msvc +-- @see https://github.com/xmake-io/xmake/issues/3652 +function _get_last_mtime_of_msvc(msvc) + local mtime = -1 + for arch, envs in pairs(msvc.vcvarsall) do + if envs.PATH then + local pathenv = path.splitenv(envs.PATH) + for _, dir in ipairs(pathenv) do + local cl = path.join(dir, "cl.exe") + if os.isfile(cl) then + local t = os.mtime(cl) + if t > mtime then + mtime = t + end + end + end + end + local winsdk = envs.WindowsSdkDir + if winsdk and os.isdir(winsdk) then + local t = os.mtime(winsdk) + if t > mtime then + mtime = t + end + end + end + return mtime +end + -- get last mtime of vstudio function _get_last_mtime(vstudio) local mtime = -1 @@ -353,6 +381,10 @@ function _get_last_mtime(vstudio) if t > mtime then mtime = t end + t = _get_last_mtime_of_msvc(msvc) + if t > mtime then + mtime = t + end else mtime = -1 break |
