summaryrefslogtreecommitdiff
path: root/xmake/core/platform/environment.lua
diff options
context:
space:
mode:
authorruki <[email protected]>2020-06-13 14:29:57 +0800
committerruki <[email protected]>2020-06-13 14:29:57 +0800
commitd1f1fd32aeddf73071b06fbcab23856925a0017f (patch)
tree3f7ee6d6f5127144a5acb64bab1a68fb720bfb79 /xmake/core/platform/environment.lua
parent531799191430f540502de732635f97879541cf3c (diff)
improve toolchain environment
Diffstat (limited to 'xmake/core/platform/environment.lua')
-rw-r--r--xmake/core/platform/environment.lua25
1 files changed, 25 insertions, 0 deletions
diff --git a/xmake/core/platform/environment.lua b/xmake/core/platform/environment.lua
index f76568cb7..d3ff0a0fd 100644
--- a/xmake/core/platform/environment.lua
+++ b/xmake/core/platform/environment.lua
@@ -86,6 +86,18 @@ end
-- enter the environment for the current platform
function environment.enter(name)
+
+ -- need enter?
+ local entered = environment._ENTERED or {}
+ environment._ENTERED = entered
+ if entered[name] then
+ entered[name] = entered[name] + 1
+ return true
+ else
+ entered[name] = 1
+ end
+
+ -- do enter
local maps = {toolchains = environment._enter_toolchains, run = environment._enter_run}
local func = maps[name]
if func then
@@ -99,6 +111,19 @@ end
-- leave the environment for the current platform
function environment.leave(name)
+
+ -- need leave?
+ local entered = environment._ENTERED or {}
+ if entered[name] then
+ entered[name] = entered[name] - 1
+ end
+ if entered[name] == 0 then
+ entered[name] = nil
+ else
+ return true
+ end
+
+ -- do leave
local maps = {toolchains = environment._leave_toolchains, run = environment._leave_run}
local func = maps[name]
if func then