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