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

Fix systemversion("latest") on VS2017 #1424

Merged
merged 1 commit into from
Apr 15, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
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
1 change: 1 addition & 0 deletions modules/android/tests/test_android_project.lua
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
test.capture [[
<PropertyGroup Label="Globals">
<ProjectGuid>{42B5DBC6-AE1F-903D-F75D-41E363076E92}</ProjectGuid>
<LatestTargetPlatformVersion>$([Microsoft.Build.Utilities.ToolLocationHelper]::GetLatestSDKTargetPlatformVersion('Windows', '10.0'))</LatestTargetPlatformVersion>
<Keyword>Android</Keyword>
<RootNamespace>MyProject</RootNamespace>
<MinimumVisualStudioVersion>15.0</MinimumVisualStudioVersion>
Expand Down
68 changes: 35 additions & 33 deletions modules/vstudio/tests/vc2010/test_globals.lua
Original file line number Diff line number Diff line change
Expand Up @@ -254,32 +254,27 @@
]]
end

--
-- Check that the "latest" systemversion works.
-- note: we override the os.getWindowsRegistry method for reliable tests.
--
---
-- Check handling of systemversion("latest")
---

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 [[
function suite.windowsTargetPlatformVersion_latest_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>
<WindowsTargetPlatformVersion>10.0.11111.0</WindowsTargetPlatformVersion>
</PropertyGroup>
]]
end
]]
end

function suite.windowsTargetPlatformVersionLatest_on2019()
p.action.set("vs2019")

function suite.windowsTargetPlatformVersion_latest_on2017()
p.action.set("vs2017")
systemversion "latest"
prepare()
test.capture [[
Expand All @@ -288,18 +283,15 @@
<IgnoreWarnCompileDuplicatedFilename>true</IgnoreWarnCompileDuplicatedFilename>
<Keyword>Win32Proj</Keyword>
<RootNamespace>MyProject</RootNamespace>
<WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>
<LatestTargetPlatformVersion>$([Microsoft.Build.Utilities.ToolLocationHelper]::GetLatestSDKTargetPlatformVersion('Windows', '10.0'))</LatestTargetPlatformVersion>
<WindowsTargetPlatformVersion>$(LatestTargetPlatformVersion)</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")
function suite.windowsTargetPlatformVersion_latest_on2019()
p.action.set("vs2019")
systemversion "latest"
prepare()
test.capture [[
Expand All @@ -308,12 +300,19 @@
<IgnoreWarnCompileDuplicatedFilename>true</IgnoreWarnCompileDuplicatedFilename>
<Keyword>Win32Proj</Keyword>
<RootNamespace>MyProject</RootNamespace>
<WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>
</PropertyGroup>
]]
end

function suite.windowsTargetPlatformVersionMultipleConditional_on2015Default()


---
-- Check handling of per-configuration systemversion
---

function suite.windowsTargetPlatformVersion_perConfig_on2015()
p.action.set("vs2015")
systemversion "8.1"
filter "Debug"
systemversion "10.0.10240.0"
filter "Release"
Expand All @@ -325,6 +324,7 @@
<IgnoreWarnCompileDuplicatedFilename>true</IgnoreWarnCompileDuplicatedFilename>
<Keyword>Win32Proj</Keyword>
<RootNamespace>MyProject</RootNamespace>
<WindowsTargetPlatformVersion>8.1</WindowsTargetPlatformVersion>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Globals">
<WindowsTargetPlatformVersion>10.0.10240.0</WindowsTargetPlatformVersion>
Expand All @@ -334,12 +334,13 @@
</PropertyGroup>
]]
end

function suite.windowsTargetPlatformVersionGlobalMultipleConditional_on2015Default()
p.action.set("vs2015")


