[*] Improve how dependencies are resolved to nuke a double lock bug
This commit is contained in:
parent
353237353a
commit
d625f7b9e2
@ -145,14 +145,25 @@ function JsonProcessor(info)
|
||||
return dep
|
||||
end
|
||||
|
||||
local handleDependsPreemptive = function(dep, this, soft)
|
||||
local handleDependsPreemptive = function(dep, this, soft, resolve)
|
||||
dep = translateDep(this, dep)
|
||||
|
||||
if (not isProjectLoaded(dep)) then
|
||||
processProject(dep, not soft)
|
||||
resolve(dep, soft)
|
||||
end
|
||||
end
|
||||
|
||||
local pokeDeps = function(this, resolve)
|
||||
local result = this.result
|
||||
forEach(result.depends, handleDependsPreemptive, this, false, resolve)
|
||||
forEach(result["soft-depends"], handleDependsPreemptive, this, true, resolve)
|
||||
end
|
||||
|
||||
local handleParse = function(this)
|
||||
|
||||
|
||||
end
|
||||
|
||||
local handleProcess = function (a)
|
||||
local result = a.result
|
||||
local name = a.info.name
|
||||
@ -160,11 +171,6 @@ function JsonProcessor(info)
|
||||
|
||||
local isUtility = false
|
||||
|
||||
forEach(result.depends, handleDependsPreemptive, a, false)
|
||||
forEach(result["soft-depends"], handleDependsPreemptive, a, true)
|
||||
|
||||
attemptNS(a.info.namespace)
|
||||
|
||||
if (result.type:lower() == "aurora") then
|
||||
local srcPath = path .. "/Source"
|
||||
local incPath = path .. "/Include"
|
||||
@ -209,8 +215,8 @@ function JsonProcessor(info)
|
||||
dependson(dep)
|
||||
end
|
||||
|
||||
local handleDepends = function(dep, soft)
|
||||
dep = translateDep(a, dep)
|
||||
local handleDepends = function(dep, this, soft)
|
||||
dep = translateDep(this, dep)
|
||||
|
||||
local proj = _G["projectsprocessor"][dep]
|
||||
if (not proj) then
|
||||
@ -221,14 +227,14 @@ function JsonProcessor(info)
|
||||
fatal("Missing project", dep)
|
||||
end
|
||||
|
||||
local iface = proj.processor
|
||||
|
||||
if (isWeakCircularReference(dep)) then
|
||||
print("handling circular reference", dep)
|
||||
iface:handleReference(true)
|
||||
return
|
||||
end
|
||||
|
||||
local iface = proj.processor
|
||||
|
||||
if (isProjectLoaded(dep)) then
|
||||
defines(("_auhas_" .. dep):upper() .. "=1")
|
||||
iface:handleReference()
|
||||
@ -358,6 +364,7 @@ function JsonProcessor(info)
|
||||
local interface = {}
|
||||
interface.result = result
|
||||
interface.info = info
|
||||
interface.resolveDependencies = pokeDeps
|
||||
interface.process = handleProcess
|
||||
interface.handleLink = handleLink
|
||||
interface.handleReference = handleReference
|
||||
|
@ -1,4 +1,5 @@
|
||||
function fatal(...)
|
||||
print(...)
|
||||
print(debug.traceback())
|
||||
os.exit(1)
|
||||
end
|
33
aurora.lua
33
aurora.lua
@ -225,27 +225,48 @@ function attemptNS(ns)
|
||||
end
|
||||
|
||||
function processProject(name, required)
|
||||
if (projectsblocked[name]) then
|
||||
return true
|
||||
end
|
||||
|
||||
projectsblocked[name] = name
|
||||
local a = projectsprocessor[name]
|
||||
if (not a) then
|
||||
if (required) then
|
||||
fatal("missing project: ", name)
|
||||
else
|
||||
print("missing: ", name)
|
||||
return false
|
||||
end
|
||||
end
|
||||
|
||||
if (not a.isParsed) then
|
||||
if (a.processor.parse) then
|
||||
a.processor:parse()
|
||||
end
|
||||
a.isParsed = true
|
||||
end
|
||||
|
||||
attemptNS(a.info.namespace)
|
||||
|
||||
if (projectsblocked[name]) then
|
||||
return true
|
||||
end
|
||||
projectsblocked[name] = name
|
||||
|
||||
|
||||
if (not a.resolvedDeps) then
|
||||
if (a.processor.resolveDependencies) then
|
||||
a.processor:resolveDependencies(function(name, soft)
|
||||
processProject(name, not soft)
|
||||
end)
|
||||
end
|
||||
a.resolvedDeps = true
|
||||
end
|
||||
|
||||
|
||||
local cwd = os.getcwd()
|
||||
local old = _G["current_project"]
|
||||
|
||||
_G["current_project"] = name
|
||||
os.chdir(a.info.path)
|
||||
|
||||
a.processor:process(a.processor)
|
||||
a.processor:process()
|
||||
|
||||
os.chdir(cwd)
|
||||
_G["current_project"] = old
|
||||
|
Loading…
Reference in New Issue
Block a user