[#3100379] C# support for Visual Studio 2010

This commit is contained in:
Jason Perkins 2011-02-16 15:16:07 -05:00
parent a69bcbfb58
commit bb94e9de81
21 changed files with 1040 additions and 817 deletions

View File

@ -2,6 +2,7 @@
4.4 (in progress) 4.4 (in progress)
------- -------
* Feature 3100379: C# support for Visual Studio 2010
* Added support for Haiku OS (Yuriy O'Donnell) * Added support for Haiku OS (Yuriy O'Donnell)
* Patch 2963313: Enable setting .NET framework version (Justen Hyde) * Patch 2963313: Enable setting .NET framework version (Justen Hyde)
* Switched PS3 builds from GCC to SNC * Switched PS3 builds from GCC to SNC

View File

@ -59,7 +59,6 @@
"actions/vstudio/vs2005_solution.lua", "actions/vstudio/vs2005_solution.lua",
"actions/vstudio/vs2005_csproj.lua", "actions/vstudio/vs2005_csproj.lua",
"actions/vstudio/vs2005_csproj_user.lua", "actions/vstudio/vs2005_csproj_user.lua",
"actions/vstudio/vs_generic_solution.lua",
"actions/vstudio/vs2010_vcxproxj.lua", "actions/vstudio/vs2010_vcxproxj.lua",
-- Xcode action -- Xcode action

View File

@ -17,6 +17,7 @@
any = "Any CPU", any = "Any CPU",
mixed = "Mixed Platforms", mixed = "Mixed Platforms",
Native = "Win32", Native = "Win32",
x86 = "x86",
x32 = "Win32", x32 = "Win32",
x64 = "x64", x64 = "x64",
PS3 = "PS3", PS3 = "PS3",
@ -54,16 +55,43 @@
local platforms = premake.filterplatforms(sln, vstudio.platforms, "Native") local platforms = premake.filterplatforms(sln, vstudio.platforms, "Native")
-- .NET projects add "Any CPU", mixed mode solutions add "Mixed Platforms" -- Figure out what's in this solution
local hascpp = premake.hascppproject(sln) local hascpp = premake.hascppproject(sln)
local hasdotnet = premake.hasdotnetproject(sln) local hasdotnet = premake.hasdotnetproject(sln)
if hasdotnet then
-- "Mixed Platform" solutions are generally those containing both
-- C/C++ and .NET projects. Starting in VS2010, all .NET solutions
-- also contain the Mixed Platform option.
if hasdotnet and (_ACTION > "vs2008" or hascpp) then
table.insert(platforms, 1, "mixed")
end
-- "Any CPU" is added to solutions with .NET projects. Starting in
-- VS2010, only pure .NET solutions get this option.
if hasdotnet and (_ACTION < "vs2010" or not hascpp) then
table.insert(platforms, 1, "any") table.insert(platforms, 1, "any")
end end
if hasdotnet and hascpp then
table.insert(platforms, 2, "mixed") -- In Visual Studio 2010, pure .NET solutions replace the Win32 platform
-- with x86. In mixed mode solution, x86 is used in addition to Win32.
if _ACTION > "vs2008" then
local platforms2010 = { }
for _, platform in ipairs(platforms) do
if vstudio.platforms[platform] == "Win32" then
if hascpp then
table.insert(platforms2010, platform)
end
if hasdotnet then
table.insert(platforms2010, "x86")
end
else
table.insert(platforms2010, platform)
end
end
platforms = platforms2010
end end
for _, buildcfg in ipairs(sln.configurations) do for _, buildcfg in ipairs(sln.configurations) do
for _, platform in ipairs(platforms) do for _, platform in ipairs(platforms) do
local entry = { } local entry = { }
@ -141,14 +169,10 @@
function vstudio.projectfile(prj) function vstudio.projectfile(prj)
local extension local extension
if (prj.language == "C#") then if prj.language == "C#" then
extension = ".csproj" extension = ".csproj"
elseif (_ACTION == "vs2010" and prj.language == "C++" )then
extension = ".vcxproj"
elseif (_ACTION == "vs2010" and prj.language == "C" )then
extension = ".vcxproj"
else else
extension = ".vcproj" extension = iif(_ACTION > "vs2008", ".vcxproj", ".vcproj")
end end
local fname = path.join(prj.location, prj.name) local fname = path.join(prj.location, prj.name)
@ -170,7 +194,7 @@
-- --
-- Register the Visual Studio command line actions -- Register Visual Studio 2002
-- --
newaction { newaction {
@ -206,6 +230,11 @@
oncleantarget = premake.vstudio.cleantarget oncleantarget = premake.vstudio.cleantarget
} }
--
-- Register Visual Studio 2002
--
newaction { newaction {
trigger = "vs2003", trigger = "vs2003",
shortname = "Visual Studio 2003", shortname = "Visual Studio 2003",
@ -239,6 +268,11 @@
oncleantarget = premake.vstudio.cleantarget oncleantarget = premake.vstudio.cleantarget
} }
--
-- Register Visual Studio 2002
--
newaction { newaction {
trigger = "vs2005", trigger = "vs2005",
shortname = "Visual Studio 2005", shortname = "Visual Studio 2005",
@ -272,6 +306,11 @@
oncleantarget = vstudio.cleantarget oncleantarget = vstudio.cleantarget
} }
--
-- Register Visual Studio 2002
--
newaction { newaction {
trigger = "vs2008", trigger = "vs2008",
shortname = "Visual Studio 2008", shortname = "Visual Studio 2008",
@ -306,30 +345,39 @@
} }
--
-- Register Visual Studio 2002
--
newaction newaction
{ {
trigger = "vs2010", trigger = "vs2010",
shortname = "Visual Studio 2010", shortname = "Visual Studio 2010",
description = "Generate Visual Studio 2010 project files (experimental)", description = "Generate Visual Studio 2010 project files",
os = "windows", os = "windows",
valid_kinds = { "ConsoleApp", "WindowedApp", "StaticLib", "SharedLib" }, valid_kinds = { "ConsoleApp", "WindowedApp", "StaticLib", "SharedLib" },
valid_languages = { "C++","C"}, valid_languages = { "C", "C++", "C#"},
valid_tools = { valid_tools = {
cc = { "msc" }, cc = { "msc" },
--dotnet = { "msnet" }, dotnet = { "msnet" },
}, },
onsolution = function(sln) onsolution = function(sln)
premake.generate(sln, "%%.sln", premake.vs_generic_solution) premake.generate(sln, "%%.sln", vstudio.sln2005.generate)
end, end,
onproject = function(prj) onproject = function(prj)
if premake.isdotnetproject(prj) then
premake.generate(prj, "%%.csproj", vstudio.cs2005.generate)
premake.generate(prj, "%%.csproj.user", vstudio.cs2005.generate_user)
else
premake.generate(prj, "%%.vcxproj", premake.vs2010_vcxproj) premake.generate(prj, "%%.vcxproj", premake.vs2010_vcxproj)
premake.generate(prj, "%%.vcxproj.user", premake.vs2010_vcxproj_user) premake.generate(prj, "%%.vcxproj.user", premake.vs2010_vcxproj_user)
premake.generate(prj, "%%.vcxproj.filters", premake.vs2010_vcxproj_filters) premake.generate(prj, "%%.vcxproj.filters", premake.vs2010_vcxproj_filters)
end
end, end,

View File

@ -1,7 +1,7 @@
-- --
-- vs2005_csproj.lua -- vs2005_csproj.lua
-- Generate a Visual Studio 2005/2008 C# project. -- Generate a Visual Studio 2005/2008 C# project.
-- Copyright (c) 2009-2010 Jason Perkins and the Premake project -- Copyright (c) 2009-2011 Jason Perkins and the Premake project
-- --
-- --
@ -70,11 +70,22 @@
end end
--
-- Return the Visual Studio architecture identification string. The logic
-- to select this is getting more complicated in VS2010, but I haven't
-- tackled all the permutations yet.
--
function cs2005.arch(prj)
return "AnyCPU"
end
-- --
-- Write out the <Files> element. -- Write out the <Files> element.
-- --
function cs2005.Files(prj) function cs2005.files(prj)
local tr = premake.project.buildsourcetree(prj) local tr = premake.project.buildsourcetree(prj)
premake.tree.traverse(tr, { premake.tree.traverse(tr, {
onleaf = function(node) onleaf = function(node)
@ -110,31 +121,71 @@
-- --
-- Write the opening <Project> element and project level <PropertyGroup> block. -- Write the opening <Project> element.
-- --
function cs2005.projectelement(prj) function cs2005.projectelement(prj)
_p('<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"%s>', iif(_ACTION == 'vs2005', '', ' ToolsVersion="3.5"')) local toolversion = {
vs2005 = '',
vs2008 = ' ToolsVersion="3.5"',
vs2010 = ' ToolsVersion="4.0"',
}
if _ACTION > "vs2008" then
_p('<?xml version="1.0" encoding="utf-8"?>')
end
_p('<Project%s DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">', toolversion[_ACTION])
end end
--
-- Write the opening PropertyGroup, which contains the project-level settings.
--
function cs2005.projectsettings(prj) function cs2005.projectsettings(prj)
local version = {
vs2005 = '8.0.50727',
vs2008 = '9.0.21022',
vs2010 = '8.0.30703',
}
_p(' <PropertyGroup>') _p(' <PropertyGroup>')
_p(' <Configuration Condition=" \'$(Configuration)\' == \'\' ">%s</Configuration>', premake.esc(prj.solution.configurations[1])) _p(' <Configuration Condition=" \'$(Configuration)\' == \'\' ">%s</Configuration>', premake.esc(prj.solution.configurations[1]))
_p(' <Platform Condition=" \'$(Platform)\' == \'\' ">AnyCPU</Platform>') _p(' <Platform Condition=" \'$(Platform)\' == \'\' ">%s</Platform>', cs2005.arch(prj))
_p(' <ProductVersion>%s</ProductVersion>', iif(_ACTION == "vs2005", "8.0.50727", "9.0.21022")) _p(' <ProductVersion>%s</ProductVersion>', version[_ACTION])
_p(' <SchemaVersion>2.0</SchemaVersion>') _p(' <SchemaVersion>2.0</SchemaVersion>')
_p(' <ProjectGuid>{%s}</ProjectGuid>', prj.uuid) _p(' <ProjectGuid>{%s}</ProjectGuid>', prj.uuid)
_p(' <OutputType>%s</OutputType>', premake.dotnet.getkind(prj)) _p(' <OutputType>%s</OutputType>', premake.dotnet.getkind(prj))
_p(' <AppDesignerFolder>Properties</AppDesignerFolder>') _p(' <AppDesignerFolder>Properties</AppDesignerFolder>')
_p(' <RootNamespace>%s</RootNamespace>', prj.buildtarget.basename) _p(' <RootNamespace>%s</RootNamespace>', prj.buildtarget.basename)
_p(' <AssemblyName>%s</AssemblyName>', prj.buildtarget.basename) _p(' <AssemblyName>%s</AssemblyName>', prj.buildtarget.basename)
if prj.framework then
_p(' <TargetFrameworkVersion>v%s</TargetFrameworkVersion>', prj.framework) local framework = prj.framework or iif(_ACTION == "vs2010", "4.0", nil)
if framework then
_p(' <TargetFrameworkVersion>v%s</TargetFrameworkVersion>', framework)
end end
if _ACTION == "vs2010" then
_p(' <TargetFrameworkProfile>Client</TargetFrameworkProfile>')
_p(' <FileAlignment>512</FileAlignment>')
end
_p(' </PropertyGroup>') _p(' </PropertyGroup>')
end end
--
-- Write the PropertyGroup element for a specific configuration block.
--
function cs2005.propertygroup(cfg)
_p(' <PropertyGroup Condition=" \'$(Configuration)|$(Platform)\' == \'%s|%s\' ">', premake.esc(cfg.name), cs2005.arch(cfg))
if _ACTION > "vs2008" then
_p(' <PlatformTarget>%s</PlatformTarget>', cs2005.arch(cfg))
end
end
-- --
-- The main function: write the project file. -- The main function: write the project file.
-- --
@ -142,35 +193,12 @@
function cs2005.generate(prj) function cs2005.generate(prj)
io.eol = "\r\n" io.eol = "\r\n"
local vsversion, toolversion cs2005.projectelement(prj)
if _ACTION == "vs2005" then cs2005.projectsettings(prj)
vsversion = "8.0.50727"
toolversion = nil
elseif _ACTION == "vs2008" then
vsversion = "9.0.21022"
toolversion = "3.5"
end
if toolversion then
_p('<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="%s">', toolversion)
else
_p('<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">')
end
_p(' <PropertyGroup>')
_p(' <Configuration Condition=" \'$(Configuration)\' == \'\' ">%s</Configuration>', premake.esc(prj.solution.configurations[1]))
_p(' <Platform Condition=" \'$(Platform)\' == \'\' ">AnyCPU</Platform>')
_p(' <ProductVersion>%s</ProductVersion>', vsversion)
_p(' <SchemaVersion>2.0</SchemaVersion>')
_p(' <ProjectGuid>{%s}</ProjectGuid>', prj.uuid)
_p(' <OutputType>%s</OutputType>', premake.dotnet.getkind(prj))
_p(' <AppDesignerFolder>Properties</AppDesignerFolder>')
_p(' <RootNamespace>%s</RootNamespace>', prj.buildtarget.basename)
_p(' <AssemblyName>%s</AssemblyName>', prj.buildtarget.basename)
_p(' </PropertyGroup>')
for cfg in premake.eachconfig(prj) do for cfg in premake.eachconfig(prj) do
_p(' <PropertyGroup Condition=" \'$(Configuration)|$(Platform)\' == \'%s|AnyCPU\' ">', premake.esc(cfg.name)) cs2005.propertygroup(cfg)
if cfg.flags.Symbols then if cfg.flags.Symbols then
_p(' <DebugSymbols>true</DebugSymbols>') _p(' <DebugSymbols>true</DebugSymbols>')
_p(' <DebugType>full</DebugType>') _p(' <DebugType>full</DebugType>')
@ -204,7 +232,7 @@
_p(' </ItemGroup>') _p(' </ItemGroup>')
_p(' <ItemGroup>') _p(' <ItemGroup>')
cs2005.Files(prj) cs2005.files(prj)
_p(' </ItemGroup>') _p(' </ItemGroup>')
_p(' <Import Project="$(MSBuildBinPath)\\Microsoft.CSharp.targets" />') _p(' <Import Project="$(MSBuildBinPath)\\Microsoft.CSharp.targets" />')

View File

@ -1,6 +1,6 @@
-- --
-- vs2005_solution.lua -- vs2005_solution.lua
-- Generate a Visual Studio 2005 or 2008 solution. -- Generate a Visual Studio 2005-2010 solution.
-- Copyright (c) 2009-2011 Jason Perkins and the Premake project -- Copyright (c) 2009-2011 Jason Perkins and the Premake project
-- --
@ -8,6 +8,7 @@
local vstudio = premake.vstudio local vstudio = premake.vstudio
local sln2005 = premake.vstudio.sln2005 local sln2005 = premake.vstudio.sln2005
function sln2005.generate(sln) function sln2005.generate(sln)
io.eol = '\r\n' io.eol = '\r\n'
@ -17,25 +18,10 @@
-- Mark the file as Unicode -- Mark the file as Unicode
_p('\239\187\191') _p('\239\187\191')
-- Write the solution file version header sln2005.header(sln)
_p('Microsoft Visual Studio Solution File, Format Version %s', iif(_ACTION == 'vs2005', '9.00', '10.00'))
_p('# Visual Studio %s', iif(_ACTION == 'vs2005', '2005', '2008'))
-- Write out the list of project entries
for prj in premake.solution.eachproject(sln) do for prj in premake.solution.eachproject(sln) do
-- Build a relative path from the solution file to the project file sln2005.project(prj)
local projpath = path.translate(path.getrelative(sln.location, vstudio.projectfile(prj)), "\\")
_p('Project("{%s}") = "%s", "%s", "{%s}"', vstudio.tool(prj), prj.name, projpath, prj.uuid)
local deps = premake.getdependencies(prj)
if #deps > 0 then
_p('\tProjectSection(ProjectDependencies) = postProject')
for _, dep in ipairs(deps) do
_p('\t\t{%s} = {%s}', dep.uuid, dep.uuid)
end
_p('\tEndProjectSection')
end
_p('EndProject')
end end
_p('Global') _p('Global')
@ -46,6 +32,54 @@
end end
--
-- Generate the solution header
--
function sln2005.header(sln)
local version = {
vs2005 = 9,
vs2008 = 10,
vs2010 = 11
}
_p('Microsoft Visual Studio Solution File, Format Version %d.00', version[_ACTION])
_p('# Visual Studio %s', _ACTION:sub(3))
end
--
-- Write out an entry for a project
--
function sln2005.project(prj)
-- Build a relative path from the solution file to the project file
local projpath = path.translate(path.getrelative(prj.solution.location, vstudio.projectfile(prj)), "\\")
_p('Project("{%s}") = "%s", "%s", "{%s}"', vstudio.tool(prj), prj.name, projpath, prj.uuid)
sln2005.projectdependencies(prj)
_p('EndProject')
end
--
-- Write out the list of project dependencies for a particular project.
--
function sln2005.projectdependencies(prj)
-- VS2010 C# gets dependencies right from the projects; doesn't need rules here
if _ACTION > "vs2008" and prj.language == "C#" then return end
local deps = premake.getdependencies(prj)
if #deps > 0 then
_p('\tProjectSection(ProjectDependencies) = postProject')
for _, dep in ipairs(deps) do
_p('\t\t{%s} = {%s}', dep.uuid, dep.uuid)
end
_p('\tEndProjectSection')
end
end
-- --
-- Write out the contents of the SolutionConfigurationPlatforms section, which -- Write out the contents of the SolutionConfigurationPlatforms section, which

View File

@ -1,6 +1,11 @@
--
-- vs200x_vcproj.lua
-- Generate a Visual Studio 2002-2008 C/C++ project.
-- Copyright (c) 2009-2011 Liam Devine and the Premake project
--
premake.vstudio.vc2010 = { } premake.vstudio.vc2010 = { }
local vc2010 = premake.vstudio.vc2010 local vc2010 = premake.vstudio.vc2010
function vc2010.remove_relative_path(file) function vc2010.remove_relative_path(file)

View File

@ -1,68 +0,0 @@
local vstudio = premake.vstudio
local vs_format_version = function()
local t =
{
vs2005 = '9.00',
vs2008 = '10.00',
vs2010 = '11.00'
}
return t[_ACTION]
end
local vs_version = function()
local t =
{
vs2005 = '2005',
vs2008 = '2008',
vs2010 = '2010'
}
return t[_ACTION]
end
local vs_write_version_info = function()
_p('Microsoft Visual Studio Solution File, Format Version %s', vs_format_version())
_p('# Visual Studio %s', vs_version() )
end
local vs_write_projects = function(sln)
-- Write out the list of project entries
for prj in premake.solution.eachproject(sln) do
-- Build a relative path from the solution file to the project file
local projpath = path.translate(path.getrelative(sln.location, vstudio.projectfile(prj)), "\\")
_p('Project("{%s}") = "%s", "%s", "{%s}"', vstudio.tool(prj), prj.name, projpath, prj.uuid)
local deps = premake.getdependencies(prj)
if #deps > 0 then
_p('\tProjectSection(ProjectDependencies) = postProject')
for _, dep in ipairs(deps) do
_p('\t\t{%s} = {%s}', dep.uuid, dep.uuid)
end
_p('\tEndProjectSection')
end
_p('EndProject')
end
end
local vs_write_pre_version = function(sln)
io.eol = '\r\n'
sln.vstudio_configs = premake.vstudio.buildconfigs(sln)
-- Mark the file as Unicode
_p('\239\187\191')
end
function premake.vs_generic_solution(sln)
vs_write_pre_version(sln)
vs_write_version_info()
vs_write_projects(sln)
_p('Global')
vstudio.sln2005.platforms(sln)
vstudio.sln2005.project_platforms(sln)
vstudio.sln2005.properties(sln)
_p('EndGlobal')
end

View File

@ -648,8 +648,6 @@
end end
if((not bIsStaticLib) and prjEntry.proj) then if((not bIsStaticLib) and prjEntry.proj) then
printf("Adding direct link to project '%s' from project '%s'",
prjEntry.proj.name, getCfgKind(cfg));
table.insert(cfg.links, prjEntry.proj.name); table.insert(cfg.links, prjEntry.proj.name);
end end
end end
@ -695,15 +693,8 @@
for prjIx, prj in ipairs(sln.projects) do for prjIx, prj in ipairs(sln.projects) do
if(not prj.usage) then if(not prj.usage) then
for cfgname, cfg in pairs(prj.__configs) do for cfgname, cfg in pairs(prj.__configs) do
for _, linkName in ipairs(cfg.links) do
printf("\t link to '%s'.", linkName)
end
local usesPrjs = getprojectsconnections(cfg, cfgname); local usesPrjs = getprojectsconnections(cfg, cfgname);
copyusagedata(cfg, cfgname, usesPrjs) copyusagedata(cfg, cfgname, usesPrjs)
for _, linkName in ipairs(cfg.links) do
printf("link to '%s'", linkName)
end
end end
end end
end end

View File

@ -23,7 +23,7 @@
premake.buildconfigs() premake.buildconfigs()
prj = premake.solution.getproject(sln, 1) prj = premake.solution.getproject(sln, 1)
sln.vstudio_configs = premake.vstudio.buildconfigs(sln) sln.vstudio_configs = premake.vstudio.buildconfigs(sln)
cs2005.Files(prj) cs2005.files(prj)
end end

View File

@ -0,0 +1,56 @@
--
-- tests/actions/vstudio/cs2005/projectelement.lua
-- Validate generation of <Project/> element in Visual Studio 2005+ .csproj
-- Copyright (c) 2009-2011 Jason Perkins and the Premake project
--
T.vstudio_cs2005_projectelement = { }
local suite = T.vstudio_cs2005_projectelement
local cs2005 = premake.vstudio.cs2005
--
-- Setup
--
local sln, prj
function suite.setup()
sln = test.createsolution()
end
local function prepare()
premake.buildconfigs()
prj = premake.solution.getproject(sln, 1)
cs2005.projectelement(prj)
end
--
-- Tests
--
function suite.On2005()
_ACTION = "vs2005"
prepare()
test.capture [[
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
]]
end
function suite.On2008()
_ACTION = "vs2008"
prepare()
test.capture [[
<Project ToolsVersion="3.5" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
]]
end
function suite.On2010()
_ACTION = "vs2010"
prepare()
test.capture [[
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
]]
end

View File

@ -1,68 +1,40 @@
-- --
-- tests/actions/test_vs2005_csproj.lua -- tests/actions/vstudio/cs2005/projectsettings.lua
-- Automated test suite for Visual Studio 2005-2008 C# project generation. -- Validate generation of root <PropertyGroup/> in Visual Studio 2005+ .csproj
-- Copyright (c) 2010 Jason Perkins and the Premake project -- Copyright (c) 2009-2011 Jason Perkins and the Premake project
-- --
T.vs2005_csproj = { } T.vstudio_cs2005_projectsettings = { }
local suite = T.vs2005_csproj local suite = T.vstudio_cs2005_projectsettings
local cs2005 = premake.vstudio.cs2005 local cs2005 = premake.vstudio.cs2005
-- --
-- Configure a solution for testing -- Setup
-- --
local sln, prj local sln, prj
function suite.setup() function suite.setup()
_ACTION = "vs2005" sln = test.createsolution()
language "C#"
sln = solution "MySolution" uuid "AE61726D-187C-E440-BD07-2556188A6565"
configurations { "Debug", "Release" }
platforms {}
project "MyProject"
language "C#"
kind "ConsoleApp"
uuid "AE61726D-187C-E440-BD07-2556188A6565"
end end
local function prepare() local function prepare()
premake.buildconfigs() premake.buildconfigs()
prj = premake.solution.getproject(sln, 1) prj = premake.solution.getproject(sln, 1)
end
--
-- Project element tests
--
function suite.projectelement_OnVs2005()
_ACTION = "vs2005"
prepare()
cs2005.projectelement(prj)
test.capture [[
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
]]
end
function suite.projectelement_OnVs2008()
_ACTION = "vs2008"
prepare()
cs2005.projectelement(prj)
test.capture [[
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="3.5">
]]
end
--
-- Project settings tests
--
function suite.projectsettings_OnVs2005()
_ACTION = "vs2005"
prepare()
cs2005.projectsettings(prj) cs2005.projectsettings(prj)
end
--
-- Version Tests
--
function suite.OnVs2005()
_ACTION = "vs2005"
prepare()
test.capture [[ test.capture [[
<PropertyGroup> <PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
@ -79,10 +51,9 @@
end end
function suite.projectsettings_OnVs2008() function suite.OnVs2008()
_ACTION = "vs2008" _ACTION = "vs2008"
prepare() prepare()
cs2005.projectsettings(prj)
test.capture [[ test.capture [[
<PropertyGroup> <PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
@ -99,11 +70,37 @@
end end
function suite.projectsettings_OnFrameworkVersion() function suite.OnVs2010()
_ACTION = "vs2010"
prepare()
test.capture [[
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProductVersion>8.0.30703</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{AE61726D-187C-E440-BD07-2556188A6565}</ProjectGuid>
<OutputType>Exe</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>MyProject</RootNamespace>
<AssemblyName>MyProject</AssemblyName>
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
<TargetFrameworkProfile>Client</TargetFrameworkProfile>
<FileAlignment>512</FileAlignment>
</PropertyGroup>
]]
end
--
-- Framework Tests
--
function suite.OnFrameworkVersion()
_ACTION = "vs2005" _ACTION = "vs2005"
framework "3.0" framework "3.0"
prepare() prepare()
cs2005.projectsettings(prj)
test.capture [[ test.capture [[
<PropertyGroup> <PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
@ -119,3 +116,5 @@
</PropertyGroup> </PropertyGroup>
]] ]]
end end

View File

@ -0,0 +1,59 @@
--
-- 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
--
-- Setup
--
local sln, prj, cfg
function suite.setup()
sln = test.createsolution()
language "C#"
end
local function prepare()
premake.buildconfigs()
prj = premake.solution.getproject(sln, 1)
cfg = premake.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' ">
]]
end

View File

@ -0,0 +1,67 @@
--
-- tests/actions/vstudio/sln2005/dependencies.lua
-- Validate generation of Visual Studio 2005+ solution project dependencies.
-- Copyright (c) 2009-2011 Jason Perkins and the Premake project
--
T.vstudio_sln2005_dependencies = { }
local suite = T.vstudio_sln2005_dependencies
local sln2005 = premake.vstudio.sln2005
--
-- Setup
--
local sln, prj1, prj2
function suite.setup()
_ACTION = "vs2005"
sln, prj1 = test.createsolution()
uuid "AE61726D-187C-E440-BD07-2556188A6565"
prj2 = test.createproject(sln)
uuid "2151E83B-997F-4A9D-955D-380157E88C31"
links "MyProject"
end
local function prepare(language)
prj1.language = language
prj2.language = language
premake.buildconfigs()
prj1 = premake.solution.getproject(sln, 1)
prj2 = premake.solution.getproject(sln, 2)
sln2005.projectdependencies(prj2)
end
--
-- Tests
--
function suite.On2005_Cpp()
prepare("C++")
test.capture [[
ProjectSection(ProjectDependencies) = postProject
{AE61726D-187C-E440-BD07-2556188A6565} = {AE61726D-187C-E440-BD07-2556188A6565}
EndProjectSection
]]
end
function suite.On2005_Cs()
prepare("C#")
test.capture [[
ProjectSection(ProjectDependencies) = postProject
{AE61726D-187C-E440-BD07-2556188A6565} = {AE61726D-187C-E440-BD07-2556188A6565}
EndProjectSection
]]
end
function suite.On2010_Cs()
-- 2010 C# gets rules from the projects rather than the solution
_ACTION = "vs2010"
prepare("C#")
local actual = io.endcapture()
test.istrue(actual:len() == 0)
end

View File

@ -0,0 +1,59 @@
--
-- tests/actions/vstudio/sln2005/header.lua
-- Validate generation of Visual Studio 2005+ solution header.
-- Copyright (c) 2009-2011 Jason Perkins and the Premake project
--
T.vstudio_sln2005_header = { }
local suite = T.vstudio_sln2005_header
local sln2005 = premake.vstudio.sln2005
--
-- Setup
--
local sln, prj
function suite.setup()
sln = test.createsolution()
end
local function prepare()
premake.buildconfigs()
sln2005.header()
end
--
-- Tests
--
function suite.On2005()
_ACTION = "vs2005"
prepare()
test.capture [[
Microsoft Visual Studio Solution File, Format Version 9.00
# Visual Studio 2005
]]
end
function suite.On2008()
_ACTION = "vs2008"
prepare()
test.capture [[
Microsoft Visual Studio Solution File, Format Version 10.00
# Visual Studio 2008
]]
end
function suite.On2010()
_ACTION = "vs2010"
prepare()
test.capture [[
Microsoft Visual Studio Solution File, Format Version 11.00
# Visual Studio 2010
]]
end

View File

@ -1,45 +1,35 @@
-- --
-- tests/test_vs2008_sln.lua -- tests/actions/vstudio/sln2005/layout.lua
-- Automated test suite for Visual Studio 2008 solution generation. -- Validate the overall layout of VS 2005-2010 solutions.
-- Copyright (c) 2009 Jason Perkins and the Premake project -- Copyright (c) 2009-2011 Jason Perkins and the Premake project
-- --
T.vs2008_sln = { } T.vstudio_sln2005_layout = { }
local suite = T.vs2008_sln local suite = T.vstudio_sln2005_layout
local sln2005 = premake.vstudio.sln2005 local sln2005 = premake.vstudio.sln2005
--
-- Configure a solution for testing
--
local sln local sln
function suite.setup() function suite.setup()
_ACTION = "vs2008" _ACTION = "vs2005"
sln = test.createsolution()
sln = solution "MySolution"
configurations { "Debug", "Release" }
platforms {}
prj = project "MyProject"
language "C++"
kind "ConsoleApp"
uuid "AE61726D-187C-E440-BD07-2556188A6565" uuid "AE61726D-187C-E440-BD07-2556188A6565"
end
local function prepare()
premake.buildconfigs() premake.buildconfigs()
sln.vstudio_configs = premake.vstudio.buildconfigs(sln)
sln2005.generate(sln)
end end
--
-- Make sure I've got the basic layout correct
--
function suite.BasicLayout() function suite.BasicLayout()
sln2005.generate(sln) prepare()
test.capture ('\239\187\191' .. [[ test.capture ('\239\187\191' .. [[
Microsoft Visual Studio Solution File, Format Version 10.00 Microsoft Visual Studio Solution File, Format Version 9.00
# Visual Studio 2008 # Visual Studio 2005
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "MyProject", "MyProject.vcproj", "{AE61726D-187C-E440-BD07-2556188A6565}" Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "MyProject", "MyProject.vcproj", "{AE61726D-187C-E440-BD07-2556188A6565}"
EndProject EndProject
Global Global

View File

@ -0,0 +1,135 @@
--
-- tests/actions/vstudio/sln2005/platforms.lua
-- Validate generation of Visual Studio 2005+ SolutionConfigurationPlatforms block.
-- Copyright (c) 2009-2011 Jason Perkins and the Premake project
--
T.vstudio_sln2005_platforms = { }
local suite = T.vstudio_sln2005_platforms
local sln2005 = premake.vstudio.sln2005
--
-- Setup
--
local sln, prj
function suite.setup()
sln, prj = test.createsolution()
end
local function prepare(language)
prj.language = language
premake.buildconfigs()
sln.vstudio_configs = premake.vstudio.buildconfigs(sln)
sln2005.platforms(sln)
end
--
-- C/C++ Tests
--
function suite.On2005_Cpp()
_ACTION = "vs2005"
prepare("C++")
test.capture [[
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Win32 = Debug|Win32
Release|Win32 = Release|Win32
EndGlobalSection
]]
end
--
-- C# Tests
--
function suite.On2005_Cs()
_ACTION = "vs2005"
prepare("C#")
test.capture [[
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Debug|Win32 = Debug|Win32
Release|Any CPU = Release|Any CPU
Release|Win32 = Release|Win32
EndGlobalSection
]]
end
function suite.On2010_Cs()
_ACTION = "vs2010"
prepare("C#")
test.capture [[
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Debug|Mixed Platforms = Debug|Mixed Platforms
Debug|x86 = Debug|x86
Release|Any CPU = Release|Any CPU
Release|Mixed Platforms = Release|Mixed Platforms
Release|x86 = Release|x86
EndGlobalSection
]]
end
--
-- Mixed language tests
--
function suite.On2005_MixedLanguages()
_ACTION = "vs2005"
test.createproject(sln)
prepare("C#")
test.capture [[
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Debug|Mixed Platforms = Debug|Mixed Platforms
Debug|Win32 = Debug|Win32
Release|Any CPU = Release|Any CPU
Release|Mixed Platforms = Release|Mixed Platforms
Release|Win32 = Release|Win32
EndGlobalSection
]]
end
function suite.On2010_MixedLanguages()
_ACTION = "vs2010"
test.createproject(sln)
prepare("C#")
test.capture [[
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Mixed Platforms = Debug|Mixed Platforms
Debug|Win32 = Debug|Win32
Debug|x86 = Debug|x86
Release|Mixed Platforms = Release|Mixed Platforms
Release|Win32 = Release|Win32
Release|x86 = Release|x86
EndGlobalSection
]]
end
--
-- Test multiple platforms
--
function suite.On2005_MixedPlatforms()
_ACTION = "vs2005"
platforms { "x32", "x64" }
prepare("C++")
test.capture [[
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Win32 = Debug|Win32
Debug|x64 = Debug|x64
Release|Win32 = Release|Win32
Release|x64 = Release|x64
EndGlobalSection
]]
end

View File

@ -1,118 +1,40 @@
-- --
-- tests/test_vs2005_sln.lua -- tests/actions/vstudio/sln2005/projectplatforms.lua
-- Automated test suite for Visual Studio 2005 solution generation. -- Validate generation of Visual Studio 2005+ ProjectConfigurationPlatforms block.
-- Copyright (c) 2009 Jason Perkins and the Premake project -- Copyright (c) 2009-2011 Jason Perkins and the Premake project
-- --
T.vs2005_sln = { } T.vstudio_sln2005_projectplatforms = { }
local suite = T.vs2005_sln local suite = T.vstudio_sln2005_projectplatforms
local sln2005 = premake.vstudio.sln2005 local sln2005 = premake.vstudio.sln2005
-- --
-- Configure a solution for testing -- Setup
-- --
local sln local sln, prj
function suite.setup() function suite.setup()
sln = solution "MySolution" sln, prj = test.createsolution()
configurations { "Debug", "Release" }
platforms {}
project "MyProject"
language "C++"
kind "ConsoleApp"
uuid "AE61726D-187C-E440-BD07-2556188A6565"
_ACTION = 'vs2005'
end
local function prepare()
premake.buildconfigs()
sln.vstudio_configs = premake.vstudio.buildconfigs(sln)
end
local function addnetproject()
project "MyNetProject"
language "C#"
kind "ConsoleApp"
uuid "C9135098-6047-8142-B10E-D27E7F73FCB3" uuid "C9135098-6047-8142-B10E-D27E7F73FCB3"
end end
local function prepare(language)
prj.language = language
premake.buildconfigs()
-- sln.vstudio_configs = premake.vstudio.buildconfigs(sln)
-- Make sure I've got the basic layout correct
--
function suite.BasicLayout()
prepare()
sln2005.generate(sln)
test.capture ('\239\187\191' .. [[
Microsoft Visual Studio Solution File, Format Version 9.00
# Visual Studio 2005
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "MyProject", "MyProject.vcproj", "{AE61726D-187C-E440-BD07-2556188A6565}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Win32 = Debug|Win32
Release|Win32 = Release|Win32
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{AE61726D-187C-E440-BD07-2556188A6565}.Debug|Win32.ActiveCfg = Debug|Win32
{AE61726D-187C-E440-BD07-2556188A6565}.Debug|Win32.Build.0 = Debug|Win32
{AE61726D-187C-E440-BD07-2556188A6565}.Release|Win32.ActiveCfg = Release|Win32
{AE61726D-187C-E440-BD07-2556188A6565}.Release|Win32.Build.0 = Release|Win32
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal
]])
end
--
-- Test a mixed runtime (C++/.NET) solution.
--
function suite.SolutionPlatforms_OnMixedModes()
addnetproject()
prepare()
sln2005.platforms(sln)
test.capture [[
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Debug|Mixed Platforms = Debug|Mixed Platforms
Debug|Win32 = Debug|Win32
Release|Any CPU = Release|Any CPU
Release|Mixed Platforms = Release|Mixed Platforms
Release|Win32 = Release|Win32
EndGlobalSection
]]
end
function suite.ProjectPlatforms_OnMixedModes()
addnetproject()
prepare()
sln2005.project_platforms(sln) sln2005.project_platforms(sln)
end
function suite.ProjectPlatforms_OnMixedLanguages()
_ACTION = "vs2005"
test.createproject(sln)
uuid "AE61726D-187C-E440-BD07-2556188A6565"
prepare("C#")
test.capture [[ test.capture [[
GlobalSection(ProjectConfigurationPlatforms) = postSolution GlobalSection(ProjectConfigurationPlatforms) = postSolution
{AE61726D-187C-E440-BD07-2556188A6565}.Debug|Any CPU.ActiveCfg = Debug|Win32
{AE61726D-187C-E440-BD07-2556188A6565}.Debug|Mixed Platforms.ActiveCfg = Debug|Win32
{AE61726D-187C-E440-BD07-2556188A6565}.Debug|Mixed Platforms.Build.0 = Debug|Win32
{AE61726D-187C-E440-BD07-2556188A6565}.Debug|Win32.ActiveCfg = Debug|Win32
{AE61726D-187C-E440-BD07-2556188A6565}.Debug|Win32.Build.0 = Debug|Win32
{AE61726D-187C-E440-BD07-2556188A6565}.Release|Any CPU.ActiveCfg = Release|Win32
{AE61726D-187C-E440-BD07-2556188A6565}.Release|Mixed Platforms.ActiveCfg = Release|Win32
{AE61726D-187C-E440-BD07-2556188A6565}.Release|Mixed Platforms.Build.0 = Release|Win32
{AE61726D-187C-E440-BD07-2556188A6565}.Release|Win32.ActiveCfg = Release|Win32
{AE61726D-187C-E440-BD07-2556188A6565}.Release|Win32.Build.0 = Release|Win32
{C9135098-6047-8142-B10E-D27E7F73FCB3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {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}.Debug|Any CPU.Build.0 = Debug|Any CPU
{C9135098-6047-8142-B10E-D27E7F73FCB3}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU {C9135098-6047-8142-B10E-D27E7F73FCB3}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
@ -123,74 +45,29 @@ EndGlobal
{C9135098-6047-8142-B10E-D27E7F73FCB3}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU {C9135098-6047-8142-B10E-D27E7F73FCB3}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
{C9135098-6047-8142-B10E-D27E7F73FCB3}.Release|Mixed Platforms.Build.0 = Release|Any CPU {C9135098-6047-8142-B10E-D27E7F73FCB3}.Release|Mixed Platforms.Build.0 = Release|Any CPU
{C9135098-6047-8142-B10E-D27E7F73FCB3}.Release|Win32.ActiveCfg = Release|Any CPU {C9135098-6047-8142-B10E-D27E7F73FCB3}.Release|Win32.ActiveCfg = Release|Any CPU
EndGlobalSection
]]
end
--
-- Test multiple platforms
--
function suite.SolutionPlatforms_OnMultiplePlatforms()
platforms { "x32", "x64" }
prepare()
sln2005.platforms(sln)
test.capture [[
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Win32 = Debug|Win32
Debug|x64 = Debug|x64
Release|Win32 = Release|Win32
Release|x64 = Release|x64
EndGlobalSection
]]
end
function suite.ProjectPlatforms_OnMultiplePlatforms()
platforms { "x32", "x64" }
prepare()
sln2005.project_platforms(sln)
test.capture [[
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{AE61726D-187C-E440-BD07-2556188A6565}.Debug|Win32.ActiveCfg = Debug|Win32
{AE61726D-187C-E440-BD07-2556188A6565}.Debug|Win32.Build.0 = Debug|Win32
{AE61726D-187C-E440-BD07-2556188A6565}.Debug|x64.ActiveCfg = Debug|x64
{AE61726D-187C-E440-BD07-2556188A6565}.Debug|x64.Build.0 = Debug|x64
{AE61726D-187C-E440-BD07-2556188A6565}.Release|Win32.ActiveCfg = Release|Win32
{AE61726D-187C-E440-BD07-2556188A6565}.Release|Win32.Build.0 = Release|Win32
{AE61726D-187C-E440-BD07-2556188A6565}.Release|x64.ActiveCfg = Release|x64
{AE61726D-187C-E440-BD07-2556188A6565}.Release|x64.Build.0 = Release|x64
EndGlobalSection
]]
end
function suite.ProjectPlatforms_OnMultiplePlatformsAndMixedModes()
platforms { "x32", "x64" }
addnetproject()
prepare()
sln2005.project_platforms(sln)
test.capture [[
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{AE61726D-187C-E440-BD07-2556188A6565}.Debug|Any CPU.ActiveCfg = Debug|Win32 {AE61726D-187C-E440-BD07-2556188A6565}.Debug|Any CPU.ActiveCfg = Debug|Win32
{AE61726D-187C-E440-BD07-2556188A6565}.Debug|Mixed Platforms.ActiveCfg = Debug|Win32 {AE61726D-187C-E440-BD07-2556188A6565}.Debug|Mixed Platforms.ActiveCfg = Debug|Win32
{AE61726D-187C-E440-BD07-2556188A6565}.Debug|Mixed Platforms.Build.0 = Debug|Win32 {AE61726D-187C-E440-BD07-2556188A6565}.Debug|Mixed Platforms.Build.0 = Debug|Win32
{AE61726D-187C-E440-BD07-2556188A6565}.Debug|Win32.ActiveCfg = Debug|Win32 {AE61726D-187C-E440-BD07-2556188A6565}.Debug|Win32.ActiveCfg = Debug|Win32
{AE61726D-187C-E440-BD07-2556188A6565}.Debug|Win32.Build.0 = Debug|Win32 {AE61726D-187C-E440-BD07-2556188A6565}.Debug|Win32.Build.0 = Debug|Win32
{AE61726D-187C-E440-BD07-2556188A6565}.Debug|x64.ActiveCfg = Debug|x64
{AE61726D-187C-E440-BD07-2556188A6565}.Debug|x64.Build.0 = Debug|x64
{AE61726D-187C-E440-BD07-2556188A6565}.Release|Any CPU.ActiveCfg = Release|Win32 {AE61726D-187C-E440-BD07-2556188A6565}.Release|Any CPU.ActiveCfg = Release|Win32
{AE61726D-187C-E440-BD07-2556188A6565}.Release|Mixed Platforms.ActiveCfg = Release|Win32 {AE61726D-187C-E440-BD07-2556188A6565}.Release|Mixed Platforms.ActiveCfg = Release|Win32
{AE61726D-187C-E440-BD07-2556188A6565}.Release|Mixed Platforms.Build.0 = Release|Win32 {AE61726D-187C-E440-BD07-2556188A6565}.Release|Mixed Platforms.Build.0 = Release|Win32
{AE61726D-187C-E440-BD07-2556188A6565}.Release|Win32.ActiveCfg = Release|Win32 {AE61726D-187C-E440-BD07-2556188A6565}.Release|Win32.ActiveCfg = Release|Win32
{AE61726D-187C-E440-BD07-2556188A6565}.Release|Win32.Build.0 = Release|Win32 {AE61726D-187C-E440-BD07-2556188A6565}.Release|Win32.Build.0 = Release|Win32
{AE61726D-187C-E440-BD07-2556188A6565}.Release|x64.ActiveCfg = Release|x64 EndGlobalSection
{AE61726D-187C-E440-BD07-2556188A6565}.Release|x64.Build.0 = Release|x64 ]]
end
function suite.ProjectPlatforms_OnMultiplePlatformsAndMixedModes()
_ACTION = "vs2005"
platforms { "x32", "x64" }
test.createproject(sln)
uuid "AE61726D-187C-E440-BD07-2556188A6565"
prepare("C#")
test.capture [[
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{C9135098-6047-8142-B10E-D27E7F73FCB3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {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}.Debug|Any CPU.Build.0 = Debug|Any CPU
{C9135098-6047-8142-B10E-D27E7F73FCB3}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU {C9135098-6047-8142-B10E-D27E7F73FCB3}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
@ -203,40 +80,20 @@ EndGlobal
{C9135098-6047-8142-B10E-D27E7F73FCB3}.Release|Mixed Platforms.Build.0 = Release|Any CPU {C9135098-6047-8142-B10E-D27E7F73FCB3}.Release|Mixed Platforms.Build.0 = Release|Any CPU
{C9135098-6047-8142-B10E-D27E7F73FCB3}.Release|Win32.ActiveCfg = Release|Any CPU {C9135098-6047-8142-B10E-D27E7F73FCB3}.Release|Win32.ActiveCfg = Release|Any CPU
{C9135098-6047-8142-B10E-D27E7F73FCB3}.Release|x64.ActiveCfg = Release|Any CPU {C9135098-6047-8142-B10E-D27E7F73FCB3}.Release|x64.ActiveCfg = Release|Any CPU
EndGlobalSection {AE61726D-187C-E440-BD07-2556188A6565}.Debug|Any CPU.ActiveCfg = Debug|Win32
]] {AE61726D-187C-E440-BD07-2556188A6565}.Debug|Mixed Platforms.ActiveCfg = Debug|Win32
end {AE61726D-187C-E440-BD07-2556188A6565}.Debug|Mixed Platforms.Build.0 = Debug|Win32
{AE61726D-187C-E440-BD07-2556188A6565}.Debug|Win32.ActiveCfg = Debug|Win32
{AE61726D-187C-E440-BD07-2556188A6565}.Debug|Win32.Build.0 = Debug|Win32
-- {AE61726D-187C-E440-BD07-2556188A6565}.Debug|x64.ActiveCfg = Debug|x64
-- Test PS3 support {AE61726D-187C-E440-BD07-2556188A6565}.Debug|x64.Build.0 = Debug|x64
-- {AE61726D-187C-E440-BD07-2556188A6565}.Release|Any CPU.ActiveCfg = Release|Win32
{AE61726D-187C-E440-BD07-2556188A6565}.Release|Mixed Platforms.ActiveCfg = Release|Win32
function suite.SolutionPlatforms_OnPS3() {AE61726D-187C-E440-BD07-2556188A6565}.Release|Mixed Platforms.Build.0 = Release|Win32
platforms { "PS3" } {AE61726D-187C-E440-BD07-2556188A6565}.Release|Win32.ActiveCfg = Release|Win32
prepare() {AE61726D-187C-E440-BD07-2556188A6565}.Release|Win32.Build.0 = Release|Win32
{AE61726D-187C-E440-BD07-2556188A6565}.Release|x64.ActiveCfg = Release|x64
sln2005.platforms(sln) {AE61726D-187C-E440-BD07-2556188A6565}.Release|x64.Build.0 = Release|x64
test.capture [[
GlobalSection(SolutionConfigurationPlatforms) = preSolution
PS3 Debug|Win32 = PS3 Debug|Win32
PS3 Release|Win32 = PS3 Release|Win32
EndGlobalSection
]]
end
function suite.ProjectPlatforms_OnPS3()
platforms { "PS3" }
prepare()
sln2005.project_platforms(sln)
test.capture [[
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{AE61726D-187C-E440-BD07-2556188A6565}.PS3 Debug|Win32.ActiveCfg = PS3 Debug|Win32
{AE61726D-187C-E440-BD07-2556188A6565}.PS3 Debug|Win32.Build.0 = PS3 Debug|Win32
{AE61726D-187C-E440-BD07-2556188A6565}.PS3 Release|Win32.ActiveCfg = PS3 Release|Win32
{AE61726D-187C-E440-BD07-2556188A6565}.PS3 Release|Win32.Build.0 = PS3 Release|Win32
EndGlobalSection EndGlobalSection
]] ]]
end end

View File

@ -0,0 +1,67 @@
--
-- tests/actions/vstudio/sln2005/projects.lua
-- Validate generation of Visual Studio 2005+ solution project entries.
-- Copyright (c) 2009-2011 Jason Perkins and the Premake project
--
T.vstudio_sln2005_projects = { }
local suite = T.vstudio_sln2005_projects
local sln2005 = premake.vstudio.sln2005
--
-- Setup
--
local sln, prj
function suite.setup()
_ACTION = "vs2005"
sln = test.createsolution()
uuid "AE61726D-187C-E440-BD07-2556188A6565"
end
local function prepare()
premake.buildconfigs()
prj = premake.solution.getproject(sln, 1)
sln2005.project(prj)
end
--
-- C/C++ project reference tests
--
function suite.On2005_CppProject()
_ACTION = "vs2005"
prepare()
test.capture [[
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "MyProject", "MyProject.vcproj", "{AE61726D-187C-E440-BD07-2556188A6565}"
EndProject
]]
end
function suite.On2010_CppProject()
_ACTION = "vs2010"
prepare()
test.capture [[
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "MyProject", "MyProject.vcxproj", "{AE61726D-187C-E440-BD07-2556188A6565}"
EndProject
]]
end
--
-- C# project reference tests
--
function suite.On2005_CsProject()
_ACTION = "vs2005"
language "C#"
prepare()
test.capture [[
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MyProject", "MyProject.csproj", "{AE61726D-187C-E440-BD07-2556188A6565}"
EndProject
]]
end

View File

@ -164,7 +164,6 @@
function suite.PBXGroup_ListsDependencies() function suite.PBXGroup_ListsDependencies()
prepare() prepare()
xcode.PBXGroup(tr) xcode.PBXGroup(tr)
-- test.print(io.endcapture())
test.capture [[ test.capture [[
/* Begin PBXGroup section */ /* Begin PBXGroup section */
[MyProject] /* MyProject */ = { [MyProject] /* MyProject */ = {

View File

@ -62,10 +62,6 @@
-- Visual Studio tests -- Visual Studio tests
dofile("test_vs2002_sln.lua") dofile("test_vs2002_sln.lua")
dofile("test_vs2003_sln.lua") dofile("test_vs2003_sln.lua")
dofile("test_vs2005_sln.lua")
dofile("test_vs2008_sln.lua")
dofile("test_vs2010_sln.lua")
dofile("actions/vstudio/test_vs2005_csproj.lua")
dofile("actions/vstudio/test_vs200x_vcproj.lua") dofile("actions/vstudio/test_vs200x_vcproj.lua")
dofile("actions/vstudio/test_vs200x_vcproj_linker.lua") dofile("actions/vstudio/test_vs200x_vcproj_linker.lua")
dofile("actions/vstudio/test_vs2010_vcxproj.lua") dofile("actions/vstudio/test_vs2010_vcxproj.lua")
@ -73,8 +69,25 @@
dofile("actions/vstudio/test_vs2010_links.lua") dofile("actions/vstudio/test_vs2010_links.lua")
dofile("actions/vstudio/test_vs2010_filters.lua") dofile("actions/vstudio/test_vs2010_filters.lua")
dofile("actions/vstudio/test_vs2010_project_kinds.lua") dofile("actions/vstudio/test_vs2010_project_kinds.lua")
-- Visual Studio 2002-2003 C# projects
dofile("actions/vstudio/cs2002/files.lua") dofile("actions/vstudio/cs2002/files.lua")
-- Visual Studio 2005-2010 C# projects
dofile("actions/vstudio/cs2005/files.lua") dofile("actions/vstudio/cs2005/files.lua")
dofile("actions/vstudio/cs2005/projectelement.lua")
dofile("actions/vstudio/cs2005/projectsettings.lua")
dofile("actions/vstudio/cs2005/propertygroup.lua")
-- Visual Studio 2005-2010 solutions
dofile("actions/vstudio/sln2005/dependencies.lua")
dofile("actions/vstudio/sln2005/header.lua")
dofile("actions/vstudio/sln2005/layout.lua")
dofile("actions/vstudio/sln2005/platforms.lua")
dofile("actions/vstudio/sln2005/projectplatforms.lua")
dofile("actions/vstudio/sln2005/projects.lua")
-- Visual Studio 2002-2008 C/++ projects
dofile("actions/vstudio/vc200x/files.lua") dofile("actions/vstudio/vc200x/files.lua")
-- Makefile tests -- Makefile tests

View File

@ -1,116 +0,0 @@
T.vs2010_sln = { }
local vs_magic_cpp_build_tool_id = "8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942"
local constant_uuid = "AE61726D-187C-E440-BD07-2556188A6565"
local constant_project_name = "MyProject"
--
-- Configure a solution for testing
--
local sln
function T.vs2010_sln.setup()
_ACTION = "vs2010"
sln = solution "MySolution"
configurations { "Debug", "Release" }
platforms {}
prj = project(constant_project_name)
language "C++"
kind "ConsoleApp"
uuid(constant_uuid)
premake.buildconfigs()
end
local function escape_id(str)
return string.gsub(str,"%-+","%%%-")
end
local function assert_has_project(buffer,uid,name,ext)
test.string_contains(buffer,"Project(\"{"..escape_id(vs_magic_cpp_build_tool_id).."}\") = \""..name.."\", \""..name.."."..ext.."\", \"{"..escape_id(uid).."}\"")
end
local function assert_find_uuid(buffer,id)
test.string_contains(buffer,escape_id(id))
end
local function get_buffer()
premake.vs_generic_solution(sln)
buffer = io.endcapture()
return buffer
end
function T.vs2010_sln.action_formatVersionis11()
local buffer = get_buffer()
test.string_contains(buffer,'Format Version 11.00')
end
function T.vs2010_sln.action_vsIs2010()
local buffer = get_buffer()
test.string_contains(buffer,'# Visual Studio 2010')
end
function T.vs2010_sln.action_hasProjectScope()
local buffer = get_buffer()
test.string_contains(buffer,"Project(.*)EndProject")
end
function T.vs2010_sln.containsVsCppMagicId()
local buffer = get_buffer()
assert_find_uuid(buffer,vs_magic_cpp_build_tool_id)
end
function T.vs2010_sln.action_findMyProjectID()
local buffer = get_buffer()
test.string_contains(buffer,escape_id(constant_uuid))
end
function T.vs2010_sln.action_findsExtension()
local buffer = get_buffer()
test.string_contains(buffer,".vcxproj")
end
function T.vs2010_sln.action_hasGlobalStartBlock()
local buffer = get_buffer()
test.string_contains(buffer,"Global")
end
function T.vs2010_sln.action_hasGlobalEndBlock()
local buffer = get_buffer()
test.string_contains(buffer,"EndGlobal")
end
function T.vs2010_sln.BasicLayout()
premake.vs_generic_solution(sln)
test.capture ('\239\187\191' .. [[
Microsoft Visual Studio Solution File, Format Version 11.00
# Visual Studio 2010
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "MyProject", "MyProject.vcxproj", "{AE61726D-187C-E440-BD07-2556188A6565}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Win32 = Debug|Win32
Release|Win32 = Release|Win32
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{AE61726D-187C-E440-BD07-2556188A6565}.Debug|Win32.ActiveCfg = Debug|Win32
{AE61726D-187C-E440-BD07-2556188A6565}.Debug|Win32.Build.0 = Debug|Win32
{AE61726D-187C-E440-BD07-2556188A6565}.Release|Win32.ActiveCfg = Release|Win32
{AE61726D-187C-E440-BD07-2556188A6565}.Release|Win32.Build.0 = Release|Win32
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal
]])
end