-- a list of results to build, topologically sorted
local sel_res = {}
if #results > 0 then
- sel_res = e2tool.dlist_recursive(info, results)
+ local re
+ sel_res, re = e2tool.dlist_recursive(info, results)
+ if not sel_res then
+ e2lib.abort(re)
+ end
else
- sel_res = e2tool.dsort(info)
+ local re
+ sel_res, re = e2tool.dsort(info)
+ if not sel_res then
+ e2lib.abort(re)
+ end
end
rc, re = e2tool.print_selection(info, sel_res)
e2lib.abort("no such result: ", result)
end
-local dep = opts.recursive
- and e2tool.dlist_recursive(info, result)
- or e2tool.dlist(info, result)
-
-if dep then
- for i = 1, #dep do print(dep[i]) end
+local dep, re
+if opts.recursive then
+ dep, re = e2tool.dlist_recursive(info, result)
+else
+ dep, re = e2tool.dlist(info, result)
+end
+if not dep then
+ e2lib.abort(re)
end
+for i = 1, #dep do print(dep[i]) end
+
e2lib.finish()
end
-- write topologically sorted list of result
local destdir = string.format("%s/project", res.build_config.T)
- local tsorted_results = e2tool.dlist_recursive(info,
+ local tsorted_results, re = e2tool.dlist_recursive(info,
res.collect_project_results)
+ if not tsorted_results then
+ return false, e:cat(re)
+ end
local tsorted_results_string = table.concat(tsorted_results, "\n")
local resultlist = string.format("%s/resultlist", destdir)
rc, re = e2lib.write_file(resultlist, tsorted_results_string .. "\n")
local t = {}
local function visit(res)
if had[res] then
- e2lib.warn("WOTHER", "cyclic dependency: " .. table.concat(path, " "))
- t = nil
+ return false, new_error("cyclic dependency: %s", table.concat(path, " "))
elseif t and not col[res] then
table.insert(path, res)
had[res] = true
col[res] = true
- for _, d in ipairs(e2tool.dlist(info, res)) do visit(d) end
+ for _, d in ipairs(e2tool.dlist(info, res)) do
+ local rc, re = visit(d)
+ if not rc then
+ return false, re
+ end
+ end
if t then table.insert(t, res) end
had[res] = nil
path[#path] = nil
end
+ return true
end
for _, r in ipairs(
type(result) == "table" and result or e2tool.dlist(info, result)) do
- visit(r)
+ local rc, re = visit(r)
+ if not rc then
+ return nil, re
+ end
end
- return t
+ return t, nil
end
function e2tool.dsort(info)
function e2tool.check_collect_project(info, resultname)
local res = info.results[resultname]
local e = new_error("in result %s:", resultname)
+ local rc, re
if not res.collect_project then
-- insert empty tables, to avoid some conditionals in the code
res.collect_project_results = {}
if e:getcount() > 1 then
return false, e
end
- res.collect_project_results = e2tool.dlist_recursive(info,
+ res.collect_project_results, re = e2tool.dlist_recursive(info,
res.collect_project_default_result)
+ if not res.collect_project_results then
+ return false, e:cat(re)
+ end
-- store a sorted list of required results
table.insert(res.collect_project_results,
res.collect_project_default_result)
end
end
if #results > 0 then
- results = e2tool.dlist_recursive(info, results)
+ results, re = e2tool.dlist_recursive(info, results)
+ if not results then
+ e2lib.abort(re)
+ end
else
- results = e2tool.dsort(info)
+ results, re = e2tool.dsort(info)
+ if not results then
+ e2lib.abort(re)
+ end
end
table.sort(results)