From 70d7a54704ae1b73cce2e0ec836f649f8f23486f Mon Sep 17 00:00:00 2001 From: Gordon Hecker Date: Thu, 4 Mar 2010 17:14:37 +0100 Subject: [PATCH] plugin support: allow extending dlist() Signed-off-by: Gordon Hecker --- local/e2build.lua | 2 +- local/e2tool.lua | 38 +++++++++++++++++++++++++++++++++++--- 2 files changed, 36 insertions(+), 4 deletions(-) diff --git a/local/e2build.lua b/local/e2build.lua index 8f77ea2..f6d5d88 100644 --- a/local/e2build.lua +++ b/local/e2build.lua @@ -549,7 +549,7 @@ function sources(info, r, return_flags) local e = new_error("installing build time dependencies") e2lib.log(3, string.format("install_build_time_dependencies")) local deps - deps = e2tool.dlist(info, r) + deps = e2tool.get_depends(info, r) for i, dep in pairs(deps) do local tmpdir = e2lib.mktempdir() local e = new_error("installing build time dependency failed: %s", dep) diff --git a/local/e2tool.lua b/local/e2tool.lua index 72755fb..7bc930a 100644 --- a/local/e2tool.lua +++ b/local/e2tool.lua @@ -403,11 +403,16 @@ function collect_project_info(path, skip_load_config) check_result = {}, -- f(info, resultname) resultid = {}, -- f(info, resultname) pbuildid = {}, -- f(info, resultname) + dlist = {}, -- f(info, resultname) } rc, re = register_check_result(info, check_result) if not rc then return nil, e:cat(re) end + rc, re = register_dlist(info, get_depends) + if not rc then + return nil, e:cat(re) + end -- load local plugins local ctx = { -- plugin context @@ -888,9 +893,28 @@ end -- If RESULT is a table, calculate dependencies for all elements, inclusive, -- otherwise calculate dependencies for RESULT, exclusive. -function dlist(info, res) - local t = info.results[res] and info.results[res].depends or {} - table.sort(t) +--- get dependencies for use in build order calculation +function get_depends(info, resultname) + local t = {} + local res = info.results[resultname] + if not res.depends then + return t + end + table.sort(res.depends) + for _,d in ipairs(res.depends) do + table.insert(t, d) + end + return t +end + +function dlist(info, resultname) + local t = {} + for _,f in ipairs(info.ftab.dlist) do + local deps = f(info, resultname) + for _,d in ipairs(deps) do + table.insert(t, d) + end + end return t end @@ -2803,6 +2827,14 @@ function register_pbuildid(info, func) return true, nil end +function register_dlist(info, func) + if type(info) ~= "table" or type(func) ~= "function" then + return false, new_error("register_dlist: invalid argument") + end + table.insert(info.ftab.dlist, func) + return true, nil +end + function load_env_config(info, file) e2lib.logf(4, "loading environment: %s", file) local e = new_error("loading environment: %s", file) -- 2.39.5