From 98c43626a6bc814ef6ce752b6e278a142ba466a7 Mon Sep 17 00:00:00 2001 From: Tobias Ulmer Date: Wed, 26 Feb 2014 12:12:00 +0100 Subject: [PATCH] Add getter/setter for info table Doesn't have to be passed as an argument everywhere. Signed-off-by: Tobias Ulmer --- local/e2tool.lua | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/local/e2tool.lua b/local/e2tool.lua index ffebb7e..70dd804 100644 --- a/local/e2tool.lua +++ b/local/e2tool.lua @@ -74,6 +74,7 @@ local e2tool_ftab = {} -- @field env table: env table -- @field env_files table: list of env files -- @field local_template_path Path to the local templates (string). +local _info = false --- table of sources records, keyed by source names -- @name sources @@ -435,6 +436,22 @@ local function get_depends(info, resultname) return t end +--- Set a new info table. +-- @param t Table to use for info. +-- @return The new info table. +function e2tool.set_info(t) + assert(type(t) == "table") + _info = t + return _info +end + +--- Return the info table. +-- @return Info table on success, +-- false if the info table has not been initialised yet. +function e2tool.info() + return _info +end + --- 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) @@ -443,7 +460,9 @@ end function e2tool.local_init(path, tool) local rc, re local e = err.new("initializing local tool") - local info = {} + local info + + info = e2tool.set_info({}) info.current_tool = tool @@ -531,7 +550,6 @@ local function load_env_config(info, file) local e = err.new("loading environment: %s", file) local rc, re - local info = info local load_env_config = load_env_config local merge_error = false local function mergeenv(data) -- 2.39.5