Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added a 'latest' systemversion for vs2017 #994

Merged
merged 4 commits into from
Jan 18, 2018
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 45 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,48 @@
</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"
prepare()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

prepare is what will call os.getWindowsRegistry, so you'll need to put this just above the test.capture

local oldRegistry = os.getWindowsRegistry
os.getWindowsRegistry = function (key)
return "10.0.11111"
end
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>
]]
-- restore the registry function
os.getWindowsRegistry = oldRegistry
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 "10.0.10240.0"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this supposed to be latest?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah ! You're totally right ! Is there a way to run specific tests ? (Couldn't run the whole test suite because of some other tests failing before this one)

prepare()
test.capture [[
<PropertyGroup Label="Globals">
<ProjectGuid>{42B5DBC6-AE1F-903D-F75D-41E363076E92}</ProjectGuid>
<IgnoreWarnCompileDuplicatedFilename>true</IgnoreWarnCompileDuplicatedFilename>
<Keyword>Win32Proj</Keyword>
<RootNamespace>MyProject</RootNamespace>
</PropertyGroup>
]]
end
22 changes: 19 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,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)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This took me a little bit to figure out but these tests fail on Linux and macOS because version .. ".0" is being evaluated here. To resolve this issue, you'll need to break this out into a proper if statement.

end


--
Expand Down