From 5059099a5b67ef501020166c8ce274ddfdc4af0e Mon Sep 17 00:00:00 2001 From: Sam Surtees Date: Thu, 17 Mar 2016 22:56:23 +1000 Subject: [PATCH] Added systemversion API. Fixes #315 --- src/_premake_init.lua | 6 ++ src/actions/vstudio/vs2010_vcxproj.lua | 9 +++ src/base/project.lua | 11 ++++ tests/actions/vstudio/vc2010/test_globals.lua | 61 +++++++++++++++++++ 4 files changed, 87 insertions(+) diff --git a/src/_premake_init.lua b/src/_premake_init.lua index 9e90d532..d1424a93 100644 --- a/src/_premake_init.lua +++ b/src/_premake_init.lua @@ -966,6 +966,12 @@ }, } + api.register { + name = "systemversion", + scope = "project", + kind = "string", + } + api.register { name = "targetdir", scope = "config", diff --git a/src/actions/vstudio/vs2010_vcxproj.lua b/src/actions/vstudio/vs2010_vcxproj.lua index c4d42a50..79af4432 100644 --- a/src/actions/vstudio/vs2010_vcxproj.lua +++ b/src/actions/vstudio/vs2010_vcxproj.lua @@ -127,6 +127,7 @@ m.ignoreWarnDuplicateFilename, m.keyword, m.projectName, + m.targetPlatformVersion, } end @@ -1924,6 +1925,14 @@ end + function m.targetPlatformVersion(prj) + local min = project.systemversion(prj) + if min ~= nil and _ACTION >= "vs2015" then + m.element("WindowsTargetPlatformVersion", nil, min) + end + end + + function m.treatLinkerWarningAsErrors(cfg) if cfg.flags.FatalLinkWarnings then local el = iif(cfg.kind == p.STATICLIB, "Lib", "Linker") diff --git a/src/base/project.lua b/src/base/project.lua index a073de50..42b4cd91 100755 --- a/src/base/project.lua +++ b/src/base/project.lua @@ -506,3 +506,14 @@ return pairing end + +-- +-- Given a project, returns requested min and max system versions. +-- + + function project.systemversion(prj) + if prj.systemversion ~= nil then + local values = string.explode(prj.systemversion, ":", true) + return values[1], values[2] + end + end diff --git a/tests/actions/vstudio/vc2010/test_globals.lua b/tests/actions/vstudio/vc2010/test_globals.lua index 56f1a24c..dccee468 100755 --- a/tests/actions/vstudio/vc2010/test_globals.lua +++ b/tests/actions/vstudio/vc2010/test_globals.lua @@ -191,3 +191,64 @@ ]] end + + +-- +-- VS 2015 adds the to allow developers +-- to target different versions of the Windows SDK. +-- + + function suite.windowsTargetPlatformVersionMissing_on2013Default() + _ACTION = "vs2013" + prepare() + test.capture [[ + + {42B5DBC6-AE1F-903D-F75D-41E363076E92} + true + Win32Proj + MyProject + + ]] + end + + function suite.windowsTargetPlatformVersionMissing_on2013() + _ACTION = "vs2013" + systemversion "10.0.10240.0" + prepare() + test.capture [[ + + {42B5DBC6-AE1F-903D-F75D-41E363076E92} + true + Win32Proj + MyProject + + ]] + end + + function suite.windowsTargetPlatformVersionMissing_on2015Default() + _ACTION = "vs2015" + prepare() + test.capture [[ + + {42B5DBC6-AE1F-903D-F75D-41E363076E92} + true + Win32Proj + MyProject + + ]] + end + + function suite.windowsTargetPlatformVersion_on2015() + _ACTION = "vs2015" + systemversion "10.0.10240.0" + prepare() + test.capture [[ + + {42B5DBC6-AE1F-903D-F75D-41E363076E92} + true + Win32Proj + MyProject + 10.0.10240.0 + + ]] + end