Add architecture support to Visual Studio C# projects
This commit is contained in:
parent
1690d9b968
commit
cba537a825
@ -304,7 +304,7 @@
|
||||
function vstudio.projectPlatform(cfg)
|
||||
local platform = cfg.platform
|
||||
if platform then
|
||||
local pltarch = vstudio.archFromPlatform(cfg.platform)
|
||||
local pltarch = vstudio.archFromPlatform(cfg.platform) or platform
|
||||
local cfgarch = vstudio.archFromConfig(cfg)
|
||||
if pltarch == cfgarch then
|
||||
platform = nil
|
||||
|
@ -24,7 +24,7 @@
|
||||
cs2005.projectsettings(prj)
|
||||
|
||||
for cfg in project.eachconfig(prj) do
|
||||
cs2005.propertygroup(cfg)
|
||||
cs2005.propertyGroup(cfg)
|
||||
cs2005.debugProps(cfg)
|
||||
cs2005.outputProps(cfg)
|
||||
cs2005.compilerProps(cfg)
|
||||
@ -344,8 +344,12 @@
|
||||
-- tackled all the permutations yet.
|
||||
--
|
||||
|
||||
function cs2005.arch(prj)
|
||||
return "AnyCPU"
|
||||
function cs2005.arch(cfg)
|
||||
local arch = vstudio.archFromConfig(cfg)
|
||||
if arch == "Any CPU" then
|
||||
arch = "AnyCPU"
|
||||
end
|
||||
return arch
|
||||
end
|
||||
|
||||
|
||||
@ -353,10 +357,11 @@
|
||||
-- Write the PropertyGroup element for a specific configuration block.
|
||||
--
|
||||
|
||||
function cs2005.propertygroup(cfg)
|
||||
_p(1,'<PropertyGroup Condition=" \'$(Configuration)|$(Platform)\' == \'%s|%s\' ">', premake.esc(cfg.buildcfg), cs2005.arch(cfg))
|
||||
if _ACTION > "vs2008" then
|
||||
_p(2,'<PlatformTarget>%s</PlatformTarget>', cs2005.arch(cfg))
|
||||
function cs2005.propertyGroup(cfg)
|
||||
local arch = cs2005.arch(cfg)
|
||||
_x(1,'<PropertyGroup Condition=" \'$(Configuration)|$(Platform)\' == \'%s|%s\' ">', cfg.buildcfg, arch)
|
||||
if arch ~= "AnyCPU" or _ACTION > "vs2008" then
|
||||
_x(2,'<PlatformTarget>%s</PlatformTarget>', arch)
|
||||
end
|
||||
end
|
||||
|
||||
@ -516,7 +521,7 @@
|
||||
cs2005.projectsettings_old(prj)
|
||||
|
||||
for cfg in premake.eachconfig(prj) do
|
||||
cs2005.propertygroup(cfg)
|
||||
cs2005.propertyGroup(cfg)
|
||||
|
||||
if cfg.flags.Symbols then
|
||||
_p(' <DebugSymbols>true</DebugSymbols>')
|
||||
|
@ -1,58 +0,0 @@
|
||||
--
|
||||
-- tests/actions/vstudio/cs2005/propertygroup.lua
|
||||
-- Validate configuration <PropertyGroup/> elements in Visual Studio 2005+ .csproj
|
||||
-- Copyright (c) 2009-2011 Jason Perkins and the Premake project
|
||||
--
|
||||
|
||||
T.vstudio_cs2005_propertygroup = { }
|
||||
local suite = T.vstudio_cs2005_propertygroup
|
||||
local cs2005 = premake.vstudio.cs2005
|
||||
local project = premake5.project
|
||||
|
||||
--
|
||||
-- Setup
|
||||
--
|
||||
|
||||
local sln, prj, cfg
|
||||
|
||||
function suite.setup()
|
||||
sln, prj = test.createsolution()
|
||||
language "C#"
|
||||
end
|
||||
|
||||
local function prepare()
|
||||
cfg = project.getconfig(prj, "Debug")
|
||||
cs2005.propertygroup(cfg)
|
||||
end
|
||||
|
||||
|
||||
--
|
||||
-- Version Tests
|
||||
--
|
||||
|
||||
function suite.OnVs2005()
|
||||
_ACTION = "vs2005"
|
||||
prepare()
|
||||
test.capture [[
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
]]
|
||||
end
|
||||
|
||||
|
||||
function suite.OnVs2008()
|
||||
_ACTION = "vs2008"
|
||||
prepare()
|
||||
test.capture [[
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
]]
|
||||
end
|
||||
|
||||
|
||||
function suite.OnVs2010()
|
||||
_ACTION = "vs2010"
|
||||
prepare()
|
||||
test.capture [[
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||
]]
|
||||
end
|
92
tests/actions/vstudio/cs2005/test_platform_groups.lua
Normal file
92
tests/actions/vstudio/cs2005/test_platform_groups.lua
Normal file
@ -0,0 +1,92 @@
|
||||
--
|
||||
-- tests/actions/vstudio/cs2005/test_platform_groups.lua
|
||||
-- Check creation of per-platform property groups in VS2005+ C# projects.
|
||||
-- Copyright (c) 2009-2012 Jason Perkins and the Premake project
|
||||
--
|
||||
|
||||
T.vstudio_cs2005_platform_groups = {}
|
||||
local suite = T.vstudio_cs2005_platform_groups
|
||||
local cs2005 = premake.vstudio.cs2005
|
||||
|
||||
--
|
||||
-- Setup
|
||||
--
|
||||
|
||||
local sln, prj, cfg
|
||||
|
||||
function suite.setup()
|
||||
_ACTION = "vs2008"
|
||||
end
|
||||
|
||||
local function prepare(platform)
|
||||
sln = solution ("MySolution")
|
||||
configurations ("Debug")
|
||||
platforms (platform)
|
||||
prj = project ("MyProject")
|
||||
language "C#"
|
||||
cfg = premake5.project.getconfig(prj, "Debug", platform)
|
||||
cs2005.propertyGroup(cfg)
|
||||
end
|
||||
|
||||
|
||||
--
|
||||
-- Check defaults.
|
||||
--
|
||||
|
||||
function suite.vs2008()
|
||||
_ACTION = "vs2008"
|
||||
prepare()
|
||||
test.capture [[
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
]]
|
||||
end
|
||||
|
||||
|
||||
function suite.vs2010()
|
||||
_ACTION = "vs2010"
|
||||
prepare()
|
||||
test.capture [[
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||
]]
|
||||
end
|
||||
|
||||
|
||||
--
|
||||
-- Check handling of specific architectures.
|
||||
--
|
||||
|
||||
function suite.vs2008_onAnyCpu()
|
||||
_ACTION = "vs2008"
|
||||
prepare("Any CPU")
|
||||
test.capture [[
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
]]
|
||||
end
|
||||
|
||||
|
||||
function suite.vs2010_onAnyCpu()
|
||||
_ACTION = "vs2010"
|
||||
prepare("Any CPU")
|
||||
test.capture [[
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||
]]
|
||||
end
|
||||
|
||||
function suite.onX32()
|
||||
prepare("x32")
|
||||
test.capture [[
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' ">
|
||||
<PlatformTarget>x86</PlatformTarget>
|
||||
]]
|
||||
end
|
||||
|
||||
|
||||
function suite.onX64()
|
||||
prepare("x64")
|
||||
test.capture [[
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x64' ">
|
||||
<PlatformTarget>x64</PlatformTarget>
|
||||
]]
|
||||
end
|
@ -548,3 +548,71 @@
|
||||
EndGlobalSection
|
||||
]]
|
||||
end
|
||||
|
||||
|
||||
--
|
||||
-- Check the handling of the "Any CPU" .NET architecture.
|
||||
--
|
||||
|
||||
function suite.onSingleCpp_withAnyCpuPlatform()
|
||||
platforms { "Any CPU" }
|
||||
project "MyProject"
|
||||
prepare()
|
||||
test.capture [[
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
Release|Any CPU = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{C9135098-6047-8142-B10E-D27E7F73FCB3}.Debug|Any CPU.ActiveCfg = Debug Any CPU|Win32
|
||||
{C9135098-6047-8142-B10E-D27E7F73FCB3}.Debug|Any CPU.Build.0 = Debug Any CPU|Win32
|
||||
{C9135098-6047-8142-B10E-D27E7F73FCB3}.Release|Any CPU.ActiveCfg = Release Any CPU|Win32
|
||||
{C9135098-6047-8142-B10E-D27E7F73FCB3}.Release|Any CPU.Build.0 = Release Any CPU|Win32
|
||||
EndGlobalSection
|
||||
]]
|
||||
end
|
||||
|
||||
function suite.onSingleCs_withAnyCpuPlatform()
|
||||
platforms { "Any CPU" }
|
||||
project "MyProject"
|
||||
language "C#"
|
||||
prepare()
|
||||
test.capture [[
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
Release|Any CPU = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{C9135098-6047-8142-B10E-D27E7F73FCB3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{C9135098-6047-8142-B10E-D27E7F73FCB3}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{C9135098-6047-8142-B10E-D27E7F73FCB3}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{C9135098-6047-8142-B10E-D27E7F73FCB3}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
]]
|
||||
end
|
||||
|
||||
function suite.onMixedLanguage_withAnyCpuPlatform()
|
||||
platforms { "Any CPU" }
|
||||
project "MyProject1"
|
||||
language "C#"
|
||||
uuid "52AD9329-0D74-4F66-A213-E649D8CCD737"
|
||||
|
||||
project "MyProject2"
|
||||
prepare()
|
||||
test.capture [[
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
Release|Any CPU = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{52AD9329-0D74-4F66-A213-E649D8CCD737}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{52AD9329-0D74-4F66-A213-E649D8CCD737}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{52AD9329-0D74-4F66-A213-E649D8CCD737}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{52AD9329-0D74-4F66-A213-E649D8CCD737}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{C9135098-6047-8142-B10E-D27E7F73FCB3}.Debug|Any CPU.ActiveCfg = Debug Any CPU|Win32
|
||||
{C9135098-6047-8142-B10E-D27E7F73FCB3}.Debug|Any CPU.Build.0 = Debug Any CPU|Win32
|
||||
{C9135098-6047-8142-B10E-D27E7F73FCB3}.Release|Any CPU.ActiveCfg = Release Any CPU|Win32
|
||||
{C9135098-6047-8142-B10E-D27E7F73FCB3}.Release|Any CPU.Build.0 = Release Any CPU|Win32
|
||||
EndGlobalSection
|
||||
]]
|
||||
end
|
||||
|
@ -94,9 +94,9 @@
|
||||
dofile("actions/vstudio/cs2005/test_files.lua")
|
||||
dofile("actions/vstudio/cs2005/test_output_props.lua")
|
||||
dofile("actions/vstudio/cs2005/projectelement.lua")
|
||||
dofile("actions/vstudio/cs2005/test_platform_groups.lua")
|
||||
dofile("actions/vstudio/cs2005/test_project_refs.lua")
|
||||
dofile("actions/vstudio/cs2005/projectsettings.lua")
|
||||
dofile("actions/vstudio/cs2005/propertygroup.lua")
|
||||
|
||||
-- Visual Studio 2005-2010 solutions
|
||||
dofile("actions/vstudio/sln2005/test_dependencies.lua")
|
||||
|
Reference in New Issue
Block a user