diff --git a/src/actions/vstudio/_vstudio.lua b/src/actions/vstudio/_vstudio.lua index 1d30967f..cd60b28a 100644 --- a/src/actions/vstudio/_vstudio.lua +++ b/src/actions/vstudio/_vstudio.lua @@ -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 diff --git a/src/actions/vstudio/vs2005_csproj.lua b/src/actions/vstudio/vs2005_csproj.lua index 53dae303..9ac8b3cc 100644 --- a/src/actions/vstudio/vs2005_csproj.lua +++ b/src/actions/vstudio/vs2005_csproj.lua @@ -325,7 +325,7 @@ function cs2005.projectReferences(prj) _p(1,'') - 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)) diff --git a/src/actions/vstudio/vs2005_solution.lua b/src/actions/vstudio/vs2005_solution.lua index 9f0a7882..8feb4cd9 100644 --- a/src/actions/vstudio/vs2005_solution.lua +++ b/src/actions/vstudio/vs2005_solution.lua @@ -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 diff --git a/src/actions/vstudio/vs2010_vcxproj.lua b/src/actions/vstudio/vs2010_vcxproj.lua index 06d68759..c37183f5 100644 --- a/src/actions/vstudio/vs2010_vcxproj.lua +++ b/src/actions/vstudio/vs2010_vcxproj.lua @@ -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('') for _, ref in ipairs(refs) do diff --git a/src/base/project.lua b/src/base/project.lua index e4aba8e0..a073de50 100755 --- a/src/base/project.lua +++ b/src/base/project.lua @@ -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 diff --git a/tests/actions/vstudio/sln2005/test_dependencies.lua b/tests/actions/vstudio/sln2005/test_dependencies.lua index c34e88db..488536e8 100755 --- a/tests/actions/vstudio/sln2005/test_dependencies.lua +++ b/tests/actions/vstudio/sln2005/test_dependencies.lua @@ -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 ]]