diff options
| author | ruki <[email protected]> | 2020-06-13 14:29:57 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2020-06-13 14:29:57 +0800 |
| commit | d1f1fd32aeddf73071b06fbcab23856925a0017f (patch) | |
| tree | 3f7ee6d6f5127144a5acb64bab1a68fb720bfb79 /xmake/core/platform/environment.lua | |
| parent | 531799191430f540502de732635f97879541cf3c (diff) | |
improve toolchain environment
Diffstat (limited to 'xmake/core/platform/environment.lua')
| -rw-r--r-- | xmake/core/platform/environment.lua | 25 |
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 |
