From bb94e9de8163cc99c0b9d37ad1367e8734f76f34 Mon Sep 17 00:00:00 2001 From: Jason Perkins Date: Wed, 16 Feb 2011 15:16:07 -0500 Subject: [PATCH] [#3100379] C# support for Visual Studio 2010 --- CHANGES.txt | 1 + src/_manifest.lua | 1 - src/actions/vstudio/_vstudio.lua | 86 +++- src/actions/vstudio/vs2005_csproj.lua | 470 ++++++++++-------- src/actions/vstudio/vs2005_solution.lua | 74 ++- src/actions/vstudio/vs2010_vcxproxj.lua | 9 +- src/actions/vstudio/vs_generic_solution.lua | 68 --- src/base/configs.lua | 9 - tests/actions/vstudio/cs2005/files.lua | 2 +- .../actions/vstudio/cs2005/projectelement.lua | 56 +++ .../projectsettings.lua} | 241 +++++---- .../actions/vstudio/cs2005/propertygroup.lua | 59 +++ .../actions/vstudio/sln2005/dependencies.lua | 67 +++ tests/actions/vstudio/sln2005/header.lua | 59 +++ .../vstudio/sln2005/layout.lua} | 48 +- tests/actions/vstudio/sln2005/platforms.lua | 135 +++++ .../vstudio/sln2005/projectplatforms.lua} | 267 +++------- tests/actions/vstudio/sln2005/projects.lua | 67 +++ .../actions/xcode/test_xcode_dependencies.lua | 1 - tests/premake4.lua | 21 +- tests/test_vs2010_sln.lua | 116 ----- 21 files changed, 1040 insertions(+), 817 deletions(-) delete mode 100644 src/actions/vstudio/vs_generic_solution.lua create mode 100755 tests/actions/vstudio/cs2005/projectelement.lua rename tests/actions/vstudio/{test_vs2005_csproj.lua => cs2005/projectsettings.lua} (60%) mode change 100644 => 100755 create mode 100755 tests/actions/vstudio/cs2005/propertygroup.lua create mode 100755 tests/actions/vstudio/sln2005/dependencies.lua create mode 100755 tests/actions/vstudio/sln2005/header.lua rename tests/{test_vs2008_sln.lua => actions/vstudio/sln2005/layout.lua} (65%) mode change 100644 => 100755 create mode 100755 tests/actions/vstudio/sln2005/platforms.lua rename tests/{test_vs2005_sln.lua => actions/vstudio/sln2005/projectplatforms.lua} (50%) mode change 100644 => 100755 create mode 100755 tests/actions/vstudio/sln2005/projects.lua delete mode 100644 tests/test_vs2010_sln.lua diff --git a/CHANGES.txt b/CHANGES.txt index 53a1214e..8d0da234 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -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 diff --git a/src/_manifest.lua b/src/_manifest.lua index a88ed706..7be11fa3 100644 --- a/src/_manifest.lua +++ b/src/_manifest.lua @@ -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 diff --git a/src/actions/vstudio/_vstudio.lua b/src/actions/vstudio/_vstudio.lua index 3ba1fdb5..4117fa4f 100644 --- a/src/actions/vstudio/_vstudio.lua +++ b/src/actions/vstudio/_vstudio.lua @@ -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, diff --git a/src/actions/vstudio/vs2005_csproj.lua b/src/actions/vstudio/vs2005_csproj.lua index 850402e4..99c390f4 100644 --- a/src/actions/vstudio/vs2005_csproj.lua +++ b/src/actions/vstudio/vs2005_csproj.lua @@ -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 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(' True') - elseif elements == "AutoGenerated" then - _p(' Designer') - _p(' ResXFileCodeGenerator') - _p(' %s.Designer.cs', premake.esc(path.getbasename(node.name))) - elseif elements == "SubTypeDesigner" then - _p(' Designer') - elseif elements == "SubTypeForm" then - _p(' Form') - elseif elements == "PreserveNewest" then - _p(' PreserveNewest') - end - if dependency then - _p(' %s', path.translate(premake.esc(dependency), "\\")) - end - _p(' ', action) - end - end - }, false) - end - - --- --- Write the opening element and project level block. --- - - function cs2005.projectelement(prj) - _p('', iif(_ACTION == 'vs2005', '', ' ToolsVersion="3.5"')) - end - - function cs2005.projectsettings(prj) - _p(' ') - _p(' %s', premake.esc(prj.solution.configurations[1])) - _p(' AnyCPU') - _p(' %s', iif(_ACTION == "vs2005", "8.0.50727", "9.0.21022")) - _p(' 2.0') - _p(' {%s}', prj.uuid) - _p(' %s', premake.dotnet.getkind(prj)) - _p(' Properties') - _p(' %s', prj.buildtarget.basename) - _p(' %s', prj.buildtarget.basename) - if prj.framework then - _p(' v%s', prj.framework) - end - _p(' ') - 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('', toolversion) - else - _p('') - end - - _p(' ') - _p(' %s', premake.esc(prj.solution.configurations[1])) - _p(' AnyCPU') - _p(' %s', vsversion) - _p(' 2.0') - _p(' {%s}', prj.uuid) - _p(' %s', premake.dotnet.getkind(prj)) - _p(' Properties') - _p(' %s', prj.buildtarget.basename) - _p(' %s', prj.buildtarget.basename) - _p(' ') - - for cfg in premake.eachconfig(prj) do - _p(' ', premake.esc(cfg.name)) - if cfg.flags.Symbols then - _p(' true') - _p(' full') - else - _p(' pdbonly') - end - _p(' %s', iif(cfg.flags.Optimize or cfg.flags.OptimizeSize or cfg.flags.OptimizeSpeed, "true", "false")) - _p(' %s', cfg.buildtarget.directory) - _p(' %s', table.concat(premake.esc(cfg.defines), ";")) - _p(' prompt') - _p(' 4') - if cfg.flags.Unsafe then - _p(' true') - end - if cfg.flags.FatalWarnings then - _p(' true') - end - _p(' ') - end - - _p(' ') - for _, ref in ipairs(premake.getlinks(prj, "siblings", "object")) do - _p(' ', path.translate(path.getrelative(prj.location, vstudio.projectfile(ref)), "\\")) - _p(' {%s}', ref.uuid) - _p(' %s', premake.esc(ref.name)) - _p(' ') - end - for _, linkname in ipairs(premake.getlinks(prj, "system", "basename")) do - _p(' ', premake.esc(linkname)) - end - _p(' ') - - _p(' ') - cs2005.Files(prj) - _p(' ') - - _p(' ') - _p(' ') - _p('') - - 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 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(' True') + elseif elements == "AutoGenerated" then + _p(' Designer') + _p(' ResXFileCodeGenerator') + _p(' %s.Designer.cs', premake.esc(path.getbasename(node.name))) + elseif elements == "SubTypeDesigner" then + _p(' Designer') + elseif elements == "SubTypeForm" then + _p(' Form') + elseif elements == "PreserveNewest" then + _p(' PreserveNewest') + end + if dependency then + _p(' %s', path.translate(premake.esc(dependency), "\\")) + end + _p(' ', action) + end + end + }, false) + end + + +-- +-- Write the opening element. +-- + + function cs2005.projectelement(prj) + local toolversion = { + vs2005 = '', + vs2008 = ' ToolsVersion="3.5"', + vs2010 = ' ToolsVersion="4.0"', + } + + if _ACTION > "vs2008" then + _p('') + end + _p('', 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(' ') + _p(' %s', premake.esc(prj.solution.configurations[1])) + _p(' %s', cs2005.arch(prj)) + _p(' %s', version[_ACTION]) + _p(' 2.0') + _p(' {%s}', prj.uuid) + _p(' %s', premake.dotnet.getkind(prj)) + _p(' Properties') + _p(' %s', prj.buildtarget.basename) + _p(' %s', prj.buildtarget.basename) + + local framework = prj.framework or iif(_ACTION == "vs2010", "4.0", nil) + if framework then + _p(' v%s', framework) + end + + if _ACTION == "vs2010" then + _p(' Client') + _p(' 512') + end + + _p(' ') + end + + +-- +-- Write the PropertyGroup element for a specific configuration block. +-- + + function cs2005.propertygroup(cfg) + _p(' ', premake.esc(cfg.name), cs2005.arch(cfg)) + if _ACTION > "vs2008" then + _p(' %s', 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(' true') + _p(' full') + else + _p(' pdbonly') + end + _p(' %s', iif(cfg.flags.Optimize or cfg.flags.OptimizeSize or cfg.flags.OptimizeSpeed, "true", "false")) + _p(' %s', cfg.buildtarget.directory) + _p(' %s', table.concat(premake.esc(cfg.defines), ";")) + _p(' prompt') + _p(' 4') + if cfg.flags.Unsafe then + _p(' true') + end + if cfg.flags.FatalWarnings then + _p(' true') + end + _p(' ') + end + + _p(' ') + for _, ref in ipairs(premake.getlinks(prj, "siblings", "object")) do + _p(' ', path.translate(path.getrelative(prj.location, vstudio.projectfile(ref)), "\\")) + _p(' {%s}', ref.uuid) + _p(' %s', premake.esc(ref.name)) + _p(' ') + end + for _, linkname in ipairs(premake.getlinks(prj, "system", "basename")) do + _p(' ', premake.esc(linkname)) + end + _p(' ') + + _p(' ') + cs2005.files(prj) + _p(' ') + + _p(' ') + _p(' ') + _p('') + + end + diff --git a/src/actions/vstudio/vs2005_solution.lua b/src/actions/vstudio/vs2005_solution.lua index d42e8540..3f4622ba 100644 --- a/src/actions/vstudio/vs2005_solution.lua +++ b/src/actions/vstudio/vs2005_solution.lua @@ -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. diff --git a/src/actions/vstudio/vs2010_vcxproxj.lua b/src/actions/vstudio/vs2010_vcxproxj.lua index 07832cf5..d9e26f50 100644 --- a/src/actions/vstudio/vs2010_vcxproxj.lua +++ b/src/actions/vstudio/vs2010_vcxproxj.lua @@ -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) diff --git a/src/actions/vstudio/vs_generic_solution.lua b/src/actions/vstudio/vs_generic_solution.lua deleted file mode 100644 index 0217dd1f..00000000 --- a/src/actions/vstudio/vs_generic_solution.lua +++ /dev/null @@ -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 \ No newline at end of file diff --git a/src/base/configs.lua b/src/base/configs.lua index 7bbac59e..700e54ee 100644 --- a/src/base/configs.lua +++ b/src/base/configs.lua @@ -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 diff --git a/tests/actions/vstudio/cs2005/files.lua b/tests/actions/vstudio/cs2005/files.lua index 0edcacc4..0ecc1e12 100755 --- a/tests/actions/vstudio/cs2005/files.lua +++ b/tests/actions/vstudio/cs2005/files.lua @@ -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 diff --git a/tests/actions/vstudio/cs2005/projectelement.lua b/tests/actions/vstudio/cs2005/projectelement.lua new file mode 100755 index 00000000..a06c1c40 --- /dev/null +++ b/tests/actions/vstudio/cs2005/projectelement.lua @@ -0,0 +1,56 @@ +-- +-- tests/actions/vstudio/cs2005/projectelement.lua +-- Validate generation of 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 [[ + + ]] + end + + function suite.On2008() + _ACTION = "vs2008" + prepare() + test.capture [[ + + ]] + end + + function suite.On2010() + _ACTION = "vs2010" + prepare() + test.capture [[ + + + ]] + end diff --git a/tests/actions/vstudio/test_vs2005_csproj.lua b/tests/actions/vstudio/cs2005/projectsettings.lua old mode 100644 new mode 100755 similarity index 60% rename from tests/actions/vstudio/test_vs2005_csproj.lua rename to tests/actions/vstudio/cs2005/projectsettings.lua index b0618eac..6c5ad586 --- a/tests/actions/vstudio/test_vs2005_csproj.lua +++ b/tests/actions/vstudio/cs2005/projectsettings.lua @@ -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 [[ - - ]] - end - - function suite.projectelement_OnVs2008() - _ACTION = "vs2008" - prepare() - cs2005.projectelement(prj) - test.capture [[ - - ]] - end - - --- --- Project settings tests --- - - function suite.projectsettings_OnVs2005() - _ACTION = "vs2005" - prepare() - cs2005.projectsettings(prj) - test.capture [[ - - Debug - AnyCPU - 8.0.50727 - 2.0 - {AE61726D-187C-E440-BD07-2556188A6565} - Exe - Properties - MyProject - MyProject - - ]] - end - - - function suite.projectsettings_OnVs2008() - _ACTION = "vs2008" - prepare() - cs2005.projectsettings(prj) - test.capture [[ - - Debug - AnyCPU - 9.0.21022 - 2.0 - {AE61726D-187C-E440-BD07-2556188A6565} - Exe - Properties - MyProject - MyProject - - ]] - end - - - function suite.projectsettings_OnFrameworkVersion() - _ACTION = "vs2005" - framework "3.0" - prepare() - cs2005.projectsettings(prj) - test.capture [[ - - Debug - AnyCPU - 8.0.50727 - 2.0 - {AE61726D-187C-E440-BD07-2556188A6565} - Exe - Properties - MyProject - MyProject - v3.0 - - ]] - end +-- +-- tests/actions/vstudio/cs2005/projectsettings.lua +-- Validate generation of root 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 [[ + + Debug + AnyCPU + 8.0.50727 + 2.0 + {AE61726D-187C-E440-BD07-2556188A6565} + Exe + Properties + MyProject + MyProject + + ]] + end + + + function suite.OnVs2008() + _ACTION = "vs2008" + prepare() + test.capture [[ + + Debug + AnyCPU + 9.0.21022 + 2.0 + {AE61726D-187C-E440-BD07-2556188A6565} + Exe + Properties + MyProject + MyProject + + ]] + end + + + function suite.OnVs2010() + _ACTION = "vs2010" + prepare() + test.capture [[ + + Debug + AnyCPU + 8.0.30703 + 2.0 + {AE61726D-187C-E440-BD07-2556188A6565} + Exe + Properties + MyProject + MyProject + v4.0 + Client + 512 + + ]] + end + + + +-- +-- Framework Tests +-- + + function suite.OnFrameworkVersion() + _ACTION = "vs2005" + framework "3.0" + prepare() + test.capture [[ + + Debug + AnyCPU + 8.0.50727 + 2.0 + {AE61726D-187C-E440-BD07-2556188A6565} + Exe + Properties + MyProject + MyProject + v3.0 + + ]] + end + + diff --git a/tests/actions/vstudio/cs2005/propertygroup.lua b/tests/actions/vstudio/cs2005/propertygroup.lua new file mode 100755 index 00000000..07eba93e --- /dev/null +++ b/tests/actions/vstudio/cs2005/propertygroup.lua @@ -0,0 +1,59 @@ +-- +-- tests/actions/vstudio/cs2005/propertygroup.lua +-- Validate configuration 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 [[ + + ]] + end + + + function suite.OnVs2008() + _ACTION = "vs2008" + prepare() + test.capture [[ + + ]] + end + + + function suite.OnVs2010() + _ACTION = "vs2010" + prepare() + test.capture [[ + + ]] + end diff --git a/tests/actions/vstudio/sln2005/dependencies.lua b/tests/actions/vstudio/sln2005/dependencies.lua new file mode 100755 index 00000000..f481c2cb --- /dev/null +++ b/tests/actions/vstudio/sln2005/dependencies.lua @@ -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 diff --git a/tests/actions/vstudio/sln2005/header.lua b/tests/actions/vstudio/sln2005/header.lua new file mode 100755 index 00000000..b0173277 --- /dev/null +++ b/tests/actions/vstudio/sln2005/header.lua @@ -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 diff --git a/tests/test_vs2008_sln.lua b/tests/actions/vstudio/sln2005/layout.lua old mode 100644 new mode 100755 similarity index 65% rename from tests/test_vs2008_sln.lua rename to tests/actions/vstudio/sln2005/layout.lua index 74513f7f..3b5a620d --- a/tests/test_vs2008_sln.lua +++ b/tests/actions/vstudio/sln2005/layout.lua @@ -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 diff --git a/tests/actions/vstudio/sln2005/platforms.lua b/tests/actions/vstudio/sln2005/platforms.lua new file mode 100755 index 00000000..82aa9d10 --- /dev/null +++ b/tests/actions/vstudio/sln2005/platforms.lua @@ -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 + diff --git a/tests/test_vs2005_sln.lua b/tests/actions/vstudio/sln2005/projectplatforms.lua old mode 100644 new mode 100755 similarity index 50% rename from tests/test_vs2005_sln.lua rename to tests/actions/vstudio/sln2005/projectplatforms.lua index d37a144a..cd404323 --- a/tests/test_vs2005_sln.lua +++ b/tests/actions/vstudio/sln2005/projectplatforms.lua @@ -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 diff --git a/tests/actions/vstudio/sln2005/projects.lua b/tests/actions/vstudio/sln2005/projects.lua new file mode 100755 index 00000000..5aacafb7 --- /dev/null +++ b/tests/actions/vstudio/sln2005/projects.lua @@ -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 diff --git a/tests/actions/xcode/test_xcode_dependencies.lua b/tests/actions/xcode/test_xcode_dependencies.lua index c9f1c4ea..e4f09261 100644 --- a/tests/actions/xcode/test_xcode_dependencies.lua +++ b/tests/actions/xcode/test_xcode_dependencies.lua @@ -164,7 +164,6 @@ function suite.PBXGroup_ListsDependencies() prepare() xcode.PBXGroup(tr) --- test.print(io.endcapture()) test.capture [[ /* Begin PBXGroup section */ [MyProject] /* MyProject */ = { diff --git a/tests/premake4.lua b/tests/premake4.lua index 48dd459c..cef6297c 100644 --- a/tests/premake4.lua +++ b/tests/premake4.lua @@ -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 diff --git a/tests/test_vs2010_sln.lua b/tests/test_vs2010_sln.lua deleted file mode 100644 index a7ed582f..00000000 --- a/tests/test_vs2010_sln.lua +++ /dev/null @@ -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 - - - - - -