summaryrefslogtreecommitdiff
path: root/xmake/core/base/os.lua
diff options
context:
space:
mode:
authorruki <[email protected]>2024-04-18 17:19:13 +0800
committerGitHub <[email protected]>2024-04-18 17:19:13 +0800
commite170a82a9f79f0331d22e66fc4ec35d05a784d8a (patch)
treec704874b6789cc27fa634a41b6f4722eed3a72a7 /xmake/core/base/os.lua
parent78627bc254c1c9c798f802fa15ddda4cff37da87 (diff)
parentf00427931ec4125ba42325e03d306b377f3d9b1d (diff)
Merge pull request #4986 from xmake-io/runenvs
Improve runenvs
Diffstat (limited to 'xmake/core/base/os.lua')
-rw-r--r--xmake/core/base/os.lua32
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