From 2b9fa9538efda1b9bb95674c510afd3082330971 Mon Sep 17 00:00:00 2001 From: ruki Date: Sat, 27 Apr 2019 00:34:05 +0800 Subject: pass envs to os.execv --- xmake/core/base/os.lua | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/xmake/core/base/os.lua b/xmake/core/base/os.lua index c20b8ac25..d63cefad3 100644 --- a/xmake/core/base/os.lua +++ b/xmake/core/base/os.lua @@ -580,7 +580,8 @@ end -- @param program "clang", "xcrun -sdk macosx clang", "~/dir/test\ xxx/clang" -- filename "clang", "xcrun"", "~/dir/test\ xxx/clang" -- @param argv the arguments --- @param opt the options, .e.g {wildcards = false, stdout = outfile, stderr = errfile, envs = {"PATH=xxx;xx", "CFLAGS=xx"}} +-- @param opt the options, .e.g {wildcards = false, stdout = outfile, stderr = errfile, +-- envs = {PATH = "xxx;xx", CFLAGS = "xx"}} -- function os.execv(program, argv, opt) @@ -608,9 +609,18 @@ function os.execv(program, argv, opt) end end + -- uses the given environments? + local envs = nil + if opt.envs then + envs = {} + for k, v in pairs(opt.envs) do + table.insert(envs, k .. '=' .. v) + end + end + -- open command local ok = -1 - local proc = process.openv(filename, argv, opt.stdout, opt.stderr, opt.envs) + local proc = process.openv(filename, argv, opt.stdout, opt.stderr, envs) if proc ~= nil then -- wait process -- cgit v1.3.1