Ported VC2010 project references
This commit is contained in:
parent
3230c3ea69
commit
1fdc480339
@ -53,10 +53,10 @@
|
||||
end
|
||||
|
||||
vc2010.files_ng(prj)
|
||||
vc2010.projectReferences_ng(prj)
|
||||
|
||||
|
||||
--[[
|
||||
vc2010.projectReferences(prj)
|
||||
|
||||
_p(1,'<Import Project="$(VCTargetsPath)\\Microsoft.Cpp.targets" />')
|
||||
_p(1,'<ImportGroup Label="ExtensionTargets">')
|
||||
_p(1,'</ImportGroup>')
|
||||
@ -449,6 +449,26 @@
|
||||
end
|
||||
|
||||
|
||||
--
|
||||
-- Generate the list of project dependencies.
|
||||
--
|
||||
|
||||
function vc2010.projectReferences_ng(prj)
|
||||
local deps = project.getdependencies(prj)
|
||||
if #deps > 0 then
|
||||
_p(1,'<ItemGroup>')
|
||||
for _, dep in ipairs(deps) do
|
||||
local slnpath = premake.solution.getlocation(prj.solution)
|
||||
local relpath = path.getrelative(slnpath, vstudio.projectfile(dep))
|
||||
_x(2,'<ProjectReference Include=\"%s\">', path.translate(relpath))
|
||||
_p(3,'<Project>{%s}</Project>', dep.uuid)
|
||||
_p(2,'</ProjectReference>')
|
||||
end
|
||||
_p(1,'</ItemGroup>')
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
--
|
||||
-- Write out the <AdditionalIncludeDirectories> element, which is used by
|
||||
-- both the compiler and resource compiler blocks.
|
||||
|
@ -5,6 +5,7 @@
|
||||
--
|
||||
|
||||
premake.solution = { }
|
||||
local solution = premake.solution
|
||||
local oven = premake5.oven
|
||||
local project = premake5.project
|
||||
|
||||
@ -21,7 +22,7 @@
|
||||
-- The new solution's name.
|
||||
--
|
||||
|
||||
function premake.solution.new(name)
|
||||
function solution.new(name)
|
||||
local sln = { }
|
||||
|
||||
-- add to master list keyed by both name and index
|
||||
@ -47,7 +48,7 @@
|
||||
-- An iterator function.
|
||||
--
|
||||
|
||||
function premake.solution.each()
|
||||
function solution.each()
|
||||
local i = 0
|
||||
return function ()
|
||||
i = i + 1
|
||||
@ -67,7 +68,7 @@
|
||||
-- An iterator function.
|
||||
--
|
||||
|
||||
function premake.solution.eachproject(sln)
|
||||
function solution.eachproject(sln)
|
||||
local i = 0
|
||||
return function ()
|
||||
i = i + 1
|
||||
@ -87,7 +88,7 @@
|
||||
-- An iterator function, returning project configurations.
|
||||
--
|
||||
|
||||
function premake.solution.eachproject_ng(sln)
|
||||
function solution.eachproject_ng(sln)
|
||||
local i = 0
|
||||
return function ()
|
||||
i = i + 1
|
||||
@ -109,7 +110,7 @@
|
||||
-- The project object, or nil if a matching project could not be found.
|
||||
--
|
||||
|
||||
function premake.solution.findproject(sln, name)
|
||||
function solution.findproject(sln, name)
|
||||
name = name:lower()
|
||||
for _, prj in ipairs(sln.projects) do
|
||||
if name == prj.name:lower() then
|
||||
@ -129,7 +130,7 @@
|
||||
-- The solution with the provided key.
|
||||
--
|
||||
|
||||
function premake.solution.get(key)
|
||||
function solution.get(key)
|
||||
return premake.solution.list[key]
|
||||
end
|
||||
|
||||
@ -143,7 +144,7 @@
|
||||
-- The path to the solutions's file system location.
|
||||
--
|
||||
|
||||
function premake.solution.getlocation(sln)
|
||||
function solution.getlocation(sln)
|
||||
return sln.location or sln.basedir
|
||||
end
|
||||
|
||||
@ -159,7 +160,7 @@
|
||||
-- The project at the given index.
|
||||
--
|
||||
|
||||
function premake.solution.getproject(sln, idx)
|
||||
function solution.getproject(sln, idx)
|
||||
-- retrieve the root configuration of the project, with all of
|
||||
-- the global (not configuration specific) settings collapsed
|
||||
local prj = sln.projects[idx]
|
||||
@ -182,7 +183,7 @@
|
||||
-- The project configuration at the given index.
|
||||
--
|
||||
|
||||
function premake.solution.getproject_ng(sln, idx)
|
||||
function solution.getproject_ng(sln, idx)
|
||||
local prj = sln.projects[idx]
|
||||
|
||||
local cfg = oven.merge({}, sln)
|
||||
|
@ -153,6 +153,36 @@
|
||||
end
|
||||
|
||||
|
||||
--
|
||||
-- If a sibling library is listed in links(), it should NOT appear in
|
||||
-- the additional dependencies element. Visual Studio will figure that
|
||||
-- out from the project reference item group.
|
||||
--
|
||||
|
||||
function suite.noDependencies_onOnlySiblingProjectLinks()
|
||||
links { "MyProject2" }
|
||||
test.createproject(sln)
|
||||
prepare()
|
||||
test.capture [[
|
||||
<Link>
|
||||
<SubSystem>Windows</SubSystem>
|
||||
<GenerateDebugInformation>false</GenerateDebugInformation>
|
||||
]]
|
||||
end
|
||||
|
||||
function suite.onlySystemDependencies_OnSiblingProjectLink()
|
||||
links { "MyProject2", "kernel32" }
|
||||
test.createproject(sln)
|
||||
prepare()
|
||||
test.capture [[
|
||||
<Link>
|
||||
<SubSystem>Windows</SubSystem>
|
||||
<GenerateDebugInformation>false</GenerateDebugInformation>
|
||||
<AdditionalDependencies>kernel32.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
]]
|
||||
end
|
||||
|
||||
|
||||
--
|
||||
-- Static libraries do not link dependencies directly, to maintain
|
||||
-- compatibility with GCC and others.
|
||||
|
58
tests/actions/vstudio/vc2010/test_project_refs.lua
Normal file
58
tests/actions/vstudio/vc2010/test_project_refs.lua
Normal file
@ -0,0 +1,58 @@
|
||||
--
|
||||
-- tests/actions/vstudio/vc2010/test_project_refs.lua
|
||||
-- Validate project references in Visual Studio 2010 C/C++ projects.
|
||||
-- Copyright (c) 2011-2012 Jason Perkins and the Premake project
|
||||
--
|
||||
|
||||
T.vstudio_vs2010_project_refs = { }
|
||||
local suite = T.vstudio_vs2010_project_refs
|
||||
local vc2010 = premake.vstudio.vc2010
|
||||
local project = premake5.project
|
||||
|
||||
|
||||
--
|
||||
-- Setup
|
||||
--
|
||||
|
||||
local sln, prj
|
||||
|
||||
function suite.setup()
|
||||
_ACTION = "vs2010"
|
||||
sln = test.createsolution()
|
||||
uuid "00112233-4455-6677-8888-99AABBCCDDEE"
|
||||
test.createproject(sln)
|
||||
end
|
||||
|
||||
local function prepare(platform)
|
||||
prj = premake.solution.getproject_ng(sln, 2)
|
||||
vc2010.projectReferences_ng(prj)
|
||||
end
|
||||
|
||||
|
||||
--
|
||||
-- If there are no sibling projects listed in links(), then the
|
||||
-- entire project references item group should be skipped.
|
||||
--
|
||||
|
||||
function suite.noProjectReferencesGroup_onNoSiblingReferences()
|
||||
prepare()
|
||||
test.isemptycapture()
|
||||
end
|
||||
|
||||
--
|
||||
-- If a sibling project is listed in links(), an item group should
|
||||
-- be written with a reference to that sibling project.
|
||||
--
|
||||
|
||||
function suite.projectReferenceAdded_onSiblingProjectLink()
|
||||
links { "MyProject" }
|
||||
prepare()
|
||||
test.capture [[
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="MyProject.vcxproj">
|
||||
<Project>{00112233-4455-6677-8888-99AABBCCDDEE}</Project>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
]]
|
||||
end
|
||||
|
@ -126,6 +126,7 @@
|
||||
dofile("actions/vstudio/vc2010/test_mfc.lua")
|
||||
dofile("actions/vstudio/vc2010/test_output_props.lua")
|
||||
dofile("actions/vstudio/vc2010/test_project_configs.lua")
|
||||
dofile("actions/vstudio/vc2010/test_project_refs.lua")
|
||||
dofile("actions/vstudio/vc2010/test_prop_sheet.lua")
|
||||
dofile("actions/vstudio/vc2010/test_resource_compile.lua")
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user