Added support for setting default platforms and implemented the VS action.

This commit is contained in:
triton 2014-03-18 22:01:59 +00:00
parent b9b3667968
commit dc18aba44a
3 changed files with 40 additions and 1 deletions

View File

@ -173,6 +173,12 @@
},
}
api.register {
name = "defaultplatform",
scope = "project",
kind = "string",
}
api.register {
name = "defines",
scope = "config",

View File

@ -172,9 +172,22 @@
-- Now I can output the sorted list of solution configuration descriptors
-- Visual Studio assumes the first configurations as the defaults.
if sln.defaultplatform then
_p(1,'GlobalSection(SolutionConfigurationPlatforms) = preSolution')
table.foreachi(sorted, function (cfg)
if cfg.platform == sln.defaultplatform then
_p(2,'%s = %s', descriptors[cfg], descriptors[cfg])
end
end)
_p(1,"EndGlobalSection")
end
_p(1,'GlobalSection(SolutionConfigurationPlatforms) = preSolution')
table.foreachi(sorted, function (cfg)
_p(2,'%s = %s', descriptors[cfg], descriptors[cfg])
if not sln.defaultplatform or cfg.platform ~= sln.defaultplatform then
_p(2,'%s = %s', descriptors[cfg], descriptors[cfg])
end
end)
_p(1,"EndGlobalSection")

View File

@ -736,3 +736,23 @@
EndGlobalSection
]]
end
-- Check that when a default platform is specified it is written in a separate
-- configuration block so that Visual Studio picks it up as default.
function suite.onDefaultPlatforms()
platforms { "x32", "x64" }
defaultplatform "x64"
project "MyProject"
prepare()
test.capture [[
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|x64 = Debug|x64
Release|x64 = Release|x64
EndGlobalSection
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Win32 = Debug|Win32
Release|Win32 = Release|Win32
EndGlobalSection
]]
end