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