diff options
| author | OpportunityLiu <[email protected]> | 2019-07-17 08:48:11 +0800 |
|---|---|---|
| committer | OpportunityLiu <[email protected]> | 2019-07-19 11:48:31 +0800 |
| commit | 0a771e41e5057d2f6dc9dce3cbe2078cbc19aa83 (patch) | |
| tree | 3478c553fbee0e2842dbe05196f5d742d518bf1b /xmake/core/base/path.lua | |
| parent | ae533cdc5bcee78d7a24b64eac430d9197d0e043 (diff) | |
add path.splitenv
Diffstat (limited to 'xmake/core/base/path.lua')
| -rw-r--r-- | xmake/core/base/path.lua | 27 |
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) |
