summaryrefslogtreecommitdiff
path: root/xmake/core/base/path.lua
diff options
context:
space:
mode:
authorOpportunityLiu <[email protected]>2019-07-17 08:48:11 +0800
committerOpportunityLiu <[email protected]>2019-07-19 11:48:31 +0800
commit0a771e41e5057d2f6dc9dce3cbe2078cbc19aa83 (patch)
tree3478c553fbee0e2842dbe05196f5d742d518bf1b /xmake/core/base/path.lua
parentae533cdc5bcee78d7a24b64eac430d9197d0e043 (diff)
add path.splitenv
Diffstat (limited to 'xmake/core/base/path.lua')
-rw-r--r--xmake/core/base/path.lua27
1 files changed, 27 insertions, 0 deletions
diff --git a/xmake/core/base/path.lua b/xmake/core/base/path.lua
index c1222ffc6..d15c42fc4 100644
--- a/xmake/core/base/path.lua
+++ b/xmake/core/base/path.lua
@@ -158,6 +158,33 @@ function path.splitenv(env_path)
return result
end
+-- concat environment variable with `path.envsep()`,
+-- also handles more speical cases such as posix flags and windows quoted pathes
+function path.joinenv(env_table)
+
+ -- check
+ env_table = env_table or {}
+
+ local envsep = path.envsep()
+
+ if xmake._HOST == "windows" then
+ local tab = {}
+ for _, v in ipairs(env_table) do
+ if v ~= "" then
+ if v:find(envsep, 1, true) then
+ v = '"' .. v .. '"'
+ end
+ table.insert(tab, v)
+ end
+ end
+ return table.concat(tab, envsep)
+ else
+ return table.concat(env_table, envsep)
+ end
+
+ return result
+end
+
-- the last character is the path seperator?
function path.islastsep(p)