[#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)
-------
* Feature 3100379: C# support for Visual Studio 2010
* Added support for Haiku OS (Yuriy O'Donnell)
* Patch 2963313: Enable setting .NET framework version (Justen Hyde)
* Switched PS3 builds from GCC to SNC

View File

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

View File

@ -17,6 +17,7 @@
any = "Any CPU",
mixed = "Mixed Platforms",
Native = "Win32",
x86 = "x86",
x32 = "Win32",
x64 = "x64",
PS3 = "PS3",
@ -54,16 +55,43 @@
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 hasdotnet = premake.hasdotnetproject(sln)
if hasdotnet then
table.insert(platforms, 1, "any")
end
if hasdotnet and hascpp then
table.insert(platforms, 2, "mixed")
-- "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")
end
-- 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
for _, buildcfg in ipairs(sln.configurations) do
for _, platform in ipairs(platforms) do
local entry = { }
@ -79,13 +107,13 @@
entry.buildcfg = platform .. " " .. buildcfg
entry.platform = "Win32"
end
-- create a name the way VS likes it
entry.name = entry.buildcfg .. "|" .. entry.platform
-- flag the "fake" platforms added for .NET
entry.isreal = (platform ~= "any" and platform ~= "mixed")
table.insert(cfgs, entry)
end
end
@ -141,14 +169,10 @@
function vstudio.projectfile(prj)
local extension
if (prj.language == "C#") then
if prj.language == "C#" then
extension = ".csproj"
elseif (_ACTION == "vs2010" and prj.language == "C++" )then
extension = ".vcxproj"
elseif (_ACTION == "vs2010" and prj.language == "C" )then
extension = ".vcxproj"
else
extension = ".vcproj"
extension = iif(_ACTION > "vs2008", ".vcxproj", ".vcproj")
end
local fname = path.join(prj.location, prj.name)
@ -170,7 +194,7 @@
--
-- Register the Visual Studio command line actions
-- Register Visual Studio 2002
--
newaction {
@ -206,6 +230,11 @@
oncleantarget = premake.vstudio.cleantarget
}
--
-- Register Visual Studio 2002
--
newaction {
trigger = "vs2003",
shortname = "Visual Studio 2003",
@ -239,6 +268,11 @@
oncleantarget = premake.vstudio.cleantarget
}
--
-- Register Visual Studio 2002
--
newaction {
trigger = "vs2005",
shortname = "Visual Studio 2005",
@ -272,6 +306,11 @@
oncleantarget = vstudio.cleantarget
}
--
-- Register Visual Studio 2002
--
newaction {
trigger = "vs2008",
shortname = "Visual Studio 2008",
@ -306,30 +345,39 @@
}
--
-- Register Visual Studio 2002
--
newaction
{
trigger = "vs2010",
shortname = "Visual Studio 2010",
description = "Generate Visual Studio 2010 project files (experimental)",
description = "Generate Visual Studio 2010 project files",
os = "windows",
valid_kinds = { "ConsoleApp", "WindowedApp", "StaticLib", "SharedLib" },
valid_languages = { "C++","C"},
valid_languages = { "C", "C++", "C#"},
valid_tools = {
cc = { "msc" },
--dotnet = { "msnet" },
dotnet = { "msnet" },
},
onsolution = function(sln)
premake.generate(sln, "%%.sln", premake.vs_generic_solution)
premake.generate(sln, "%%.sln", vstudio.sln2005.generate)
end,
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.user", premake.vs2010_vcxproj_user)
premake.generate(prj, "%%.vcxproj.filters", premake.vs2010_vcxproj_filters)
end
end,

View File

@ -1,221 +1,249 @@
--
-- vs2005_csproj.lua
-- Generate a Visual Studio 2005/2008 C# project.
-- Copyright (c) 2009-2010 Jason Perkins and the Premake project
--
--
-- Set up namespaces
--
premake.vstudio.cs2005 = { }
local vstudio = premake.vstudio
local cs2005 = premake.vstudio.cs2005
--
-- Figure out what elements a particular source code file need in its item
-- block, based on its build action and any related files in the project.
--
local function getelements(prj, action, fname)
if action == "Compile" and fname:endswith(".cs") then
if fname:endswith(".Designer.cs") then
-- is there a matching *.cs file?
local basename = fname:sub(1, -13)
local testname = basename .. ".cs"
if premake.findfile(prj, testname) then
return "Dependency", testname
end
-- is there a matching *.resx file?
testname = basename .. ".resx"
if premake.findfile(prj, testname) then
return "AutoGen", testname
end
else
-- is there a *.Designer.cs file?
local basename = fname:sub(1, -4)
local testname = basename .. ".Designer.cs"
if premake.findfile(prj, testname) then
return "SubTypeForm"
end
end
end
if action == "EmbeddedResource" and fname:endswith(".resx") then
-- is there a matching *.cs file?
local basename = fname:sub(1, -6)
local testname = path.getname(basename .. ".cs")
if premake.findfile(prj, testname) then
if premake.findfile(prj, basename .. ".Designer.cs") then
return "DesignerType", testname
else
return "Dependency", testname
end
else
-- is there a matching *.Designer.cs?
testname = path.getname(basename .. ".Designer.cs")
if premake.findfile(prj, testname) then
return "AutoGenerated"
end
end
end
if action == "Content" then
return "CopyNewest"
end
return "None"
end
--
-- Write out the <Files> element.
--
function cs2005.Files(prj)
local tr = premake.project.buildsourcetree(prj)
premake.tree.traverse(tr, {
onleaf = function(node)
local action = premake.dotnet.getbuildaction(node.cfg)
local fname = path.translate(premake.esc(node.path), "\\")
local elements, dependency = getelements(prj, action, node.path)
if elements == "None" then
_p(' <%s Include="%s" />', action, fname)
else
_p(' <%s Include="%s">', action, fname)
if elements == "AutoGen" then
_p(' <AutoGen>True</AutoGen>')
elseif elements == "AutoGenerated" then
_p(' <SubType>Designer</SubType>')
_p(' <Generator>ResXFileCodeGenerator</Generator>')
_p(' <LastGenOutput>%s.Designer.cs</LastGenOutput>', premake.esc(path.getbasename(node.name)))
elseif elements == "SubTypeDesigner" then
_p(' <SubType>Designer</SubType>')
elseif elements == "SubTypeForm" then
_p(' <SubType>Form</SubType>')
elseif elements == "PreserveNewest" then
_p(' <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>')
end
if dependency then
_p(' <DependentUpon>%s</DependentUpon>', path.translate(premake.esc(dependency), "\\"))
end
_p(' </%s>', action)
end
end
}, false)
end
--
-- Write the opening <Project> element and project level <PropertyGroup> block.
--
function cs2005.projectelement(prj)
_p('<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"%s>', iif(_ACTION == 'vs2005', '', ' ToolsVersion="3.5"'))
end
function cs2005.projectsettings(prj)
_p(' <PropertyGroup>')
_p(' <Configuration Condition=" \'$(Configuration)\' == \'\' ">%s</Configuration>', premake.esc(prj.solution.configurations[1]))
_p(' <Platform Condition=" \'$(Platform)\' == \'\' ">AnyCPU</Platform>')
_p(' <ProductVersion>%s</ProductVersion>', iif(_ACTION == "vs2005", "8.0.50727", "9.0.21022"))
_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)
if prj.framework then
_p(' <TargetFrameworkVersion>v%s</TargetFrameworkVersion>', prj.framework)
end
_p(' </PropertyGroup>')
end
--
-- The main function: write the project file.
--
function cs2005.generate(prj)
io.eol = "\r\n"
local vsversion, toolversion
if _ACTION == "vs2005" then
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
_p(' <PropertyGroup Condition=" \'$(Configuration)|$(Platform)\' == \'%s|AnyCPU\' ">', premake.esc(cfg.name))
if cfg.flags.Symbols then
_p(' <DebugSymbols>true</DebugSymbols>')
_p(' <DebugType>full</DebugType>')
else
_p(' <DebugType>pdbonly</DebugType>')
end
_p(' <Optimize>%s</Optimize>', iif(cfg.flags.Optimize or cfg.flags.OptimizeSize or cfg.flags.OptimizeSpeed, "true", "false"))
_p(' <OutputPath>%s</OutputPath>', cfg.buildtarget.directory)
_p(' <DefineConstants>%s</DefineConstants>', table.concat(premake.esc(cfg.defines), ";"))
_p(' <ErrorReport>prompt</ErrorReport>')
_p(' <WarningLevel>4</WarningLevel>')
if cfg.flags.Unsafe then
_p(' <AllowUnsafeBlocks>true</AllowUnsafeBlocks>')
end
if cfg.flags.FatalWarnings then
_p(' <TreatWarningsAsErrors>true</TreatWarningsAsErrors>')
end
_p(' </PropertyGroup>')
end
_p(' <ItemGroup>')
for _, ref in ipairs(premake.getlinks(prj, "siblings", "object")) do
_p(' <ProjectReference Include="%s">', path.translate(path.getrelative(prj.location, vstudio.projectfile(ref)), "\\"))
_p(' <Project>{%s}</Project>', ref.uuid)
_p(' <Name>%s</Name>', premake.esc(ref.name))
_p(' </ProjectReference>')
end
for _, linkname in ipairs(premake.getlinks(prj, "system", "basename")) do
_p(' <Reference Include="%s" />', premake.esc(linkname))
end
_p(' </ItemGroup>')
_p(' <ItemGroup>')
cs2005.Files(prj)
_p(' </ItemGroup>')
_p(' <Import Project="$(MSBuildBinPath)\\Microsoft.CSharp.targets" />')
_p(' <!-- To modify your build process, add your task inside one of the targets below and uncomment it.')
_p(' Other similar extension points exist, see Microsoft.Common.targets.')
_p(' <Target Name="BeforeBuild">')
_p(' </Target>')
_p(' <Target Name="AfterBuild">')
_p(' </Target>')
_p(' -->')
_p('</Project>')
end
--
-- vs2005_csproj.lua
-- Generate a Visual Studio 2005/2008 C# project.
-- Copyright (c) 2009-2011 Jason Perkins and the Premake project
--
--
-- Set up namespaces
--
premake.vstudio.cs2005 = { }
local vstudio = premake.vstudio
local cs2005 = premake.vstudio.cs2005
--
-- Figure out what elements a particular source code file need in its item
-- block, based on its build action and any related files in the project.
--
local function getelements(prj, action, fname)
if action == "Compile" and fname:endswith(".cs") then
if fname:endswith(".Designer.cs") then
-- is there a matching *.cs file?
local basename = fname:sub(1, -13)
local testname = basename .. ".cs"
if premake.findfile(prj, testname) then
return "Dependency", testname
end
-- is there a matching *.resx file?
testname = basename .. ".resx"
if premake.findfile(prj, testname) then
return "AutoGen", testname
end
else
-- is there a *.Designer.cs file?
local basename = fname:sub(1, -4)
local testname = basename .. ".Designer.cs"
if premake.findfile(prj, testname) then
return "SubTypeForm"
end
end
end
if action == "EmbeddedResource" and fname:endswith(".resx") then
-- is there a matching *.cs file?
local basename = fname:sub(1, -6)
local testname = path.getname(basename .. ".cs")
if premake.findfile(prj, testname) then
if premake.findfile(prj, basename .. ".Designer.cs") then
return "DesignerType", testname
else
return "Dependency", testname
end
else
-- is there a matching *.Designer.cs?
testname = path.getname(basename .. ".Designer.cs")
if premake.findfile(prj, testname) then
return "AutoGenerated"
end
end
end
if action == "Content" then
return "CopyNewest"
end
return "None"
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.
--
function cs2005.files(prj)
local tr = premake.project.buildsourcetree(prj)
premake.tree.traverse(tr, {
onleaf = function(node)
local action = premake.dotnet.getbuildaction(node.cfg)
local fname = path.translate(premake.esc(node.path), "\\")
local elements, dependency = getelements(prj, action, node.path)
if elements == "None" then
_p(' <%s Include="%s" />', action, fname)
else
_p(' <%s Include="%s">', action, fname)
if elements == "AutoGen" then
_p(' <AutoGen>True</AutoGen>')
elseif elements == "AutoGenerated" then
_p(' <SubType>Designer</SubType>')
_p(' <Generator>ResXFileCodeGenerator</Generator>')
_p(' <LastGenOutput>%s.Designer.cs</LastGenOutput>', premake.esc(path.getbasename(node.name)))
elseif elements == "SubTypeDesigner" then
_p(' <SubType>Designer</SubType>')
elseif elements == "SubTypeForm" then
_p(' <SubType>Form</SubType>')
elseif elements == "PreserveNewest" then
_p(' <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>')
end
if dependency then
_p(' <DependentUpon>%s</DependentUpon>', path.translate(premake.esc(dependency), "\\"))
end
_p(' </%s>', action)
end
end
}, false)
end
--
-- Write the opening <Project> element.
--
function cs2005.projectelement(prj)
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
--
-- Write the opening PropertyGroup, which contains the project-level settings.
--
function cs2005.projectsettings(prj)
local version = {
vs2005 = '8.0.50727',
vs2008 = '9.0.21022',
vs2010 = '8.0.30703',
}
_p(' <PropertyGroup>')
_p(' <Configuration Condition=" \'$(Configuration)\' == \'\' ">%s</Configuration>', premake.esc(prj.solution.configurations[1]))
_p(' <Platform Condition=" \'$(Platform)\' == \'\' ">%s</Platform>', cs2005.arch(prj))
_p(' <ProductVersion>%s</ProductVersion>', version[_ACTION])
_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)
local framework = prj.framework or iif(_ACTION == "vs2010", "4.0", nil)
if framework then
_p(' <TargetFrameworkVersion>v%s</TargetFrameworkVersion>', framework)
end
if _ACTION == "vs2010" then
_p(' <TargetFrameworkProfile>Client</TargetFrameworkProfile>')
_p(' <FileAlignment>512</FileAlignment>')
end
_p(' </PropertyGroup>')
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.
--
function cs2005.generate(prj)
io.eol = "\r\n"
cs2005.projectelement(prj)
cs2005.projectsettings(prj)
for cfg in premake.eachconfig(prj) do
cs2005.propertygroup(cfg)
if cfg.flags.Symbols then
_p(' <DebugSymbols>true</DebugSymbols>')
_p(' <DebugType>full</DebugType>')
else
_p(' <DebugType>pdbonly</DebugType>')
end
_p(' <Optimize>%s</Optimize>', iif(cfg.flags.Optimize or cfg.flags.OptimizeSize or cfg.flags.OptimizeSpeed, "true", "false"))
_p(' <OutputPath>%s</OutputPath>', cfg.buildtarget.directory)
_p(' <DefineConstants>%s</DefineConstants>', table.concat(premake.esc(cfg.defines), ";"))
_p(' <ErrorReport>prompt</ErrorReport>')
_p(' <WarningLevel>4</WarningLevel>')
if cfg.flags.Unsafe then
_p(' <AllowUnsafeBlocks>true</AllowUnsafeBlocks>')
end
if cfg.flags.FatalWarnings then
_p(' <TreatWarningsAsErrors>true</TreatWarningsAsErrors>')
end
_p(' </PropertyGroup>')
end
_p(' <ItemGroup>')
for _, ref in ipairs(premake.getlinks(prj, "siblings", "object")) do
_p(' <ProjectReference Include="%s">', path.translate(path.getrelative(prj.location, vstudio.projectfile(ref)), "\\"))
_p(' <Project>{%s}</Project>', ref.uuid)
_p(' <Name>%s</Name>', premake.esc(ref.name))
_p(' </ProjectReference>')
end
for _, linkname in ipairs(premake.getlinks(prj, "system", "basename")) do
_p(' <Reference Include="%s" />', premake.esc(linkname))
end
_p(' </ItemGroup>')
_p(' <ItemGroup>')
cs2005.files(prj)
_p(' </ItemGroup>')
_p(' <Import Project="$(MSBuildBinPath)\\Microsoft.CSharp.targets" />')
_p(' <!-- To modify your build process, add your task inside one of the targets below and uncomment it.')
_p(' Other similar extension points exist, see Microsoft.Common.targets.')
_p(' <Target Name="BeforeBuild">')
_p(' </Target>')
_p(' <Target Name="AfterBuild">')
_p(' </Target>')
_p(' -->')
_p('</Project>')
end

