NEXT:
+ * the plugin interface was extended to permit plugins to register
+ commandline options and permit tool specific initialization of plugins
* a serious bug in the hashcache was fixed. The buildid calculation
used outdated hash of files from the project tree.
* the username is included in the chroot environment path again
require("e2local")
require("e2tool")
e2lib.init()
+local info, re = e2tool.local_init(nil, "build-numbers")
+if not info then
+ e2lib.abort(re)
+end
e2option.documentation = [[
usage:
if not build_mode then
e2lib.abort("no build mode given")
end
-local info, re = e2tool.collect_project_info()
+info, re = e2tool.collect_project_info(info)
if not info then
e2lib.abort(re)
end
require("e2tool")
require("e2build")
e2lib.init()
+local info, re = e2tool.local_init(nil, "build")
+if not info then
+ e2lib.abort(re)
+end
e2option.documentation = [[
usage: e2-build [<option> | <result> ...]
e2lib.abort("no build mode given")
end
-local info, re = e2tool.collect_project_info()
+info, re = e2tool.collect_project_info(info)
if not info then
e2lib.abort(re)
end
require("e2local")
require("e2tool")
e2lib.init()
+local info, re = e2tool.local_init(nil, "cf")
+if not info then
+ e2lib.abort(re)
+end
e2option.documentation = [[
usage: e2 cf <command> ...
-- initialize some basics in the info structure without actually loading
-- the project configuration.
-local info, re = e2tool.collect_project_info(nil, true)
+info, re = e2tool.collect_project_info(info, true)
if not info then
e2lib.abort(re)
end
require("e2tool")
require("e2build")
e2lib.init()
+local info, re = e2tool.local_init(nil, "dlist")
+if not info then
+ e2lib.abort(re)
+end
e2option.documentation = [[
usage: e2-dlist [<option> | <result> ...]
elseif #opts.arguments ~= 1 then e2option.usage(1) end
local result = opts.arguments[1]
-local info, re = e2tool.collect_project_info()
+info, re = e2tool.collect_project_info(info)
if not info then
e2lib.abort(re)
end
require("e2tool")
require("e2build")
e2lib.init()
+local info, re = e2tool.local_init(nil, "dsort")
+if not info then
+ e2lib.abort(re)
+end
e2option.documentation = [[
usage: e2-dsort
e2option.parse(arg)
-local info, re = e2tool.collect_project_info()
+info, re = e2tool.collect_project_info(info)
if not info then
e2lib.abort(re)
end
-- @param results table: list of results, sorted by dependencies
-- @return bool
-- @return an error object on failure
-function build_results(info, results)
+function build_results_default(info, results)
e2lib.logf(3, "building results")
for _, r in ipairs(results) do
local e = new_error("building result failed: %s", r)
return true, nil
end
+function build_results(info, results)
+ for i,f in ipairs(build_results_ftab) do
+ rc, re = f(info, results)
+ if not rc then
+ return rc, re
+ end
+ end
+ return true, nil
+end
+
+build_results_ftab = {
+ build_results_default,
+}
+
+function register_build_results(func, position, post)
+ for i,f in ipairs(build_results_ftab) do
+ if f == position then
+ if post then
+ table.insert(build_results_ftab, i + 1 ,func)
+ return true, nil
+ else
+ table.insert(build_results_ftab, i, func)
+ return true, nil
+ end
+ end
+ end
+ return false, new_error("registering build_results function failed")
+end
+
--- build a result
-- @param info
-- @param result string: result name
return list, nil
end
-function collect_project_info(path, skip_load_config)
+--- initialize the local library, load and initialize local plugins
+-- @param path string: path to project tree
+-- @param tool string: tool name (without the 'e2-' prefix)
+-- @return table: the info table, or false on failure
+-- @return an error object on failure
+function local_init(path, tool)
local rc, re
- local e = new_error("reading project configuration")
-
+ local e = new_error("initializing")
local info = {}
+ -- provide the current tool name to allow conditionals in plugin
+ -- initialization
+ info.current_tool = tool
+
-- set the umask value to be used in chroot
info.chroot_umask = 18 -- 0022 octal
init_umask(info)
return false, e:cat(re)
end
+ return info
+end
+
+function collect_project_info(info, skip_load_config)
+ local rc, re
+ local e = new_error("reading project configuration")
+
-- check for configuration compatibility
info.config_syntax_compat = buildconfig.SYNTAX
info.config_syntax_file = ".e2/syntax"
require("e2tool")
require("e2build")
e2lib.init()
+local info, re = e2tool.local_init(nil, "fetch-sources")
+if not info then
+ e2lib.abort(re)
+end
e2option.documentation = [[
usage: e2-fetch-sources <source> ...
e2option.flag("result", "select sources by result names")
local opts = e2option.parse(arg)
-local info, re = e2tool.collect_project_info()
+info, re = e2tool.collect_project_info(info)
if not info then
e2lib.abort(re)
end
require("e2local")
require("e2tool")
e2lib.init()
+local info, re = e2tool.local_init(nil, "ls-project")
+if not info then
+ e2lib.abort(re)
+end
e2option.documentation = [[
usage: e2-ls-project [<result> ...]
local opts = e2option.parse(arg)
-local info, re = e2tool.collect_project_info()
+info, re = e2tool.collect_project_info(info)
if not info then
e2lib.abort(re)
end
require("e2local")
require("e2tool")
e2lib.init()
+local info, re = e2tool.local_init(nil, "new-source")
+if not info then
+ e2lib.abort(re)
+end
e2option.documentation = [[
usage: e2-new-source --git [--server <server>] <name>
return true, nil
end
-local info, re = e2tool.collect_project_info()
+info, re = e2tool.collect_project_info(info)
if not info then
e2lib.abort(re)
end
require("e2tool")
require("e2build")
e2lib.init()
+local info, re = e2tool.local_init(nil, "playground")
+if not info then
+ e2lib.abort(re)
+end
local e = new_error("entering playground failed")
local rc, re
if not build_mode then
e2lib.abort("no build mode given")
end
-local info, re = e2tool.collect_project_info()
+info, re = e2tool.collect_project_info(info)
if not info then
e2lib.abort(re)
end