From d5089b5d9b7bab6a3f93ae34666f32ec76b320e5 Mon Sep 17 00:00:00 2001 From: Damien Courtois Date: Tue, 16 Jan 2018 16:45:47 +0100 Subject: [PATCH 1/4] added a 'latest' systemversion for vs2017 forgot to add the ".0" suffix added unit tests for systemversion "latest" --- modules/vstudio/tests/vc2010/test_globals.lua | 45 +++++++++++++++++++ modules/vstudio/vs2010_vcxproj.lua | 22 +++++++-- 2 files changed, 64 insertions(+), 3 deletions(-) diff --git a/modules/vstudio/tests/vc2010/test_globals.lua b/modules/vstudio/tests/vc2010/test_globals.lua index 88c49a40de..4ce7ab1b35 100644 --- a/modules/vstudio/tests/vc2010/test_globals.lua +++ b/modules/vstudio/tests/vc2010/test_globals.lua @@ -253,3 +253,48 @@ ]] end + +-- +-- Check that the "latest" systemversion works. +-- note: we override the os.getWindowsRegistry method for reliable tests. +-- + + function suite.windowsTargetPlatformVersionLatest_on2017() + p.action.set("vs2017") + systemversion "latest" + prepare() + local oldRegistry = os.getWindowsRegistry + os.getWindowsRegistry = function (key) + return "10.0.11111" + end + test.capture [[ + + {42B5DBC6-AE1F-903D-F75D-41E363076E92} + true + Win32Proj + MyProject + 10.0.11111.0 + + ]] + -- restore the registry function + os.getWindowsRegistry = oldRegistry + end + +-- +-- Check that the "latest" systemversion will not add +-- when the action is less than 2017 +-- + + function suite.windowsTargetPlatformVersionLatest_on2015() + p.action.set("vs2015") + systemversion "10.0.10240.0" + prepare() + test.capture [[ + + {42B5DBC6-AE1F-903D-F75D-41E363076E92} + true + Win32Proj + MyProject + + ]] + end diff --git a/modules/vstudio/vs2010_vcxproj.lua b/modules/vstudio/vs2010_vcxproj.lua index 3f2fe692a4..7d1befa7cf 100644 --- a/modules/vstudio/vs2010_vcxproj.lua +++ b/modules/vstudio/vs2010_vcxproj.lua @@ -2356,9 +2356,16 @@ function m.targetPlatformVersion(prj) - local min = project.systemversion(prj) - if min ~= nil and _ACTION >= "vs2015" then - m.element("WindowsTargetPlatformVersion", nil, min) + if _ACTION >= "vs2015" then + local min = project.systemversion(prj) + -- handle special "latest" version + if min == "latest" then + -- vs2015 and lower can't build against SDK 10 + min = iif(_ACTION >= "vs2017", m.latestSDK10Version(), nil) + end + if min ~= nil then + m.element("WindowsTargetPlatformVersion", nil, min) + end end end @@ -2484,6 +2491,15 @@ return m.conditionFromConfigText(vstudio.projectConfig(cfg)) end +-- +-- Get the latest installed SDK 10 version from the registry. +-- + + function m.latestSDK10Version() + local arch = iif(os.is64bit(), "\\WOW6432Node\\", "\\") + local version = os.getWindowsRegistry("HKLM:SOFTWARE" .. arch .."Microsoft\\Microsoft SDKs\\Windows\\v10.0\\ProductVersion") + return iif(version ~= nil, version .. ".0", nil) + end -- From 3a63d496e665d918555269e2520917e54190f9f8 Mon Sep 17 00:00:00 2001 From: Damien Courtois Date: Wed, 17 Jan 2018 09:13:58 +0100 Subject: [PATCH 2/4] fixed incorrect unit test with systemversion 'latest' --- modules/vstudio/tests/vc2010/test_globals.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/vstudio/tests/vc2010/test_globals.lua b/modules/vstudio/tests/vc2010/test_globals.lua index 4ce7ab1b35..ca2ed9d8d6 100644 --- a/modules/vstudio/tests/vc2010/test_globals.lua +++ b/modules/vstudio/tests/vc2010/test_globals.lua @@ -287,7 +287,7 @@ function suite.windowsTargetPlatformVersionLatest_on2015() p.action.set("vs2015") - systemversion "10.0.10240.0" + systemversion "latest" prepare() test.capture [[ From 7017f09263b51f4f436d9837de1194ca93607afa Mon Sep 17 00:00:00 2001 From: Damien Courtois Date: Thu, 18 Jan 2018 09:20:37 +0100 Subject: [PATCH 3/4] fixed system 'latest' test --- modules/vstudio/tests/vc2010/test_globals.lua | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/modules/vstudio/tests/vc2010/test_globals.lua b/modules/vstudio/tests/vc2010/test_globals.lua index ca2ed9d8d6..48931030e0 100644 --- a/modules/vstudio/tests/vc2010/test_globals.lua +++ b/modules/vstudio/tests/vc2010/test_globals.lua @@ -262,11 +262,10 @@ function suite.windowsTargetPlatformVersionLatest_on2017() p.action.set("vs2017") systemversion "latest" + local oldRegistry = os["getWindowsRegistry"] + os["getWindowsRegistry"] = function (key) return "10.0.11111" end prepare() - local oldRegistry = os.getWindowsRegistry - os.getWindowsRegistry = function (key) - return "10.0.11111" - end + os["getWindowsRegistry"] = oldRegistry test.capture [[ {42B5DBC6-AE1F-903D-F75D-41E363076E92} @@ -276,8 +275,6 @@ 10.0.11111.0 ]] - -- restore the registry function - os.getWindowsRegistry = oldRegistry end -- From 928076a13a3497b4cbc24832daf487affdbe4208 Mon Sep 17 00:00:00 2001 From: Damien Courtois Date: Thu, 18 Jan 2018 11:37:37 +0100 Subject: [PATCH 4/4] fixed a crash in latestSDK10Version when the registry value is not found --- modules/vstudio/vs2010_vcxproj.lua | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/modules/vstudio/vs2010_vcxproj.lua b/modules/vstudio/vs2010_vcxproj.lua index 7d1befa7cf..e4e83685b7 100644 --- a/modules/vstudio/vs2010_vcxproj.lua +++ b/modules/vstudio/vs2010_vcxproj.lua @@ -2498,7 +2498,11 @@ function m.latestSDK10Version() local arch = iif(os.is64bit(), "\\WOW6432Node\\", "\\") local version = os.getWindowsRegistry("HKLM:SOFTWARE" .. arch .."Microsoft\\Microsoft SDKs\\Windows\\v10.0\\ProductVersion") - return iif(version ~= nil, version .. ".0", nil) + if version ~= nil then + return version .. ".0" + else + return nil + end end