Merge pull request #398 from Blizzard/premake-extension-support

add premake extension data.
This commit is contained in:
Tom van Dijck 2016-01-14 13:45:54 -08:00
commit 99bf0bc8cd
4 changed files with 113 additions and 1 deletions

View File

@ -1077,6 +1077,12 @@
kind = "boolean",
}
api.register {
name = "editorintegration",
scope = "workspace",
kind = "boolean",
}
-----------------------------------------------------------------------------
--
-- Field name aliases for backward compatibility
@ -1361,6 +1367,7 @@
clr "Off"
exceptionhandling "Default"
rtti "Default"
editorintegration "On"
-- Setting a default language makes some validation easier later

View File

@ -29,6 +29,7 @@
"ConfigurationPlatforms",
"SolutionProperties",
"NestedProjects",
"ExtensibilityGlobals"
}
end
@ -292,6 +293,55 @@
end
--
-- Write out the ExtensibilityGlobals block, which embeds some data for the
-- Visual Studio PremakeExtension.
--
function sln2005.premakeExtensibilityGlobals(wks)
if wks.editorintegration then
-- we need to filter out the 'file' argument, since we already output
-- the script separately.
local args = {}
for _, arg in ipairs(_ARGV) do
if not (arg:startswith("--file") or arg:startswith("/file")) then
table.insert(args, arg);
end
end
p.w('PremakeBinary = %s', _PREMAKE_COMMAND)
p.w('PremakeScript = %s', p.workspace.getrelative(wks, _MAIN_SCRIPT))
p.w('PremakeArguments = %s', table.concat(args, ' '))
end
end
--
-- Map ExtensibilityGlobals to output functions.
--
sln2005.elements.extensibilityGlobals = function(wks)
return {
sln2005.premakeExtensibilityGlobals,
}
end
--
-- Output the ExtensibilityGlobals section.
--
function sln2005.extensibilityGlobals(wks)
local contents = p.capture(function ()
p.push()
p.callArray(sln2005.elements.extensibilityGlobals, wks)
p.pop()
end)
if #contents > 0 then
p.push('GlobalSection(ExtensibilityGlobals) = postSolution')
p.outln(contents)
p.pop('EndGlobalSection')
end
end
--
-- Map solution sections to output functions. Tools that aren't listed will
-- be ignored.
@ -301,7 +351,8 @@
return {
sln2005.configurationPlatforms,
sln2005.properties,
sln2005.NestedProjects
sln2005.NestedProjects,
sln2005.extensibilityGlobals,
}
end

View File

@ -81,6 +81,7 @@ return {
"actions/vstudio/sln2005/test_nested_projects.lua",
"actions/vstudio/sln2005/test_projects.lua",
"actions/vstudio/sln2005/test_platforms.lua",
"actions/vstudio/sln2005/test_sections.lua",
-- Visual Studio 2002-2008 C/C++ projects
"actions/vstudio/vc200x/test_assembly_refs.lua",

View File

@ -0,0 +1,53 @@
--
-- tests/actions/vstudio/sln2005/test_sections.lua
-- Validate generation of Visual Studio 2005+ solution section entries.
-- Copyright (c) 2009-2013 Jason Perkins and the Premake project
--
local suite = test.declare("vstudio_sln2005_sections")
local sln2005 = premake.vstudio.sln2005
--
-- Setup
--
local wks
function suite.setup()
_MAIN_SCRIPT = "c:\\test\\premake5.lua"
premake.escaper(premake.vstudio.vs2005.esc)
wks = workspace("MyWorkspace")
wks.location = "c:\\test\\build"
configurations { "Debug", "Release" }
language "C++"
kind "ConsoleApp"
end
--
-- Test the editorintegration switch.
--
function suite.extensibilityGlobalsOn()
editorintegration "On"
project "MyProject"
sln2005.extensibilityGlobals(wks)
test.capture [[
GlobalSection(ExtensibilityGlobals) = postSolution
]]
end
function suite.extensibilityGlobalsOff()
editorintegration "Off"
project "MyProject"
sln2005.extensibilityGlobals(wks)
local res = premake.captured()
if (#res > 0) then
test.fail("no editorintegration output was expected");
end
end