diff options
Diffstat (limited to 'xmake/core/base/os.lua')
| -rw-r--r-- | xmake/core/base/os.lua | 32 |
1 files changed, 24 insertions, 8 deletions
diff --git a/xmake/core/base/os.lua b/xmake/core/base/os.lua index 2d7023ac4..b0545afc8 100644 --- a/xmake/core/base/os.lua +++ b/xmake/core/base/os.lua @@ -830,20 +830,36 @@ function os.execv(program, argv, opt) -- uses the given environments? local envs = nil - if opt.envs then + local setenvs = opt.setenvs or opt.envs + local addenvs = opt.addenvs + if setenvs or addenvs then local envars = os.getenvs() - for k, v in pairs(opt.envs) do - if type(v) == "table" then - v = path.joinenv(v) + if setenvs then + for k, v in pairs(setenvs) do + if type(v) == "table" then + v = path.joinenv(v) + end + envars[k] = v end - -- we try to fix too long value before running process - if type(v) == "string" and #v > 4096 and os.host() == "windows" then - v = os._deduplicate_pathenv(v) + end + if addenvs then + for k, v in pairs(addenvs) do + if type(v) == "table" then + v = path.joinenv(v) + end + local o = envars[k] + if o then + v = v .. path.envsep() .. o + end + envars[k] = v end - envars[k] = v end envs = {} for k, v in pairs(envars) do + -- we try to fix too long value before running process + if type(v) == "string" and #v > 4096 and os.host() == "windows" then + v = os._deduplicate_pathenv(v) + end table.insert(envs, k .. '=' .. v) end end |
