Avoid adding envs repeatedly
@@ -90,7 +90,11 @@ function _on_run_target(target)
end
-- recursively target add env
-function _add_target_pkgenvs(target, oldenvs)
+function _add_target_pkgenvs(target, oldenvs, targets_added)
+ if targets_added[target:name()] then
+ return
+ end
+ targets_added[target:name()] = true
for name, values in pairs(target:pkgenvs()) do
if not oldenvs[name] then
oldenvs[name] = os.getenv(name)
@@ -98,7 +102,7 @@ function _add_target_pkgenvs(target, oldenvs)
os.addenv(name, unpack(values))
end
for _, dep in ipairs(target:orderdeps()) do
- _add_target_pkgenvs(dep, oldenvs)
+ _add_target_pkgenvs(dep, oldenvs, targets_added)
end
end
@@ -107,7 +111,7 @@ function _run(target)
-- enter the environments of the target packages
local oldenvs = {}
- _add_target_pkgenvs(target, oldenvs)
+ _add_target_pkgenvs(target, oldenvs, {})
-- the target scripts
local scripts =
