[*] Amend namespace iteration

This commit is contained in:
Reece Wilson 2021-06-07 18:27:58 +01:00
parent d625f7b9e2
commit d2750594dd

View File

@ -169,7 +169,7 @@ end
local processNS = function(namespace)
local projs = {}
local projsIdxs = {}
forEach(projectsprocessor, function(proj)
if (proj.info.namespace ~= namespace) then
return
@ -208,7 +208,6 @@ end
function attemptNS(ns)
local attemptLoad = false
if (not namespacesemitted[ns]) then
namespacesemitted[ns] = "";
dbgGroup(ns) -- only print the group once
attemptLoad = true
@ -218,19 +217,17 @@ function attemptNS(ns)
-- once you switch namespaces, theres no going back, it seems.
-- we try to preserve namespace-project contiguity as much as possible through sorting and evil recursion
namespace(ns)
if (attemptLoad) then
processNS(ns)
end
return attemptLoad
end
function processProject(name, required)
resolved = {}
function processProject(name, required, noNs)
local a = projectsprocessor[name]
if (not a) then
if (required) then
fatal("missing project: ", name)
else
print("missing: ", name)
return false
end
end
@ -242,23 +239,30 @@ function processProject(name, required)
a.isParsed = true
end
attemptNS(a.info.namespace)
if (projectsblocked[name]) then
return true
end
projectsblocked[name] = name
resolved[name] = name
if (not a.resolvedDeps) then
if (a.processor.resolveDependencies) then
a.processor:resolveDependencies(function(name, soft)
processProject(name, not soft)
if (resolved[name]) then
return
end
processProject(name, not soft, noNs)
end)
end
a.resolvedDeps = true
end
if (projectsblocked[name]) then
return true
end
projectsblocked[name] = name
local ns = a.info.namespace
local loadOthers = attemptNS(ns)
local cwd = os.getcwd()
local old = _G["current_project"]
@ -273,6 +277,11 @@ function processProject(name, required)
projectsemitted[name] = name
if (loadOthers) then
namespacesemitted[ns] = "";
processNS(ns)
end
return true
end