View File

@ -1,6 +1,6 @@
--
-- 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
--
@ -8,6 +8,7 @@
local vstudio = premake.vstudio
local sln2005 = premake.vstudio.sln2005
function sln2005.generate(sln)
io.eol = '\r\n'
@ -17,25 +18,10 @@
-- Mark the file as Unicode
_p('\239\187\191')
-- Write the solution file version header
_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'))
sln2005.header(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')
sln2005.project(prj)
end
_p('Global')
@ -44,9 +30,57 @@
sln2005.properties(sln)
_p('EndGlobal')
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
-- lists all of the configuration/platform pairs that exist in the solution.

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 = { }
local vc2010 = premake.vstudio.vc2010
premake.vstudio.vc2010 = { }
local vc2010 = premake.vstudio.vc2010
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
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);
end
end
@ -695,15 +693,8 @@
for prjIx, prj in ipairs(sln.projects) do
if(not prj.usage) then
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);
copyusagedata(cfg, cfgname, usesPrjs)
for _, linkName in ipairs(cfg.links) do
printf("link to '%s'", linkName)
end
end
end
end

View File

@ -23,7 +23,7 @@
premake.buildconfigs()
prj = premake.solution.getproject(sln, 1)
sln.vstudio_configs = premake.vstudio.buildconfigs(sln)
cs2005.Files(prj)
cs2005.files(prj)
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,121 +1,120 @@
--
-- tests/actions/test_vs2005_csproj.lua
-- Automated test suite for Visual Studio 2005-2008 C# project generation.
-- Copyright (c) 2010 Jason Perkins and the Premake project
--
T.vs2005_csproj = { }
local suite = T.vs2005_csproj
local cs2005 = premake.vstudio.cs2005
--
-- Configure a solution for testing
--
local sln, prj
function suite.setup()
_ACTION = "vs2005"
sln = solution "MySolution"
configurations { "Debug", "Release" }
platforms {}
project "MyProject"
language "C#"
kind "ConsoleApp"
uuid "AE61726D-187C-E440-BD07-2556188A6565"
end
local function prepare()
premake.buildconfigs()
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)
test.capture [[
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProductVersion>8.0.50727</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{AE61726D-187C-E440-BD07-2556188A6565}</ProjectGuid>
<OutputType>Exe</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>MyProject</RootNamespace>
<AssemblyName>MyProject</AssemblyName>
</PropertyGroup>
]]
end
function suite.projectsettings_OnVs2008()
_ACTION = "vs2008"
prepare()
cs2005.projectsettings(prj)
test.capture [[
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProductVersion>9.0.21022</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{AE61726D-187C-E440-BD07-2556188A6565}</ProjectGuid>
<OutputType>Exe</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>MyProject</RootNamespace>
<AssemblyName>MyProject</AssemblyName>
</PropertyGroup>
]]
end
function suite.projectsettings_OnFrameworkVersion()
_ACTION = "vs2005"
framework "3.0"
prepare()
cs2005.projectsettings(prj)
test.capture [[
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProductVersion>8.0.50727</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>v3.0</TargetFrameworkVersion>
</PropertyGroup>
]]
end
--
-- tests/actions/vstudio/cs2005/projectsettings.lua
-- Validate generation of root <PropertyGroup/> in Visual Studio 2005+ .csproj
-- Copyright (c) 2009-2011 Jason Perkins and the Premake project
--
T.vstudio_cs2005_projectsettings = { }
local suite = T.vstudio_cs2005_projectsettings
local cs2005 = premake.vstudio.cs2005
--
-- Setup
--
local sln, prj
function suite.setup()
sln = test.createsolution()
language "C#"
uuid "AE61726D-187C-E440-BD07-2556188A6565"
end
local function prepare()
premake.buildconfigs()
prj = premake.solution.getproject(sln, 1)
cs2005.projectsettings(prj)
end
--
-- Version Tests
--
function suite.OnVs2005()
_ACTION = "vs2005"
prepare()
test.capture [[
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProductVersion>8.0.50727</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{AE61726D-187C-E440-BD07-2556188A6565}</ProjectGuid>
<OutputType>Exe</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>MyProject</RootNamespace>
<AssemblyName>MyProject</AssemblyName>
</PropertyGroup>
]]
end
function suite.OnVs2008()
_ACTION = "vs2008"
prepare()
test.capture [[
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProductVersion>9.0.21022</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{AE61726D-187C-E440-BD07-2556188A6565}</ProjectGuid>
<OutputType>Exe</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>MyProject</RootNamespace>
<AssemblyName>MyProject</AssemblyName>
</PropertyGroup>
]]
end
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"
framework "3.0"
prepare()
test.capture [[
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProductVersion>8.0.50727</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>v3.0</TargetFrameworkVersion>
</PropertyGroup>
]]
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
-- Automated test suite for Visual Studio 2008 solution generation.
-- Copyright (c) 2009 Jason Perkins and the Premake project
-- tests/actions/vstudio/sln2005/layout.lua
-- Validate the overall layout of VS 2005-2010 solutions.
-- Copyright (c) 2009-2011 Jason Perkins and the Premake project
--
T.vstudio_sln2005_layout = { }
local suite = T.vstudio_sln2005_layout
local sln2005 = premake.vstudio.sln2005
T.vs2008_sln = { }
local suite = T.vs2008_sln
local sln2005 = premake.vstudio.sln2005
--
-- Configure a solution for testing
--
local sln
function suite.setup()
_ACTION = "vs2008"
sln = solution "MySolution"
configurations { "Debug", "Release" }
platforms {}
prj = project "MyProject"
language "C++"
kind "ConsoleApp"
uuid "AE61726D-187C-E440-BD07-2556188A6565"
premake.buildconfigs()
_ACTION = "vs2005"
sln = test.createsolution()
uuid "AE61726D-187C-E440-BD07-2556188A6565"
end
local function prepare()
premake.buildconfigs()
sln.vstudio_configs = premake.vstudio.buildconfigs(sln)
sln2005.generate(sln)
end
--
-- Make sure I've got the basic layout correct
--
function suite.BasicLayout()
sln2005.generate(sln)
prepare()
test.capture ('\239\187\191' .. [[
Microsoft Visual Studio Solution File, Format Version 10.00
# Visual Studio 2008
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

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
-- Automated test suite for Visual Studio 2005 solution generation.
-- Copyright (c) 2009 Jason Perkins and the Premake project
--
T.vs2005_sln = { }
local suite = T.vs2005_sln
local sln2005 = premake.vstudio.sln2005
--
-- Configure a solution for testing
--
local sln
function suite.setup()
sln = solution "MySolution"
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"
end
--
-- 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)
--
-- tests/actions/vstudio/sln2005/projectplatforms.lua
-- Validate generation of Visual Studio 2005+ ProjectConfigurationPlatforms block.
-- Copyright (c) 2009-2011 Jason Perkins and the Premake project
--
T.vstudio_sln2005_projectplatforms = { }
local suite = T.vstudio_sln2005_projectplatforms
local sln2005 = premake.vstudio.sln2005
--
-- Setup
--
local sln, prj
function suite.setup()
sln, prj = test.createsolution()
uuid "C9135098-6047-8142-B10E-D27E7F73FCB3"
end
local function prepare(language)
prj.language = language
premake.buildconfigs()
sln.vstudio_configs = premake.vstudio.buildconfigs(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 [[
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.Build.0 = 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.Build.0 = 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|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}.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|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
{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()
_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.Build.0 = 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|Win32.ActiveCfg = Release|Any CPU
{C9135098-6047-8142-B10E-D27E7F73FCB3}.Release|x64.ActiveCfg = Release|Any CPU
EndGlobalSection
]]
end
--
-- Test PS3 support
--
function suite.SolutionPlatforms_OnPS3()
platforms { "PS3" }
prepare()
sln2005.platforms(sln)
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
{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}.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|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
{AE61726D-187C-E440-BD07-2556188A6565}.Release|x64.ActiveCfg = Release|x64
{AE61726D-187C-E440-BD07-2556188A6565}.Release|x64.Build.0 = Release|x64
EndGlobalSection
]]
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()
prepare()
xcode.PBXGroup(tr)
-- test.print(io.endcapture())
test.capture [[
/* Begin PBXGroup section */
[MyProject] /* MyProject */ = {

View File

@ -62,10 +62,6 @@
-- Visual Studio tests
dofile("test_vs2002_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_linker.lua")
dofile("actions/vstudio/test_vs2010_vcxproj.lua")
@ -73,8 +69,25 @@
dofile("actions/vstudio/test_vs2010_links.lua")
dofile("actions/vstudio/test_vs2010_filters.lua")
dofile("actions/vstudio/test_vs2010_project_kinds.lua")
-- Visual Studio 2002-2003 C# projects
dofile("actions/vstudio/cs2002/files.lua")
-- Visual Studio 2005-2010 C# projects
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")
-- 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