diff options
| -rw-r--r-- | xmake/core/base/interpreter.lua | 9 | ||||
| -rw-r--r-- | xmake/core/base/os.lua | 2 |
2 files changed, 10 insertions, 1 deletions
diff --git a/xmake/core/base/interpreter.lua b/xmake/core/base/interpreter.lua index 8fb1d8afd..7b2cc9e2c 100644 --- a/xmake/core/base/interpreter.lua +++ b/xmake/core/base/interpreter.lua @@ -242,12 +242,21 @@ function interpreter:_api_builtin_add_subdirfiles(isdirs, ...) -- clear the current scope, force to enter root scope scopes._CURRENT = nil + -- save the current directory + local olddir = os.curdir() + + -- enter the script directory + os.cd(path.directory(file)) + -- done interpreter local ok, errors = xpcall(script, interpreter._traceback) if not ok then os.raise(errors) end + -- leave the script directory + os.cd(olddir) + -- restore the previous scope kind scopes._CURRENT_KIND = scope_kind_prev diff --git a/xmake/core/base/os.lua b/xmake/core/base/os.lua index 0389fb75a..bebf04fc7 100644 --- a/xmake/core/base/os.lua +++ b/xmake/core/base/os.lua @@ -224,7 +224,7 @@ function os.cd(dir) return false, string.format("not found the previous directory %s", os.strerror()) end end - + -- is directory? if os.isdir(dir) then |
