[*] Push current project info during dep resolve
[*] Better debugging auFatals
This commit is contained in:
parent
330b52364f
commit
7206d2f4a3
@ -104,7 +104,7 @@ local function auBlockProjectKeyDefines(processor, value)
|
|||||||
__pushFilter(value, "value", defines)
|
__pushFilter(value, "value", defines)
|
||||||
end
|
end
|
||||||
|
|
||||||
local function auBlockProjectKeyIncludes(processor, value, tasks, inc)
|
local function auBlockProjectKeyIncludes(processor, value, map, tasks, inc)
|
||||||
_includeDirectoryEx(processor:getMeta().path .. "/" .. value, not inc)
|
_includeDirectoryEx(processor:getMeta().path .. "/" .. value, not inc)
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -136,14 +136,14 @@ local function auBlockProjectKeySourcePaths(processor, value)
|
|||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
local function auBlockProjectKeyEval(processor, value, tasksMask)
|
local function auBlockProjectKeyEval(processor, value, map, tasksMask)
|
||||||
if (type(object) == "string") then
|
if (type(object) == "string") then
|
||||||
auEval(object)
|
auEval(object)
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
__pushFilter(value, nil, function(value)
|
__pushFilter(value, nil, function(value)
|
||||||
__pRunTasks(processor, value, auProjectBlockHandlers, kGenericTasks, true)
|
__pRunTasks(processor, value, map, tasksMask, true)
|
||||||
end)
|
end)
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -257,10 +257,10 @@ local function handleActionCommon(action, cb, ...)
|
|||||||
--_G["info"] = nil
|
--_G["info"] = nil
|
||||||
end
|
end
|
||||||
|
|
||||||
local function auBlockProjectKeyBuildAction(processor, value, mask)
|
local function auBlockProjectKeyBuildAction(processor, value, map, tasks)
|
||||||
__pushFilter(value, nil, function(value)
|
__pushFilter(value, nil, function(value)
|
||||||
handleActionCommon(value, function(thenblock)
|
handleActionCommon(value, function(thenblock)
|
||||||
auBlockProjectKeyEval(processor, thenblock, auProjectBlockHandlers)
|
auBlockProjectKeyEval(processor, thenblock, map, tasks)
|
||||||
end)
|
end)
|
||||||
end, processor)
|
end, processor)
|
||||||
end
|
end
|
||||||
@ -270,23 +270,39 @@ local function handleDepends(processor, dep, soft)
|
|||||||
dep = processor:translateDep(dep)
|
dep = processor:translateDep(dep)
|
||||||
local macro = ("_auhas_" .. dep):upper():gsub("%-", "_");
|
local macro = ("_auhas_" .. dep):upper():gsub("%-", "_");
|
||||||
|
|
||||||
if (auIsProjectIntialized(dep)) then
|
if (auGetProjectProcessor(dep)) then
|
||||||
defines(macro .. "=1")
|
defines(macro .. "=1")
|
||||||
auLinkAndRefProject(dep, soft)
|
auLinkAndRefProject(dep, soft)
|
||||||
else
|
else
|
||||||
defines(macro .. "=0")
|
--defines(macro .. "=0")
|
||||||
if (not soft) then
|
if (not soft) then
|
||||||
fatal("missing project: ", dep)
|
auFatal("missing project: ", dep)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
local function auBlockProjectKeyDepends(processor, value)
|
local function auBlockProjectKeyDepends(processor, value)
|
||||||
__pushFilter(value, "value", function(obj)
|
__pushFilter(value, "value", function(obj)
|
||||||
auForEach(obj, function(re)
|
handleDepends(processor, obj, false)
|
||||||
handleDepends(processor, re, false)
|
end, processor, true)
|
||||||
end)
|
end
|
||||||
end, processor)
|
|
||||||
|
local function auBlockProjectKeySoftDepends(processor, value)
|
||||||
|
__pushFilter(value, "value", function(obj)
|
||||||
|
handleDepends(processor, obj, true)
|
||||||
|
end, processor, true)
|
||||||
|
end
|
||||||
|
|
||||||
|
local function auBlockProjectRefKeyDepends(processor, value, taskMap, taskArray, inc, resolve)
|
||||||
|
__pushFilter(value, "value", function(obj)
|
||||||
|
resolve(processor:translateDep(obj), false)
|
||||||
|
end, processor, true)
|
||||||
|
end
|
||||||
|
|
||||||
|
local function auBlockProjectRefKeySoftDepends(processor, value, taskMap, taskArray, inc, resolve)
|
||||||
|
__pushFilter(value, "value", function(obj)
|
||||||
|
resolve(processor:translateDep(obj), true)
|
||||||
|
end, processor, true)
|
||||||
end
|
end
|
||||||
|
|
||||||
local function auBlockProjectKeyLua(processor, script)
|
local function auBlockProjectKeyLua(processor, script)
|
||||||
@ -338,30 +354,40 @@ auProjectBlockHandlers =
|
|||||||
features = auBlockKeyFeature
|
features = auBlockKeyFeature
|
||||||
}
|
}
|
||||||
|
|
||||||
|
auProjectBlockHandlers["soft-depends"] = auBlockProjectKeySoftDepends
|
||||||
|
|
||||||
|
local auProjectRefHandlers =
|
||||||
|
{
|
||||||
|
linkDepends = auHeaderProjectKeyLinkDepends,
|
||||||
|
eval = auBlockProjectKeyEval
|
||||||
|
}
|
||||||
|
auProjectRefHandlers["soft-depends"] = auBlockProjectRefKeySoftDepends
|
||||||
|
auProjectRefHandlers["depends"] = auBlockProjectRefKeyDepends
|
||||||
|
|
||||||
kGenericTasks = {"sourcePaths", "includes","include", "sources",
|
kGenericTasks = {"sourcePaths", "includes","include", "sources",
|
||||||
"impDefines", "implDefines", "implementationDefines",
|
"impDefines", "implDefines", "implementationDefines",
|
||||||
"impInclude", "implInclude", "impIncludes", "implIncludes", "clangIgnore",
|
"impInclude", "implInclude", "impIncludes", "implIncludes", "clangIgnore",
|
||||||
"msvcIgnore", "excludes", "depends", "require",
|
"msvcIgnore", "excludes", "depends", "require",
|
||||||
"eval", "lua", "events", "actions", "staticImpDefines", "features",
|
"eval", "lua", "events", "actions", "staticImpDefines", "features",
|
||||||
"links"
|
"links", "soft-depends"
|
||||||
}
|
}
|
||||||
|
|
||||||
local kReferenceTasks = {"eval", "includes", "include"} --, "features"}
|
local kReferenceTasks = {"eval", "includes", "include"} --, "features"}
|
||||||
|
|
||||||
|
|
||||||
__pRunTasks = function(processor, object, map, tasks, inc)
|
__pRunTasks = function(processor, object, map, tasks, inc, resolve)
|
||||||
auForEachKV(tasks, function(na, key)
|
auForEachKV(tasks, function(na, key)
|
||||||
local value = object[key]
|
local value = object[key]
|
||||||
if (not value) then
|
if (not value) then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
map[key](processor, value, tasks, inc)
|
map[key](processor, value, map, tasks, inc, resolve)
|
||||||
end)
|
end)
|
||||||
end
|
end
|
||||||
|
|
||||||
local function __pRunLinkTasks(processor, object)
|
local function __pRunLinkTasks(processor, object, resolve)
|
||||||
__pRunTasks(processor, object, auProjectBlockHandlers, { "links", "depends"})
|
__pRunTasks(processor, object, auProjectRefHandlers, { "links", "depends", "soft-depends", "eval"}, false, resolve)
|
||||||
end
|
end
|
||||||
|
|
||||||
local function __pRunIncludeTasks(processor, object, isIncludeLocalProject)
|
local function __pRunIncludeTasks(processor, object, isIncludeLocalProject)
|
||||||
|
@ -113,7 +113,7 @@ function JsonProcessor(info)
|
|||||||
local processJsonBlockForLinks = function(object, this)
|
local processJsonBlockForLinks = function(object, this)
|
||||||
auForEach(object.links, links)
|
auForEach(object.links, links)
|
||||||
auForEach(object.depends, handleDependsShort, this, false)
|
auForEach(object.depends, handleDependsShort, this, false)
|
||||||
auForEach(object["soft-depends"], handleDependsShort, this, true)
|
--auForEach(object["soft-depends"], handleDependsShort, this, true)
|
||||||
end
|
end
|
||||||
|
|
||||||
function handleEvalForLinks(object, this)
|
function handleEvalForLinks(object, this)
|
||||||
@ -239,18 +239,9 @@ function JsonProcessor(info)
|
|||||||
defines(("_auhas_" .. this.result.name):upper():gsub("%-", "_") .. "=1")
|
defines(("_auhas_" .. this.result.name):upper():gsub("%-", "_") .. "=1")
|
||||||
end
|
end
|
||||||
|
|
||||||
local handleDependsPreemptive = function(dep, this, soft, resolve)
|
|
||||||
dep = translateDep(this, dep)
|
|
||||||
|
|
||||||
if (not auIsProjectIntialized(dep)) then
|
|
||||||
resolve(dep, soft)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
local pokeDeps = function(this, resolve)
|
local pokeDeps = function(this, resolve)
|
||||||
local result = this.result
|
auRequire("Core/JSON/JSON").projectHandlers.runProjectLink(this, result, resolve)
|
||||||
auForEach(result.depends, handleDependsPreemptive, this, false, resolve)
|
|
||||||
auForEach(result["soft-depends"], handleDependsPreemptive, this, true, resolve)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
local handleParse = function(this)
|
local handleParse = function(this)
|
||||||
@ -383,7 +374,7 @@ function JsonProcessor(info)
|
|||||||
local processJsonBlock = function(object)
|
local processJsonBlock = function(object)
|
||||||
auRequire("Core/JSON/JSON").projectHandlers.runProjectBlock(a, object)
|
auRequire("Core/JSON/JSON").projectHandlers.runProjectBlock(a, object)
|
||||||
|
|
||||||
auForEach(object["soft-depends"], handleDepends, a, true)
|
--auForEach(object["soft-depends"], handleDepends, a, true)
|
||||||
auForEach(object.unpack, runCopies, info.path, info.name)
|
auForEach(object.unpack, runCopies, info.path, info.name)
|
||||||
addM4Defines(object.m4Defines)
|
addM4Defines(object.m4Defines)
|
||||||
end
|
end
|
||||||
|
@ -149,6 +149,23 @@ local function addScript(ina)
|
|||||||
_auProjects[info.name] = project
|
_auProjects[info.name] = project
|
||||||
end
|
end
|
||||||
|
|
||||||
|
local function pushProjectState(name, path, callback)
|
||||||
|
local cwd = os.getcwd()
|
||||||
|
local old = _auCurrentProject
|
||||||
|
|
||||||
|
_auCurrentProject = name
|
||||||
|
os.chdir(path)
|
||||||
|
|
||||||
|
callback()
|
||||||
|
|
||||||
|
os.chdir(cwd)
|
||||||
|
_auCurrentProject = old
|
||||||
|
end
|
||||||
|
|
||||||
|
local function pushProject(project, callback)
|
||||||
|
pushProjectState(project.info.name, project.info.path, callback)
|
||||||
|
end
|
||||||
|
|
||||||
-- private
|
-- private
|
||||||
local function processInit(project)
|
local function processInit(project)
|
||||||
if (project.isInitialized) then
|
if (project.isInitialized) then
|
||||||
@ -157,7 +174,9 @@ local function processInit(project)
|
|||||||
project.isInitialized = true
|
project.isInitialized = true
|
||||||
|
|
||||||
if (project.processor.init) then
|
if (project.processor.init) then
|
||||||
project.processor:init()
|
pushProject(project, function()
|
||||||
|
project.processor:init()
|
||||||
|
end)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -169,24 +188,30 @@ local function initializeDependencyTree(proj, resolveProject)
|
|||||||
|
|
||||||
if (not proj.resolvedDeps) then
|
if (not proj.resolvedDeps) then
|
||||||
if (proj.processor.resolveDependencies) then
|
if (proj.processor.resolveDependencies) then
|
||||||
proj.processor:resolveDependencies(function(name, soft)
|
pushProject(proj, function()
|
||||||
|
_auFatalMsg = {}
|
||||||
|
_auFatalMsg["starting resolve dependencies"] = proj.info.name
|
||||||
|
|
||||||
table.insert(proj.deps, name)
|
|
||||||
|
|
||||||
if (_auResolvedDep[name]) then
|
proj.processor:resolveDependencies(function(name, soft)
|
||||||
return
|
|
||||||
end
|
|
||||||
|
|
||||||
local depProj = _auProjects[name]
|
table.insert(proj.deps, name)
|
||||||
if (not depProj) then
|
|
||||||
if (not soft) then
|
if (_auResolvedDep[name]) then
|
||||||
auFatal("missing dependency: ", name)
|
return
|
||||||
else
|
|
||||||
return false
|
|
||||||
end
|
end
|
||||||
end
|
|
||||||
|
|
||||||
initializeDependencyTree(depProj, true)
|
local depProj = _auProjects[name]
|
||||||
|
if (not depProj) then
|
||||||
|
if (not soft) then
|
||||||
|
auFatal("missing dependency: ", name)
|
||||||
|
else
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
initializeDependencyTree(depProj, true)
|
||||||
|
end)
|
||||||
end)
|
end)
|
||||||
end
|
end
|
||||||
proj.resolvedDeps = true
|
proj.resolvedDeps = true
|
||||||
@ -216,10 +241,17 @@ local function processNS(namespace)
|
|||||||
return a:upper() < b:upper()
|
return a:upper() < b:upper()
|
||||||
end)
|
end)
|
||||||
|
|
||||||
|
|
||||||
|
_auFatalMsg = {}
|
||||||
|
_auFatalMsg["starting dependency tree"] = namespace
|
||||||
|
|
||||||
auForEach(projsIdxs, function(idx)
|
auForEach(projsIdxs, function(idx)
|
||||||
initializeDependencyTree(projs[idx], true)
|
initializeDependencyTree(projs[idx], true)
|
||||||
end)
|
end)
|
||||||
|
|
||||||
|
|
||||||
|
_auFatalMsg = {}
|
||||||
|
_auFatalMsg["starting projects"] = namespace
|
||||||
auForEach(projsIdxs, function(idx)
|
auForEach(projsIdxs, function(idx)
|
||||||
processProject(projs[idx].info.name)
|
processProject(projs[idx].info.name)
|
||||||
end)
|
end)
|
||||||
@ -253,6 +285,7 @@ local function attemptNS(ns)
|
|||||||
end
|
end
|
||||||
|
|
||||||
processProject = function(name, required, noNs)
|
processProject = function(name, required, noNs)
|
||||||
|
|
||||||
local a = _auProjects[name]
|
local a = _auProjects[name]
|
||||||
if (not a) then
|
if (not a) then
|
||||||
if (required) then
|
if (required) then
|
||||||
@ -275,18 +308,11 @@ processProject = function(name, required, noNs)
|
|||||||
local ns = a.info.namespace
|
local ns = a.info.namespace
|
||||||
local loadOthers = attemptNS(ns)
|
local loadOthers = attemptNS(ns)
|
||||||
|
|
||||||
-- {
|
pushProject(a, function()
|
||||||
local cwd = os.getcwd()
|
_auFatalMsg = {}
|
||||||
local old = _auCurrentProject
|
_auFatalMsg["processing project"] = a.info.name
|
||||||
|
|
||||||
_auCurrentProject = name
|
|
||||||
os.chdir(a.info.path)
|
|
||||||
|
|
||||||
a.processor:process()
|
a.processor:process()
|
||||||
|
end)
|
||||||
os.chdir(cwd)
|
|
||||||
_auCurrentProject = old
|
|
||||||
-- }
|
|
||||||
|
|
||||||
-- cont
|
-- cont
|
||||||
if (loadOthers) then
|
if (loadOthers) then
|
||||||
|
@ -1,8 +1,10 @@
|
|||||||
function auFatal(...)
|
function auFatal(...)
|
||||||
print("[!!!] Fatal Crash")
|
print("[!!!] Fatal Crash")
|
||||||
print("Error Message:")
|
if (_auFatalMsg) then
|
||||||
print(...)
|
print("Previous step: ", json.encode(_auFatalMsg))
|
||||||
print("Origin:")
|
end
|
||||||
|
print("Error Message: ", ...)
|
||||||
|
--print("Origin:")
|
||||||
print(debug.traceback())
|
print(debug.traceback())
|
||||||
os.exit(1)
|
os.exit(1)
|
||||||
end
|
end
|
Loading…
Reference in New Issue
Block a user