Skip to content

Commit

Permalink
Merge pull request #994 from dcourtois/issue_935
Browse files Browse the repository at this point in the history
added a 'latest' systemversion for vs2017
  • Loading branch information
samsinsane authored Jan 18, 2018
2 parents e9dda51 + 928076a commit ae8e3b0
Show file tree
Hide file tree
Showing 2 changed files with 65 additions and 3 deletions.
42 changes: 42 additions & 0 deletions modules/vstudio/tests/vc2010/test_globals.lua
Original file line number Diff line number Diff line change
Expand Up @@ -253,3 +253,45 @@
</PropertyGroup>
]]
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"
local oldRegistry = os["getWindowsRegistry"]
os["getWindowsRegistry"] = function (key) return "10.0.11111" end
prepare()
os["getWindowsRegistry"] = oldRegistry
test.capture [[
<PropertyGroup Label="Globals">
<ProjectGuid>{42B5DBC6-AE1F-903D-F75D-41E363076E92}</ProjectGuid>
<IgnoreWarnCompileDuplicatedFilename>true</IgnoreWarnCompileDuplicatedFilename>
<Keyword>Win32Proj</Keyword>
<RootNamespace>MyProject</RootNamespace>
<WindowsTargetPlatformVersion>10.0.11111.0</WindowsTargetPlatformVersion>
</PropertyGroup>
]]
end

--
-- Check that the "latest" systemversion will not add <WindowsTargetPlatformVersion>
-- when the action is less than 2017
--

function suite.windowsTargetPlatformVersionLatest_on2015()
p.action.set("vs2015")
systemversion "latest"
prepare()
test.capture [[
<PropertyGroup Label="Globals">
<ProjectGuid>{42B5DBC6-AE1F-903D-F75D-41E363076E92}</ProjectGuid>
<IgnoreWarnCompileDuplicatedFilename>true</IgnoreWarnCompileDuplicatedFilename>
<Keyword>Win32Proj</Keyword>
<RootNamespace>MyProject</RootNamespace>
</PropertyGroup>
]]
end
26 changes: 23 additions & 3 deletions modules/vstudio/vs2010_vcxproj.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -2484,6 +2491,19 @@
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")
if version ~= nil then
return version .. ".0"
else
return nil
end
end


--
Expand Down

0 comments on commit ae8e3b0

Please sign in to comment.