]> git.e2factory.org Git - e2factory.git/commitdiff
project: move config verify into project module
authorTobias Ulmer <tu@emlix.com>
Fri, 21 Oct 2016 16:53:06 +0000 (18:53 +0200)
committerTobias Ulmer <tu@emlix.com>
Wed, 16 Nov 2016 14:41:18 +0000 (15:41 +0100)
Signed-off-by: Tobias Ulmer <tu@emlix.com>
local/e2tool.lua
local/project.lua

index 98fce35b52554442a421179dcbe5f124f0b975aa..76e65e19604369a2b47d5077156a26d6c9dabd3c 100644 (file)
@@ -320,33 +320,6 @@ function e2tool.sourceconfig(name, prefix)
     return e2lib.join(e2tool.sourcedir(name, prefix), "config")
 end
 
---- Checks project information for consistancy.
--- @return True on success, false on error.
--- @return Error object on failure.
-local function check_project_info()
-    local rc, re, e
-    e = err.new("error in project configuration")
-
-    for r in project.default_results_iter() do
-        if not result.results[r] then
-            e:append("default_results: No such result: %s", r)
-        end
-    end
-    for r in project.deploy_results_iter() do
-        if not result.results[r] then
-            e:append("deploy_results: No such result: %s", r)
-        end
-    end
-    if e:getcount() > 1 then
-        return false, e
-    end
-    rc, re = e2tool.dsort()
-    if not rc then
-        return false, e:cat(re)
-    end
-    return true
-end
-
 --- collect project info.
 -- @param info Info table.
 -- @param skip_load_config If true, skip loading config files etc.
@@ -468,6 +441,12 @@ function e2tool.collect_project_info(info, skip_load_config)
         return false, e:cat(re)
     end
 
+    -- after results are loaded, verify the project configuration
+    rc, re = project.verify_project_config()
+    if not rc then
+        return false, e:cat(re)
+    end
+
     if e:getcount() > 1 then
         return false, e
     end
@@ -549,11 +528,6 @@ function e2tool.collect_project_info(info, skip_load_config)
         end
     end
 
-    rc, re = check_project_info()
-    if not rc then
-        return false, re
-    end
-
     return strict.lock(info)
 end
 
index 2aa2877fea835d19246ad84f7a9a698b0bbf4fab..74318bbcf34662f7a6bc89700a54e4417377136c 100644 (file)
@@ -28,6 +28,7 @@ local e2tool = require("e2tool")
 local err = require("err")
 local hash = require("hash")
 local projenv = require("projenv")
+local result = require("result")
 local strict = require("strict")
 
 local _prj = {}
@@ -168,6 +169,34 @@ function project.load_project_config(info)
     return true
 end
 
+--- Checks project information for consistancy once results are loaded.
+-- @return True on success, false on error.
+-- @return Error object on failure.
+function project.verify_project_config()
+    local rc, re, e
+    e = err.new("error in project configuration")
+
+    for r in project.default_results_iter() do
+        if not result.results[r] then
+            e:append("default_results: No such result: %s", r)
+        end
+    end
+    for r in project.deploy_results_iter() do
+        if not result.results[r] then
+            e:append("deploy_results: No such result: %s", r)
+        end
+    end
+    if e:getcount() > 1 then
+        return false, e
+    end
+
+    rc, re = e2tool.dsort()
+    if not rc then
+        return false, e:cat(re)
+    end
+    return true
+end
+
 --- Get project name.
 -- @return Name.
 function project.name()