fix project dependencies.
This commit is contained in:
parent
b35082ba9b
commit
25045787e0
@ -380,7 +380,7 @@
|
||||
if not cfg._needsExplicitLink then
|
||||
local ex = cfg.flags.NoImplicitLink
|
||||
if not ex then
|
||||
local prjdeps = project.getdependencies(cfg.project)
|
||||
local prjdeps = project.getdependencies(cfg.project, "linkOnly")
|
||||
local cfgdeps = config.getlinks(cfg, "dependencies", "object")
|
||||
ex = #prjdeps ~= #cfgdeps
|
||||
end
|
||||
|
@ -325,7 +325,7 @@
|
||||
function cs2005.projectReferences(prj)
|
||||
_p(1,'<ItemGroup>')
|
||||
|
||||
local deps = project.getdependencies(prj, true)
|
||||
local deps = project.getdependencies(prj, 'linkOnly')
|
||||
if #deps > 0 then
|
||||
for _, dep in ipairs(deps) do
|
||||
local relpath = vstudio.path(prj, vstudio.projectfile(dep))
|
||||
|
@ -32,7 +32,7 @@
|
||||
|
||||
function sln2005.generate(wks)
|
||||
-- Mark the file as Unicode
|
||||
_p('\239\187\191')
|
||||
premake.utf8()
|
||||
|
||||
sln2005.reorderProjects(wks)
|
||||
|
||||
@ -127,7 +127,7 @@
|
||||
--
|
||||
|
||||
function sln2005.projectdependencies(prj)
|
||||
local deps = project.getdependencies(prj)
|
||||
local deps = project.getdependencies(prj, 'dependOnly')
|
||||
if #deps > 0 then
|
||||
_p(1,'ProjectSection(ProjectDependencies) = postProject')
|
||||
for _, dep in ipairs(deps) do
|
||||
|
@ -874,7 +874,7 @@
|
||||
end
|
||||
|
||||
function m.projectReferences(prj)
|
||||
local refs = project.getdependencies(prj)
|
||||
local refs = project.getdependencies(prj, 'linkOnly')
|
||||
if #refs > 0 then
|
||||
p.push('<ItemGroup>')
|
||||
for _, ref in ipairs(refs) do
|
||||
|
@ -158,16 +158,24 @@
|
||||
--
|
||||
-- @param prj
|
||||
-- The project to query.
|
||||
-- @param linkOnly
|
||||
-- If set, returns only siblings which are linked against (links) and skips
|
||||
-- siblings which are not (dependson).
|
||||
-- @param mode
|
||||
-- if mode == 'linkOnly', returns only siblings which are linked against (links) and skips siblings which are not (dependson).
|
||||
-- if mode == 'dependOnly' returns only siblings which are depended on (dependson) and skips siblings which are not (links).
|
||||
-- @return
|
||||
-- A list of dependent projects, as an array of project objects.
|
||||
---
|
||||
|
||||
function project.getdependencies(prj, linkOnly)
|
||||
function project.getdependencies(prj, mode)
|
||||
if not prj.dependencies then
|
||||
local result = {}
|
||||
prj.dependencies = {}
|
||||
end
|
||||
|
||||
local m = mode or 'all'
|
||||
local result = prj.dependencies[m]
|
||||
if result then
|
||||
return result
|
||||
end
|
||||
|
||||
local function add_to_project_list(cfg, depproj, result)
|
||||
local dep = p.workspace.findproject(cfg.workspace, depproj)
|
||||
if dep and not table.contains(result, dep) then
|
||||
@ -175,21 +183,27 @@
|
||||
end
|
||||
end
|
||||
|
||||
local linkOnly = m == 'linkOnly'
|
||||
local depsOnly = m == 'dependOnly'
|
||||
|
||||
result = {}
|
||||
for cfg in project.eachconfig(prj) do
|
||||
if not depsOnly then
|
||||
for _, link in ipairs(cfg.links) do
|
||||
if link ~= prj.name then
|
||||
add_to_project_list(cfg, link, result)
|
||||
end
|
||||
end
|
||||
end
|
||||
if not linkOnly then
|
||||
for _, depproj in ipairs(cfg.dependson) do
|
||||
add_to_project_list(cfg, depproj, result)
|
||||
end
|
||||
end
|
||||
end
|
||||
prj.dependencies = result
|
||||
end
|
||||
return prj.dependencies
|
||||
prj.dependencies[m] = result
|
||||
|
||||
return result
|
||||
end
|
||||
|
||||
|
||||
|
@ -45,7 +45,6 @@
|
||||
prepare("C++")
|
||||
test.capture [[
|
||||
ProjectSection(ProjectDependencies) = postProject
|
||||
{AE61726D-187C-E440-BD07-2556188A6565} = {AE61726D-187C-E440-BD07-2556188A6565}
|
||||
{2151E83B-997F-4A9D-955D-380157E88C31} = {2151E83B-997F-4A9D-955D-380157E88C31}
|
||||
EndProjectSection
|
||||
]]
|
||||
@ -60,7 +59,6 @@
|
||||
prepare("C#")
|
||||
test.capture [[
|
||||
ProjectSection(ProjectDependencies) = postProject
|
||||
{AE61726D-187C-E440-BD07-2556188A6565} = {AE61726D-187C-E440-BD07-2556188A6565}
|
||||
{2151E83B-997F-4A9D-955D-380157E88C31} = {2151E83B-997F-4A9D-955D-380157E88C31}
|
||||
EndProjectSection
|
||||
]]
|
||||
@ -77,7 +75,6 @@
|
||||
prepare("C#")
|
||||
test.capture [[
|
||||
ProjectSection(ProjectDependencies) = postProject
|
||||
{AE61726D-187C-E440-BD07-2556188A6565} = {AE61726D-187C-E440-BD07-2556188A6565}
|
||||
{2151E83B-997F-4A9D-955D-380157E88C31} = {2151E83B-997F-4A9D-955D-380157E88C31}
|
||||
EndProjectSection
|
||||
]]
|
||||
@ -94,7 +91,6 @@
|
||||
prepare("C#")
|
||||
test.capture [[
|
||||
ProjectSection(ProjectDependencies) = postProject
|
||||
{AE61726D-187C-E440-BD07-2556188A6565} = {AE61726D-187C-E440-BD07-2556188A6565}
|
||||
{2151E83B-997F-4A9D-955D-380157E88C31} = {2151E83B-997F-4A9D-955D-380157E88C31}
|
||||
EndProjectSection
|
||||
]]
|
||||
|
Reference in New Issue
Block a user