From f586b1695db0840f9c69e6249af027824de82481 Mon Sep 17 00:00:00 2001 From: Jason Perkins Date: Thu, 2 May 2013 11:21:23 -0400 Subject: [PATCH] Removed some duplication from the Visual Studio actions --- src/_manifest.lua | 3 + src/actions/vstudio/_vstudio.lua | 140 ------------------------------- src/actions/vstudio/vs2005.lua | 72 ++++++++++++++++ src/actions/vstudio/vs2008.lua | 57 +++++++++++++ src/actions/vstudio/vs2010.lua | 71 ++++++++++++++++ src/actions/vstudio/vs2012.lua | 29 +++---- 6 files changed, 214 insertions(+), 158 deletions(-) create mode 100644 src/actions/vstudio/vs2005.lua create mode 100644 src/actions/vstudio/vs2008.lua create mode 100644 src/actions/vstudio/vs2010.lua diff --git a/src/_manifest.lua b/src/_manifest.lua index b45f7e15..3b8f8f72 100644 --- a/src/_manifest.lua +++ b/src/_manifest.lua @@ -57,11 +57,14 @@ -- Visual Studio actions "actions/vstudio/_vstudio.lua", + "actions/vstudio/vs2005.lua", + "actions/vstudio/vs2008.lua", "actions/vstudio/vs200x_vcproj.lua", "actions/vstudio/vs200x_vcproj_user.lua", "actions/vstudio/vs2005_solution.lua", "actions/vstudio/vs2005_csproj.lua", "actions/vstudio/vs2005_csproj_user.lua", + "actions/vstudio/vs2010.lua", "actions/vstudio/vs2010_vcxproj.lua", "actions/vstudio/vs2010_vcxproj_user.lua", "actions/vstudio/vs2010_vcxproj_filters.lua", diff --git a/src/actions/vstudio/_vstudio.lua b/src/actions/vstudio/_vstudio.lua index 43b77fc2..1e99f9c0 100644 --- a/src/actions/vstudio/_vstudio.lua +++ b/src/actions/vstudio/_vstudio.lua @@ -11,146 +11,6 @@ local config = premake5.config --- --- The Visual Studio action definitions --- - - newaction { - trigger = "vs2005", - shortname = "Visual Studio 2005", - description = "Generate Microsoft Visual Studio 2005 project files", - os = "windows", - - -- temporary, until I can phase out the legacy implementations - isnextgen = true, - - valid_kinds = { "ConsoleApp", "WindowedApp", "StaticLib", "SharedLib" }, - - valid_languages = { "C", "C++", "C#" }, - - valid_tools = { - cc = { "msc" }, - dotnet = { "msnet" }, - }, - - onsolution = function(sln) - premake.generate(sln, ".sln", vstudio.sln2005.generate_ng) - end, - - onproject = function(prj) - if project.isdotnet(prj) then - premake.generate(prj, ".csproj", vstudio.cs2005.generate_ng) - premake.generate(prj, ".csproj.user", vstudio.cs2005.generate_user_ng) - else - premake.generate(prj, ".vcproj", vstudio.vc200x.generate) - premake.generate(prj, ".vcproj.user", vstudio.vc200x.generate_user) - end - end, - - oncleansolution = vstudio.cleansolution, - oncleanproject = vstudio.cleanproject, - oncleantarget = vstudio.cleantarget, - - vstudio = { - csprojSchemaVersion = "2.0", - productVersion = "8.0.50727", - solutionVersion = "9", - } - } - - - newaction { - trigger = "vs2008", - shortname = "Visual Studio 2008", - description = "Generate Microsoft Visual Studio 2008 project files", - os = "windows", - - -- temporary, until I can phase out the legacy implementations - isnextgen = true, - - valid_kinds = { "ConsoleApp", "WindowedApp", "StaticLib", "SharedLib" }, - - valid_languages = { "C", "C++", "C#" }, - - valid_tools = { - cc = { "msc" }, - dotnet = { "msnet" }, - }, - - onsolution = function(sln) - premake.generate(sln, ".sln", vstudio.sln2005.generate_ng) - end, - - onproject = function(prj) - if project.isdotnet(prj) then - premake.generate(prj, ".csproj", vstudio.cs2005.generate_ng) - premake.generate(prj, ".csproj.user", vstudio.cs2005.generate_user_ng) - else - premake.generate(prj, ".vcproj", vstudio.vc200x.generate) - premake.generate(prj, ".vcproj.user", vstudio.vc200x.generate_user) - end - end, - - oncleansolution = vstudio.cleansolution, - oncleanproject = vstudio.cleanproject, - oncleantarget = vstudio.cleantarget, - - vstudio = { - csprojSchemaVersion = "2.0", - productVersion = "9.0.21022", - solutionVersion = "10", - toolsVersion = "3.5", - } - } - - - newaction { - trigger = "vs2010", - shortname = "Visual Studio 2010", - description = "Generate Visual Studio 2010 project files", - os = "windows", - - -- temporary, until I can phase out the legacy implementations - isnextgen = true, - - valid_kinds = { "ConsoleApp", "WindowedApp", "StaticLib", "SharedLib", "Makefile" }, - - valid_languages = { "C", "C++", "C#" }, - - valid_tools = { - cc = { "msc" }, - dotnet = { "msnet" }, - }, - - onsolution = function(sln) - premake.generate(sln, ".sln", vstudio.sln2005.generate_ng) - end, - - onproject = function(prj) - if project.isdotnet(prj) then - premake.generate(prj, ".csproj", vstudio.cs2005.generate_ng) - premake.generate(prj, ".csproj.user", vstudio.cs2005.generate_user_ng) - else - premake.generate(prj, ".vcxproj", vstudio.vc2010.generate) - premake.generate(prj, ".vcxproj.user", vstudio.vc2010.generateUser) - premake.generate(prj, ".vcxproj.filters", vstudio.vc2010.generateFilters) - end - end, - - oncleansolution = vstudio.cleansolution, - oncleanproject = vstudio.cleanproject, - oncleantarget = vstudio.cleantarget, - - vstudio = { - csprojSchemaVersion = "2.0", - productVersion = "8.0.30703", - solutionVersion = "11", - targetFramework = "4.0", - toolsVersion = "4.0", - } - } - - -- -- Mapping tables from Premake systems and architectures to Visual Studio -- identifiers. Broken out as tables so new values can be pushed in by diff --git a/src/actions/vstudio/vs2005.lua b/src/actions/vstudio/vs2005.lua new file mode 100644 index 00000000..802173af --- /dev/null +++ b/src/actions/vstudio/vs2005.lua @@ -0,0 +1,72 @@ +-- +-- actions/vstudio/vs2005.lua +-- Add support for the Visual Studio 2005 project formats. +-- Copyright (c) 2008-2013 Jason Perkins and the Premake project +-- + + premake.vstudio.vs2005 = {} + local vs2005 = premake.vstudio.vs2005 + local vstudio = premake.vstudio + + +--- +-- Register a command-line action for Visual Studio 2006. +--- + + function vs2005.generateSolution(sln) + premake.generate(sln, ".sln", vstudio.sln2005.generate_ng) + end + + + function vs2005.generateProject(prj) + if premake5.project.isdotnet(prj) then + premake.generate(prj, ".csproj", vstudio.cs2005.generate_ng) + premake.generate(prj, ".csproj.user", vstudio.cs2005.generate_user_ng) + else + premake.generate(prj, ".vcproj", vstudio.vc200x.generate) + premake.generate(prj, ".vcproj.user", vstudio.vc200x.generate_user) + end + end + + + newaction { + -- Metadata for the command line and help system + + trigger = "vs2005", + shortname = "Visual Studio 2005", + description = "Generate Visual Studio 2005 project files", + + -- Visual Studio always uses Windows path and naming conventions + + os = "windows", + + -- temporary, until I can phase out the legacy implementations + + isnextgen = true, + + -- The capabilities of this action + + valid_kinds = { "ConsoleApp", "WindowedApp", "StaticLib", "SharedLib", "Makefile" }, + valid_languages = { "C", "C++", "C#" }, + valid_tools = { + cc = { "msc" }, + dotnet = { "msnet" }, + }, + + -- Solution and project generation logic + + onsolution = vstudio.vs2005.generateSolution, + onproject = vstudio.vs2005.generateProject, + + oncleansolution = vstudio.cleanSolution, + oncleanproject = vstudio.cleanProject, + oncleantarget = vstudio.cleanTarget, + + -- This stuff is specific to the Visual Studio exporters + + vstudio = { + csprojSchemaVersion = "2.0", + productVersion = "8.0.50727", + solutionVersion = "9", + } + } diff --git a/src/actions/vstudio/vs2008.lua b/src/actions/vstudio/vs2008.lua new file mode 100644 index 00000000..971d1a36 --- /dev/null +++ b/src/actions/vstudio/vs2008.lua @@ -0,0 +1,57 @@ +-- +-- actions/vstudio/vs2008.lua +-- Add support for the Visual Studio 2008 project formats. +-- Copyright (c) 2008-2013 Jason Perkins and the Premake project +-- + + premake.vstudio.vs2008 = {} + local vs2008 = premake.vstudio.vs2008 + local vstudio = premake.vstudio + + +--- +-- Register a command-line action for Visual Studio 2008. +--- + + newaction { + -- Metadata for the command line and help system + + trigger = "vs2008", + shortname = "Visual Studio 2008", + description = "Generate Visual Studio 2008 project files", + + -- Visual Studio always uses Windows path and naming conventions + + os = "windows", + + -- temporary, until I can phase out the legacy implementations + + isnextgen = true, + + -- The capabilities of this action + + valid_kinds = { "ConsoleApp", "WindowedApp", "StaticLib", "SharedLib", "Makefile" }, + valid_languages = { "C", "C++", "C#" }, + valid_tools = { + cc = { "msc" }, + dotnet = { "msnet" }, + }, + + -- Solution and project generation logic + + onsolution = vstudio.vs2005.generateSolution, + onproject = vstudio.vs2005.generateProject, + + oncleansolution = vstudio.cleanSolution, + oncleanproject = vstudio.cleanProject, + oncleantarget = vstudio.cleanTarget, + + -- This stuff is specific to the Visual Studio exporters + + vstudio = { + csprojSchemaVersion = "2.0", + productVersion = "9.0.21022", + solutionVersion = "10", + toolsVersion = "3.5", + } + } diff --git a/src/actions/vstudio/vs2010.lua b/src/actions/vstudio/vs2010.lua new file mode 100644 index 00000000..370eac97 --- /dev/null +++ b/src/actions/vstudio/vs2010.lua @@ -0,0 +1,71 @@ +-- +-- actions/vstudio/vs2010.lua +-- Add support for the Visual Studio 2010 project formats. +-- Copyright (c) 2009-2013 Jason Perkins and the Premake project +-- + + premake.vstudio.vs2010 = {} + local vs2010 = premake.vstudio.vs2010 + local vstudio = premake.vstudio + + + +--- +-- Register a command-line action for Visual Studio 2010. +--- + + function vs2010.generateProject(prj) + if premake5.project.isdotnet(prj) then + premake.generate(prj, ".csproj", vstudio.cs2005.generate_ng) + premake.generate(prj, ".csproj.user", vstudio.cs2005.generate_user_ng) + else + premake.generate(prj, ".vcxproj", vstudio.vc2010.generate) + premake.generate(prj, ".vcxproj.user", vstudio.vc2010.generateUser) + premake.generate(prj, ".vcxproj.filters", vstudio.vc2010.generateFilters) + end + end + + + newaction { + -- Metadata for the command line and help system + + trigger = "vs2010", + shortname = "Visual Studio 2010", + description = "Generate Visual Studio 2010 project files", + + -- Visual Studio always uses Windows path and naming conventions + + os = "windows", + + -- temporary, until I can phase out the legacy implementations + + isnextgen = true, + + -- The capabilities of this action + + valid_kinds = { "ConsoleApp", "WindowedApp", "StaticLib", "SharedLib", "Makefile" }, + valid_languages = { "C", "C++", "C#" }, + valid_tools = { + cc = { "msc" }, + dotnet = { "msnet" }, + }, + + -- Solution and project generation logic + + onsolution = vstudio.vs2005.generateSolution, + onproject = vstudio.vs2010.generateProject, + + oncleansolution = vstudio.cleanSolution, + oncleanproject = vstudio.cleanProject, + oncleantarget = vstudio.cleanTarget, + + -- This stuff is specific to the Visual Studio exporters + + vstudio = { + csprojSchemaVersion = "2.0", + productVersion = "8.0.30703", + solutionVersion = "11", + targetFramework = "4.0", + toolsVersion = "4.0", + } + } diff --git a/src/actions/vstudio/vs2012.lua b/src/actions/vstudio/vs2012.lua index 627f75c6..fde53178 100644 --- a/src/actions/vstudio/vs2012.lua +++ b/src/actions/vstudio/vs2012.lua @@ -15,17 +15,21 @@ newaction { -- Metadata for the command line and help system + trigger = "vs2012", shortname = "Visual Studio 2012", description = "Generate Visual Studio 2012 project files", -- Visual Studio always uses Windows path and naming conventions + os = "windows", -- temporary, until I can phase out the legacy implementations + isnextgen = true, -- The capabilities of this action + valid_kinds = { "ConsoleApp", "WindowedApp", "StaticLib", "SharedLib", "Makefile" }, valid_languages = { "C", "C++", "C#" }, valid_tools = { @@ -34,27 +38,16 @@ }, -- Solution and project generation logic - -- TODO: Merge these with the other actions; no need to replicate each time - onsolution = function(sln) - premake.generate(sln, ".sln", vstudio.sln2005.generate_ng) - end, - onproject = function(prj) - if premake5.project.isdotnet(prj) then - premake.generate(prj, ".csproj", vstudio.cs2005.generate_ng) - premake.generate(prj, ".csproj.user", vstudio.cs2005.generate_user_ng) - else - premake.generate(prj, ".vcxproj", vstudio.vc2010.generate) - premake.generate(prj, ".vcxproj.user", vstudio.vc2010.generateUser) - premake.generate(prj, ".vcxproj.filters", vstudio.vc2010.generateFilters) - end - end, + onsolution = vstudio.vs2005.generateSolution, + onproject = vstudio.vs2010.generateProject, - oncleansolution = vstudio.cleansolution, - oncleanproject = vstudio.cleanproject, - oncleantarget = vstudio.cleantarget, + oncleansolution = vstudio.cleanSolution, + oncleanproject = vstudio.cleanProject, + oncleantarget = vstudio.cleanTarget, -- This stuff is specific to the Visual Studio exporters + vstudio = { solutionVersion = "12", targetFramework = "4.5", @@ -65,7 +58,7 @@ --- -- Add new elements to the configuration properties block of C++ projects. --- +--- table.insertafter(vc2010.elements.configurationProperties, "characterSet", "platformToolset")