]> git.e2factory.org Git - e2factory.git/commitdiff
plugin support: allow extending dlist()
authorGordon Hecker <gh@emlix.com>
Thu, 4 Mar 2010 16:14:37 +0000 (17:14 +0100)
committerGordon Hecker <gh@emlix.com>
Fri, 5 Mar 2010 13:18:04 +0000 (14:18 +0100)
Signed-off-by: Gordon Hecker <gh@emlix.com>
local/e2build.lua
local/e2tool.lua

index 8f77ea2e7137742ecfebe50c9f3b1f19963574f5..f6d5d881f7acf281643b2c397a1b88cf25db7f11 100644 (file)
@@ -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)
index 72755fbbe510ee78d3ee187cbfb812398730a738..7bc930a5daf8296b6461435094d6f4e4c6163695 100644 (file)
@@ -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)