diff options
| author | ruki <[email protected]> | 2021-04-13 22:42:22 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2021-04-13 22:42:22 +0800 |
| commit | 84b64c4ecffe6ed4a498efa8116271ecba78e52d (patch) | |
| tree | 4f03fff7f04d6fd648b9bfce26348463b4bc7423 /xmake/modules | |
| parent | 317745583da0e5c940f6e300c5f6163eb800efbf (diff) | |
improve envs
Diffstat (limited to 'xmake/modules')
4 files changed, 11 insertions, 14 deletions
diff --git a/xmake/modules/private/action/require/check.lua b/xmake/modules/private/action/require/check.lua index 5d7dc103c..9b20b1310 100644 --- a/xmake/modules/private/action/require/check.lua +++ b/xmake/modules/private/action/require/check.lua @@ -43,9 +43,10 @@ function main(requires_raw) runjobs("fetch_packages", function (index) local instance = packages[index] if instance and (not option.get("force") or (option.get("shallow") and not instance:is_toplevel())) then + local oldenvs = os.getenvs() instance:envs_enter() instance:fetch() - instance:envs_leave() + os.setenvs(oldenvs) end end, {total = #packages}) diff --git a/xmake/modules/private/action/require/impl/actions/install.lua b/xmake/modules/private/action/require/impl/actions/install.lua index 752b80725..81f93681e 100644 --- a/xmake/modules/private/action/require/impl/actions/install.lua +++ b/xmake/modules/private/action/require/impl/actions/install.lua @@ -132,6 +132,7 @@ function main(package) end -- install it + local oldenvs = os.getenvs() try { function () @@ -158,7 +159,6 @@ function main(package) patch_sources(package) -- enter the environments of all package dependencies - local oldenvs = os.getenvs() for _, dep in ipairs(package:orderdeps()) do dep:envs_enter() end @@ -172,9 +172,7 @@ function main(package) end -- leave the environments of all package dependencies - for _, dep in irpairs(package:orderdeps()) do - dep:envs_leave() - end + os.setenvs(oldenvs) -- save the package info to the manifest file package:manifest_save() @@ -206,10 +204,7 @@ function main(package) end -- leave the package environments - package:envs_leave() - for _, dep in irpairs(package:orderdeps()) do - dep:envs_leave() - end + os.setenvs(oldenvs) -- trace tty.erase_line_to_start().cr() @@ -235,7 +230,7 @@ function main(package) cprint("${yellow} => ${clear}install %s %s .. ${color.failure}${text.failure}", package:displayname(), package:version_str() or "") -- leave the package environments - package:envs_leave() + os.setenvs(oldenvs) -- copy the invalid package directory to cache local installdir = package:installdir() diff --git a/xmake/modules/private/action/require/impl/environment.lua b/xmake/modules/private/action/require/impl/environment.lua index ae6950de3..115f263aa 100644 --- a/xmake/modules/private/action/require/impl/environment.lua +++ b/xmake/modules/private/action/require/impl/environment.lua @@ -54,6 +54,7 @@ function enter() end -- enter the environments of installed packages + _g._OLDENVS = os.getenvs() for _, instance in ipairs(packages) do instance:envs_enter() end @@ -64,9 +65,8 @@ end function leave() -- leave the environments of installed packages - for _, instance in irpairs(_g._PACKAGES) do - instance:envs_leave() - end + os.setenvs(_g._OLDENVS) + _g._OLDENVS = nil _g._PACKAGES = nil -- leave the environments of git diff --git a/xmake/modules/private/action/require/impl/install_packages.lua b/xmake/modules/private/action/require/impl/install_packages.lua index efc0c73a9..8bec808c6 100644 --- a/xmake/modules/private/action/require/impl/install_packages.lua +++ b/xmake/modules/private/action/require/impl/install_packages.lua @@ -429,9 +429,10 @@ function main(requires, opt) runjobs("fetch_packages", function (index) local instance = packages[index] if instance and (not option.get("force") or (option.get("shallow") and not instance:is_toplevel())) then + local oldenvs = os.getenvs() instance:envs_enter() instance:fetch() - instance:envs_leave() + os.setenvs(oldenvs) end end, {total = #packages}) |
