Added missing extension targets section for custom rules

This commit is contained in:
Jason Perkins 2014-06-12 19:05:44 -04:00
parent bd49556345
commit 725e433929
4 changed files with 89 additions and 8 deletions

View File

@ -41,7 +41,7 @@
m.assemblyReferences,
m.files,
m.projectReferences,
m.import,
m.importExtensionTargets,
}
end
@ -1037,10 +1037,15 @@
end
function m.import(prj)
_p(1,'<Import Project="$(VCTargetsPath)\\Microsoft.Cpp.targets" />')
_p(1,'<ImportGroup Label="ExtensionTargets">')
_p(1,'</ImportGroup>')
function m.importExtensionTargets(prj)
p.w('<Import Project="$(VCTargetsPath)\\Microsoft.Cpp.targets" />')
p.push('<ImportGroup Label="ExtensionTargets">')
table.foreachi(prj.customRules, function(value)
value = path.translate(project.getrelative(prj, value))
value = path.appendExtension(value, ".targets")
p.x('<Import Project="%s" />', value)
end)
p.pop('</ImportGroup>')
end

View File

@ -1,10 +1,10 @@
--
-- tests/actions/vstudio/vc2010/test_import_extensions.lua
-- tests/actions/vstudio/vc2010/test_extension_settings.lua
-- Check the import extension settings block of a VS 2010 project.
-- Copyright (c) 2014 Jason Perkins and the Premake project
--
local suite = test.declare("vs2010_import_extensions")
local suite = test.declare("vs2010_import_settings")
local vc2010 = premake.vstudio.vc2010
local project = premake.project

View File

@ -0,0 +1,75 @@
--
-- tests/actions/vstudio/vc2010/test_extension_targets.lua
-- Check the import extension targets block of a VS 2010 project.
-- Copyright (c) 2014 Jason Perkins and the Premake project
--
local suite = test.declare("vs2010_import_targets")
local vc2010 = premake.vstudio.vc2010
local project = premake.project
--
-- Setup
--
local sln
function suite.setup()
sln = test.createsolution()
end
local function prepare()
local prj = test.getproject(sln)
vc2010.importExtensionTargets(prj)
end
--
-- Writes an empty element when no custom rules are specified.
--
function suite.structureIsCorrect_onDefaultValues()
prepare()
test.capture [[
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
]]
end
--
-- Writes entries for each project scoped custom rules path.
--
function suite.addsImport_onEachRulesFile()
customRules "MyRules"
customRules "MyOtherRules"
prepare()
test.capture [[
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
<Import Project="MyRules.targets" />
<Import Project="MyOtherRules.targets" />
</ImportGroup>
]]
end
--
-- Rule files use a project relative path.
--
function suite.usesProjectRelativePaths()
customRules "path/to/MyRules"
location "build"
prepare()
test.capture [[
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
<Import Project="..\path\to\MyRules.targets" />
</ImportGroup>
]]
end

View File

@ -168,12 +168,13 @@
dofile("actions/vstudio/vc2010/test_config_props.lua")
dofile("actions/vstudio/vc2010/test_debug_settings.lua")
dofile("actions/vstudio/vc2010/test_excluded_configs.lua")
dofile("actions/vstudio/vc2010/test_extension_settings.lua")
dofile("actions/vstudio/vc2010/test_extension_targets.lua")
dofile("actions/vstudio/vc2010/test_globals.lua")
dofile("actions/vstudio/vc2010/test_header.lua")
dofile("actions/vstudio/vc2010/test_files.lua")
dofile("actions/vstudio/vc2010/test_filter_ids.lua")
dofile("actions/vstudio/vc2010/test_filters.lua")
dofile("actions/vstudio/vc2010/test_import_extensions.lua")
dofile("actions/vstudio/vc2010/test_item_def_group.lua")
dofile("actions/vstudio/vc2010/test_link.lua")
dofile("actions/vstudio/vc2010/test_manifest.lua")