function suite.windowsTargetPlatformVersion_perConfig_on2017()
p.action.set("vs2017")
systemversion "8.1"
filter "Debug"
systemversion "10.0.10240.0"
systemversion "latest"
filter "Release"
systemversion "10.0.10240.1"
prepare()
Expand All @@ -349,14 +350,15 @@
<IgnoreWarnCompileDuplicatedFilename>true</IgnoreWarnCompileDuplicatedFilename>
<Keyword>Win32Proj</Keyword>
<RootNamespace>MyProject</RootNamespace>
<LatestTargetPlatformVersion>$([Microsoft.Build.Utilities.ToolLocationHelper]::GetLatestSDKTargetPlatformVersion('Windows', '10.0'))</LatestTargetPlatformVersion>
<WindowsTargetPlatformVersion>8.1</WindowsTargetPlatformVersion>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Globals">
<WindowsTargetPlatformVersion>10.0.10240.0</WindowsTargetPlatformVersion>
<WindowsTargetPlatformVersion>$(LatestTargetPlatformVersion)</WindowsTargetPlatformVersion>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Globals">
<WindowsTargetPlatformVersion>10.0.10240.1</WindowsTargetPlatformVersion>
</PropertyGroup>
]]
end

61 changes: 31 additions & 30 deletions modules/vstudio/vs2010_vcxproj.lua
Original file line number Diff line number Diff line change
Expand Up @@ -131,13 +131,14 @@
m.keyword,
m.projectName,
m.preferredToolArchitecture,
m.targetPlatformVersionGlobal,
m.latestTargetPlatformVersion,
m.windowsTargetPlatformVersion,
}
end

m.elements.globalsCondition = function(prj, cfg)
return {
m.targetPlatformVersionCondition,
m.windowsTargetPlatformVersion,
}
end

Expand Down Expand Up @@ -2580,43 +2581,43 @@
end


function m.targetPlatformVersion(cfgOrPrj)

if _ACTION >= "vs2015" then
local min = project.systemversion(cfgOrPrj)
-- handle special "latest" version
if min == "latest" then
-- vs2015 and lower can't build against SDK 10
-- vs2019 allows for automatic assignment to latest
-- Windows 10 sdk if you set to "10.0"
if _ACTION >= "vs2019" then
min = "10.0"
else
min = iif(_ACTION == "vs2017", m.latestSDK10Version(), nil)
end
end

return min
function m.latestTargetPlatformVersion(prj)
-- See https://developercommunity.visualstudio.com/content/problem/140294/windowstargetplatformversion-makes-it-impossible-t.html
if _ACTION == "vs2017" then
m.element("LatestTargetPlatformVersion", nil, "$([Microsoft.Build.Utilities.ToolLocationHelper]::GetLatestSDKTargetPlatformVersion('Windows', '10.0'))")
end

end


function m.targetPlatformVersionGlobal(prj)
local min = m.targetPlatformVersion(prj)
if min ~= nil then
m.element("WindowsTargetPlatformVersion", nil, min)
function m.windowsTargetPlatformVersion(prj, cfg)
if _ACTION < "vs2015" then
return
end
end

local target = cfg or prj
local version = project.systemversion(target)

function m.targetPlatformVersionCondition(prj, cfg)
-- if this is a config, only emit if different from project
if cfg then
local prjVersion = project.systemversion(prj)
if not prjVersion or version == prjVersion then
return
end
end

local cfgPlatformVersion = m.targetPlatformVersion(cfg)
local prjPlatformVersion = m.targetPlatformVersion(prj)
-- See https://developercommunity.visualstudio.com/content/problem/140294/windowstargetplatformversion-makes-it-impossible-t.html
if version == "latest" then
if _ACTION == "vs2015" then
version = nil -- SDK v10 is not supported by VS2015
elseif _ACTION == "vs2017" then
version = "$(LatestTargetPlatformVersion)"
else
version = "10.0"
end
end

if cfgPlatformVersion ~= nil and cfgPlatformVersion ~= prjPlatformVersion then
m.element("WindowsTargetPlatformVersion", nil, cfgPlatformVersion)
if version then
m.element("WindowsTargetPlatformVersion", nil, version)
end
end

Expand Down