diff options
| author | ruki <[email protected]> | 2016-06-22 19:42:00 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2016-06-22 19:42:00 +0800 |
| commit | eecb073d6ca8b04168ebd829d04a7fc340731d1d (patch) | |
| tree | 212fe6f484641700d7028c3ed40483a4119ec8e3 /xmake/core/base/interpreter.lua | |
| parent | 7bd08766b43b74e0c5cb5a5e86e7a856b9acbc3a (diff) | |
fix add_subdirs scope bug
Diffstat (limited to 'xmake/core/base/interpreter.lua')
| -rw-r--r-- | xmake/core/base/interpreter.lua | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/xmake/core/base/interpreter.lua b/xmake/core/base/interpreter.lua index 1152aee97..2c13e811a 100644 --- a/xmake/core/base/interpreter.lua +++ b/xmake/core/base/interpreter.lua @@ -194,6 +194,10 @@ function interpreter:_api_builtin_add_subdirfiles(isdirs, ...) local curfile = self._PRIVATE._CURFILE assert(curfile) + -- the scopes + local scopes = self._PRIVATE._SCOPES + assert(scopes) + -- get all subpathes local subpathes = self:_api_translate_pathes(...) @@ -229,8 +233,14 @@ function interpreter:_api_builtin_add_subdirfiles(isdirs, ...) -- bind public scope setfenv(script, self._PUBLIC) + -- save the previous scope + local scope_prev = scopes._CURRENT + + -- save the previous scope kind + local scope_kind_prev = scopes._CURRENT_KIND + -- clear the current scope, force to enter root scope - self._PRIVATE._SCOPES._CURRENT = nil + scopes._CURRENT = nil -- done interpreter local ok, errors = xpcall(script, interpreter._traceback) @@ -238,6 +248,12 @@ function interpreter:_api_builtin_add_subdirfiles(isdirs, ...) os.raise(errors) end + -- restore the previous scope kind + scopes._CURRENT_KIND = scope_kind_prev + + -- restore the previous scope + scopes._CURRENT = scope_prev + -- get mtime of the file self._PRIVATE._MTIMES[path.relative(file, self._PRIVATE._ROOTDIR)] = os.mtime(file) else |
