diff options
| author | ruki <[email protected]> | 2016-09-01 14:39:35 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2016-09-01 14:39:35 +0800 |
| commit | 698ba0673743e5d260882432b8ba1aff8193c2ed (patch) | |
| tree | 7759556242cbe27a5d7a2179d339ffa24735bb48 | |
| parent | 0783aa7d6de42ea14b2da12f1bfdcd0711fb7f99 (diff) | |
fix curdir bug for xmake.lua
| -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 |
