Ported VS2008 .vcproj Platforms and Configuration blocks to new platforms API
This commit is contained in:
parent
8f8a1a989f
commit
2baa0ce3ad
@ -52,8 +52,10 @@
|
||||
--
|
||||
|
||||
function vstudio.architecture(cfg)
|
||||
local architecture = cfg.architecture or "Win32"
|
||||
return architecture
|
||||
if cfg.architecture == "x32" then
|
||||
return "Win32"
|
||||
end
|
||||
return cfg.architecture or "Win32"
|
||||
end
|
||||
|
||||
|
||||
|
@ -10,6 +10,7 @@
|
||||
--
|
||||
|
||||
premake.vstudio.vc200x = { }
|
||||
local vstudio = premake.vstudio
|
||||
local vc200x = premake.vstudio.vc200x
|
||||
local tree = premake.tree
|
||||
|
||||
@ -73,6 +74,40 @@
|
||||
-- Write out the <Configuration> element.
|
||||
--
|
||||
|
||||
function vc200x.configuration(cfg)
|
||||
_p(2,'<Configuration')
|
||||
|
||||
local platform = vstudio.projectplatform(cfg)
|
||||
local architecture = vstudio.architecture(cfg)
|
||||
_p(3,'Name="%s|%s"', premake.esc(platform), premake.esc(architecture))
|
||||
|
||||
_p(3,'OutputDirectory="%s"', premake.esc("."))
|
||||
_p(3,'IntermediateDirectory="%s"', premake.esc("obj\\" .. cfg.buildcfg .. "\\" .. cfg.project.name))
|
||||
|
||||
local cfgtype
|
||||
if (cfg.kind == "SharedLib") then
|
||||
cfgtype = 2
|
||||
elseif (cfg.kind == "StaticLib") then
|
||||
cfgtype = 4
|
||||
else
|
||||
cfgtype = 1
|
||||
end
|
||||
_p(3,'ConfigurationType="%s"', cfgtype)
|
||||
|
||||
if (cfg.flags.MFC) then
|
||||
_p(3, 'UseOfMFC="%d"', iif(cfg.flags.StaticRuntime, 1, 2))
|
||||
end
|
||||
|
||||
_p(3,'CharacterSet="%s"', iif(cfg.flags.Unicode, 1, 2))
|
||||
|
||||
if cfg.flags.Managed then
|
||||
_p(3,'ManagedExtensions="1"')
|
||||
end
|
||||
|
||||
_p(3,'>')
|
||||
end
|
||||
|
||||
-- TODO: REMOVE, OBSOLETE
|
||||
function vc200x.Configuration(name, cfg)
|
||||
_p(2,'<Configuration')
|
||||
_p(3,'Name="%s"', premake.esc(name))
|
||||
@ -180,10 +215,28 @@
|
||||
|
||||
|
||||
--
|
||||
-- Write out the <Platforms> element; ensures that each target platform
|
||||
-- is listed only once. Skips over .NET's pseudo-platforms (like "Any CPU").
|
||||
-- Write out the <Platforms> element, listing each architecture used
|
||||
-- by the project's configurations.
|
||||
--
|
||||
|
||||
function vc200x.platforms(prj)
|
||||
_p(1,'<Platforms>')
|
||||
|
||||
architectures = { }
|
||||
for cfg in premake5.project.eachconfig(prj) do
|
||||
local arch = vstudio.architecture(cfg)
|
||||
if not architectures[arch] then
|
||||
_p(2,'<Platform')
|
||||
_p(3,'Name="%s"', arch)
|
||||
_p(2,'/>')
|
||||
architectures[arch] = true
|
||||
end
|
||||
end
|
||||
|
||||
_p(1,'</Platforms>')
|
||||
end
|
||||
|
||||
-- TODO: REMOVE, OBSOLETE
|
||||
function vc200x.Platforms(prj)
|
||||
local used = { }
|
||||
_p(1,'<Platforms>')
|
||||
@ -805,4 +858,18 @@
|
||||
end
|
||||
|
||||
|
||||
--
|
||||
-- Enumerate the project's configurations.
|
||||
--
|
||||
|
||||
function vc200x.configurations(prj)
|
||||
_p(1,'<Configurations>')
|
||||
for cfg in premake5.project.eachconfig(prj) do
|
||||
-- write the opening <Configuration> element
|
||||
vc200x.configuration(cfg)
|
||||
|
||||
|
||||
_p(2,'</Configuration>')
|
||||
end
|
||||
_p(1,'</Configurations>')
|
||||
end
|
||||
|
@ -235,46 +235,6 @@
|
||||
end
|
||||
|
||||
|
||||
--
|
||||
-- Test multiple platforms
|
||||
--
|
||||
|
||||
function suite.Platforms_OnMultiplePlatforms()
|
||||
platforms { "x32", "x64" }
|
||||
prepare()
|
||||
|
||||
vc200x.generate(prj)
|
||||
local result = io.endcapture()
|
||||
test.istrue(result:find '<Configuration\r\n\t\t\tName="Debug|Win32"\r\n')
|
||||
test.istrue(result:find '<Configuration\r\n\t\t\tName="Release|Win32"\r\n')
|
||||
test.istrue(result:find '<Configuration\r\n\t\t\tName="Debug|x64"\r\n')
|
||||
test.istrue(result:find '<Configuration\r\n\t\t\tName="Release|x64"\r\n')
|
||||
end
|
||||
|
||||
|
||||
|
||||
--
|
||||
-- Test x64 handling
|
||||
--
|
||||
|
||||
function suite.PlatformsList_OnX64()
|
||||
platforms { "Native", "x64" }
|
||||
prepare()
|
||||
vc200x.Platforms(prj)
|
||||
test.capture [[
|
||||
<Platforms>
|
||||
<Platform
|
||||
Name="Win32"
|
||||
/>
|
||||
<Platform
|
||||
Name="x64"
|
||||
/>
|
||||
</Platforms>
|
||||
]]
|
||||
end
|
||||
|
||||
|
||||
|
||||
--
|
||||
-- Test Xbox360 handling
|
||||
--
|
||||
|
74
tests/actions/vstudio/vc200x/test_configuration.lua
Executable file
74
tests/actions/vstudio/vc200x/test_configuration.lua
Executable file
@ -0,0 +1,74 @@
|
||||
--
|
||||
-- tests/actions/vstudio/vc200x/test_configuration.lua
|
||||
-- Test the Visual Studio 2002-2008 project's Configuration block
|
||||
-- Copyright (c) 2009-2012 Jason Perkins and the Premake project
|
||||
--
|
||||
|
||||
T.vstudio_vc200x_configuration = { }
|
||||
local suite = T.vstudio_vc200x_configuration
|
||||
local vc200x = premake.vstudio.vc200x
|
||||
|
||||
|
||||
--
|
||||
-- Setup
|
||||
--
|
||||
|
||||
local sln, prj
|
||||
|
||||
function suite.setup()
|
||||
_ACTION = "vs2008"
|
||||
sln, prj = test.createsolution()
|
||||
end
|
||||
|
||||
local function prepare()
|
||||
local it = premake5.project.eachconfig(prj)
|
||||
local cfg = it()
|
||||
vc200x.configuration(cfg)
|
||||
end
|
||||
|
||||
|
||||
--
|
||||
-- Check the results of generating with the default project settings
|
||||
-- (C++ console application).
|
||||
--
|
||||
|
||||
function suite.defaultSettings()
|
||||
prepare()
|
||||
test.capture [[
|
||||
<Configuration
|
||||
Name="Debug|Win32"
|
||||
OutputDirectory="."
|
||||
IntermediateDirectory="obj\Debug\MyProject"
|
||||
ConfigurationType="1"
|
||||
CharacterSet="2"
|
||||
>
|
||||
]]
|
||||
end
|
||||
|
||||
|
||||
--
|
||||
-- If a platform is specified, it should be included in the platform name.
|
||||
--
|
||||
|
||||
function suite.usesWin32_onX32()
|
||||
platforms { "x32" }
|
||||
prepare()
|
||||
test.capture [[
|
||||
<Configuration
|
||||
Name="Debug x32|Win32"
|
||||
]]
|
||||
end
|
||||
|
||||
|
||||
--
|
||||
-- Check the x64 architecture handling.
|
||||
--
|
||||
|
||||
function suite.usesX64Architecture_onX64Platform()
|
||||
platforms { "x64" }
|
||||
prepare()
|
||||
test.capture [[
|
||||
<Configuration
|
||||
Name="Debug x64|x64"
|
||||
]]
|
||||
end
|
79
tests/actions/vstudio/vc200x/test_platforms.lua
Executable file
79
tests/actions/vstudio/vc200x/test_platforms.lua
Executable file
@ -0,0 +1,79 @@
|
||||
--
|
||||
-- tests/actions/vstudio/vc200x/test_platforms.lua
|
||||
-- Test the Visual Studio 2002-2008 project's Platforms block
|
||||
-- Copyright (c) 2009-2012 Jason Perkins and the Premake project
|
||||
--
|
||||
|
||||
T.vstudio_vc200x_platforms = { }
|
||||
local suite = T.vstudio_vc200x_platforms
|
||||
local vc200x = premake.vstudio.vc200x
|
||||
|
||||
|
||||
--
|
||||
-- Setup
|
||||
--
|
||||
|
||||
local sln, prj
|
||||
|
||||
function suite.setup()
|
||||
_ACTION = "vs2008"
|
||||
sln, prj = test.createsolution()
|
||||
end
|
||||
|
||||
local function prepare()
|
||||
vc200x.platforms(prj)
|
||||
end
|
||||
|
||||
|
||||
--
|
||||
-- If no architectures are specified, Win32 should be the default.
|
||||
--
|
||||
|
||||
function suite.win32Listed_onNoPlatforms()
|
||||
prepare()
|
||||
test.capture [[
|
||||
<Platforms>
|
||||
<Platform
|
||||
Name="Win32"
|
||||
/>
|
||||
</Platforms>
|
||||
]]
|
||||
end
|
||||
|
||||
|
||||
--
|
||||
-- If multiple configurations use the same architecture, it should
|
||||
-- still only be listed once.
|
||||
--
|
||||
|
||||
function suite.architectureListedOnlyOnce_onMultipleConfigurations()
|
||||
platforms { "Static", "Dynamic" }
|
||||
prepare()
|
||||
test.capture [[
|
||||
<Platforms>
|
||||
<Platform
|
||||
Name="Win32"
|
||||
/>
|
||||
</Platforms>
|
||||
]]
|
||||
end
|
||||
|
||||
|
||||
--
|
||||
-- If multiple architectures are used, they should all be listed.
|
||||
--
|
||||
|
||||
function suite.allArchitecturesListed_onMultipleArchitectures()
|
||||
platforms { "x32", "x64" }
|
||||
prepare()
|
||||
test.capture [[
|
||||
<Platforms>
|
||||
<Platform
|
||||
Name="Win32"
|
||||
/>
|
||||
<Platform
|
||||
Name="x64"
|
||||
/>
|
||||
</Platforms>
|
||||
]]
|
||||
end
|
@ -104,10 +104,12 @@
|
||||
dofile("actions/vstudio/vc200x/test_compiler_block.lua")
|
||||
dofile("actions/vstudio/vc200x/debugdir.lua")
|
||||
dofile("actions/vstudio/vc200x/header.lua")
|
||||
dofile("actions/vstudio/vc200x/test_configuration.lua")
|
||||
dofile("actions/vstudio/vc200x/test_files.lua")
|
||||
dofile("actions/vstudio/vc200x/test_filters.lua")
|
||||
dofile("actions/vstudio/vc200x/test_linker_block.lua")
|
||||
dofile("actions/vstudio/vc200x/test_mfc.lua")
|
||||
dofile("actions/vstudio/vc200x/test_platforms.lua")
|
||||
|
||||
-- Visual Studio 2010 C/C++ projects
|
||||
dofile("actions/vstudio/vc2010/test_compile_settings.lua")
|
||||
|
Loading…
Reference in New Issue
Block a user