vs2010 sln

This commit is contained in:
LiamDevine 2010-06-10 16:42:45 +01:00
parent 5a7551d069
commit 375e4fafa7
7 changed files with 231 additions and 0 deletions

View File

@ -58,6 +58,8 @@
"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
"actions/xcode/_xcode.lua",

View File

@ -259,6 +259,8 @@
local extension
if (prj.language == "C#") then
extension = ".csproj"
elseif (_ACTION == "vs2010" and prj.language == "C++" )then
extension = ".vcxproj"
else
extension = ".vcproj"
end
@ -418,3 +420,37 @@
oncleanproject = premake.vstudio.cleanproject,
oncleantarget = premake.vstudio.cleantarget
}
local function ignore()
end
newaction
{
trigger = "vs2010",
shortname = "Visual Studio 2010",
description = "Generate Microsoft Visual Studio 2010 project files",
os = "windows",
valid_kinds = { "ConsoleApp", "WindowedApp", "StaticLib", "SharedLib" },
valid_languages = { "C++"},
valid_tools = {
cc = { "msc" },
--dotnet = { "msnet" },
},
onsolution = function(sln)
premake.generate(sln, "%%.sln", premake.vs_generic_solution)
end,
onproject = function(prj)
premake.generate(prj, "%%.vcxproj", premake.vs2010_vcxproj)
end,
oncleansolution = ignore, --premake.vstudio.cleansolution,
oncleanproject = ignore, --premake.vstudio.cleanproject,
oncleantarget = ignore --premake.vstudio.cleantarget
}

View File

@ -0,0 +1,66 @@
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, _VS.projectfile(prj)), "\\")
_p('Project("{%s}") = "%s", "%s", "{%s}"', _VS.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')
premake.vs2005_solution_platforms(sln)
premake.vs2005_solution_project_platforms(sln)
premake.vs2005_solution_properties(sln)
_p('EndGlobal')
end

View File

@ -63,8 +63,10 @@
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_vs2010_vcxproj.lua")
-- Xcode tests
dofile("actions/xcode/test_xcode_common.lua")

2
tests/test.bat Normal file
View File

@ -0,0 +1,2 @@
CALL ..\\bin\\debug\\premake4 /scripts=..\\src test

118
tests/test_vs2010_sln.lua Normal file
View File

@ -0,0 +1,118 @@
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()
io.capture()
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()
io.capture()
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

View File

@ -15,6 +15,11 @@
--
-- Assertion functions
--
function test.string_contains(buffer, expected)
if not string.find(buffer,expected) then
test.fail("\n==Fail==: Expected to find :\n%s\nyet it was not found in buffer:\n%s\n", expected,buffer)
end
end
function test.capture(expected)
local actual = io.endcapture()