Removed some duplication from the Visual Studio actions

This commit is contained in:
Jason Perkins 2013-05-02 11:21:23 -04:00
parent 89a85f0250
commit f586b1695d
6 changed files with 214 additions and 158 deletions

View File

@ -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",

View File

@ -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

View File

@ -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",
}
}

View File

@ -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",
}
}

View File

@ -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",
}
}

View File

@ -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")