]> git.e2factory.org Git - e2factory.git/commitdiff
e2tool: extend resultdir(), sourceconfig() and friends by an optional prefix
authorTobias Ulmer <tu@emlix.com>
Fri, 6 Dec 2013 13:43:30 +0000 (14:43 +0100)
committerTobias Ulmer <tu@emlix.com>
Wed, 16 Nov 2016 14:41:17 +0000 (15:41 +0100)
Signed-off-by: Tobias Ulmer <tu@emlix.com>
local/e2tool.lua

index eeba83b6962fd622ae2c4ad4ab7b2f4710797f42..06168b86f82259d54bf90a85e38f029e744d24de 100644 (file)
@@ -1067,49 +1067,62 @@ local function load_source_config(info)
     return true, nil
 end
 
---- Get directory for a result.
--- Returns the relative path to the resultdir and optionally a name
--- (e.g. res/name).
--- @param name optional path component (string).
+--- Get project-relative directory for a result.
+-- Returns the relative path to the resultdir and optionally a name and prefix
+-- (e.g. prefix/res/name).
+-- @param name Optional result path component (string).
+-- @param prefix Optional prefix path.
 -- @return Path of the result.
-function e2tool.resultdir(name)
+function e2tool.resultdir(name, prefix)
+    local p = "res"
     if name then
-        return e2lib.join("res", name)
+        p = e2lib.join(p, name)
     end
-    return "res"
+    if prefix then
+        p = e2lib.join(prefix, p)
+    end
+    return p
 end
 
---- Get directory for a source.
--- Returns the relative path to the sourcedir and optinally a name
--- (e.g. src/name).
--- @param name optional path component (string).
+--- Get project-relative directory for a source.
+-- Returns the relative path to the sourcedir and optinally a name and prefix
+-- (e.g. prefix/src/name).
+-- @param name Optional source path component (string).
+-- @param prefix Optional prefix path.
 -- @return Path of the source.
-function e2tool.sourcedir(name)
+function e2tool.sourcedir(name, prefix)
+    local p = "src"
     if name then
-        return e2lib.join("src", name)
+        p = e2lib.join(p, name)
+    end
+    if prefix then
+        p = e2lib.join(prefix, p)
     end
-    return "src"
+    return p
 end
 
---- get path to the result config.
--- @param resultname
--- @return path to the resultconfig
-function e2tool.resultconfig(name)
-    return e2lib.join(e2tool.resultdir(name), "config")
+--- Get project-relative path to the result config.
+-- @param name Result path component.
+-- @param prefix Optional prefix path.
+-- @return Path to the resultconfig.
+function e2tool.resultconfig(name, prefix)
+    return e2lib.join(e2tool.resultdir(name, prefix), "config")
 end
 
---- get path to the result build-script
--- @param resultname
--- @return path to the result build-script
-function e2tool.resultbuildscript(name)
-    return e2lib.join(e2tool.resultdir(name), "build-script")
+--- Get project-relative path to the result build-script
+-- @param name Result path compnent name.
+-- @param prefix Optional prefix path.
+-- @return Path to the result build-script.
+function e2tool.resultbuildscript(name, prefix)
+    return e2lib.join(e2tool.resultdir(name, prefix), "build-script")
 end
 
---- get path to the source config
--- @param sourcename
--- @return path to the sourceconfig
-function e2tool.sourceconfig(name)
-    return e2lib.join(e2tool.sourcedir(name), "config")
+--- Get project-relative path to the source config.
+-- @param name Source path component.
+-- @param prefix Optional prefix path.
+-- @return Path to the sourceconfig.
+function e2tool.sourceconfig(name, prefix)
+    return e2lib.join(e2tool.sourcedir(name, prefix), "config")
 end
 
 --- Gather result paths.