diff options
| author | ruki <[email protected]> | 2016-07-04 14:33:50 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2016-07-04 14:33:50 +0800 |
| commit | 1ec6011956e78dedd7eea87f484b0a3c56cfef27 (patch) | |
| tree | c762bc26e0483b9082ff70eed890b7bef468f98d | |
| parent | 2acc00d97e75abee7e1871f699c69136d37c4e49 (diff) | |
fix cd bug
| -rwxr-xr-x | xmake/actions/build/main.lua | 4 | ||||
| -rwxr-xr-x | xmake/actions/clean/main.lua | 4 | ||||
| -rwxr-xr-x | xmake/actions/config/configheader.lua | 5 | ||||
| -rwxr-xr-x | xmake/actions/install/main.lua | 4 | ||||
| -rwxr-xr-x | xmake/actions/package/main.lua | 4 | ||||
| -rwxr-xr-x | xmake/actions/run/main.lua | 4 | ||||
| -rwxr-xr-x | xmake/actions/uninstall/main.lua | 4 | ||||
| -rw-r--r-- | xmake/core/sandbox/modules/os.lua | 5 | ||||
| -rwxr-xr-x | xmake/plugins/project/makefile.lua | 4 | ||||
| -rw-r--r-- | xmake/tools/ar.lua | 4 |
10 files changed, 23 insertions, 19 deletions
diff --git a/xmake/actions/build/main.lua b/xmake/actions/build/main.lua index 948bf400f..d09454be6 100755 --- a/xmake/actions/build/main.lua +++ b/xmake/actions/build/main.lua @@ -56,7 +56,7 @@ function main() cache.flush() -- enter project directory - os.cd(project.directory()) + local olddir = os.cd(project.directory()) -- build it try @@ -83,7 +83,7 @@ function main() } -- leave project directory - os.cd("-") + os.cd(olddir) -- trace print("build ok!") diff --git a/xmake/actions/clean/main.lua b/xmake/actions/clean/main.lua index 319c14b77..0ac4d7819 100755 --- a/xmake/actions/clean/main.lua +++ b/xmake/actions/clean/main.lua @@ -149,13 +149,13 @@ function main() task.run("config", {target = targetname}) -- enter project directory - os.cd(project.directory()) + local olddir = os.cd(project.directory()) -- clean the current target _clean(targetname) -- leave project directory - os.cd("-") + os.cd(olddir) -- trace print("clean ok!") diff --git a/xmake/actions/config/configheader.lua b/xmake/actions/config/configheader.lua index 0871e5909..8803fb0a8 100755 --- a/xmake/actions/config/configheader.lua +++ b/xmake/actions/config/configheader.lua @@ -129,7 +129,7 @@ function make() local targetname = option.get("target") -- enter project directory - os.cd(project.directory()) + local olddir = os.cd(project.directory()) -- init files local files = {} @@ -151,6 +151,5 @@ function make() end -- leave project directory - os.cd("-") - + os.cd(olddir) end diff --git a/xmake/actions/install/main.lua b/xmake/actions/install/main.lua index 2b6a42aa6..727c86f73 100755 --- a/xmake/actions/install/main.lua +++ b/xmake/actions/install/main.lua @@ -54,7 +54,7 @@ end function _install(target) -- enter project directory - os.cd(project.directory()) + local olddir = os.cd(project.directory()) -- the target scripts local scripts = @@ -73,7 +73,7 @@ function _install(target) end -- leave project directory - os.cd("-") + os.cd(olddir) end -- install the given target and deps diff --git a/xmake/actions/package/main.lua b/xmake/actions/package/main.lua index 377d31eea..453725e13 100755 --- a/xmake/actions/package/main.lua +++ b/xmake/actions/package/main.lua @@ -129,7 +129,7 @@ end function _package(target) -- enter project directory - os.cd(project.directory()) + local olddir = os.cd(project.directory()) -- the target scripts local scripts = @@ -148,7 +148,7 @@ function _package(target) end -- leave project directory - os.cd("-") + os.cd(olddir) end -- package the given target and deps diff --git a/xmake/actions/run/main.lua b/xmake/actions/run/main.lua index 43b942240..2f35ef2f0 100755 --- a/xmake/actions/run/main.lua +++ b/xmake/actions/run/main.lua @@ -84,11 +84,11 @@ function main() task.run("build", {target = targetname}) -- enter project directory - os.cd(project.directory()) + local olddir = os.cd(project.directory()) -- run the current target _run(project.target(targetname)) -- leave project directory - os.cd("-") + os.cd(olddir) end diff --git a/xmake/actions/uninstall/main.lua b/xmake/actions/uninstall/main.lua index 6b5aa6a23..2f5056b6e 100755 --- a/xmake/actions/uninstall/main.lua +++ b/xmake/actions/uninstall/main.lua @@ -54,7 +54,7 @@ end function _uninstall(target) -- enter project directory - os.cd(project.directory()) + local olddir = os.cd(project.directory()) -- the target scripts local scripts = @@ -73,7 +73,7 @@ function _uninstall(target) end -- leave project directory - os.cd("-") + os.cd(olddir) end -- uninstall the given target and deps diff --git a/xmake/core/sandbox/modules/os.lua b/xmake/core/sandbox/modules/os.lua index 7930ae3b2..c8341a160 100644 --- a/xmake/core/sandbox/modules/os.lua +++ b/xmake/core/sandbox/modules/os.lua @@ -97,12 +97,17 @@ function sandbox_os.cd(dir) -- format it first dir = vformat(dir) + -- the previous directory + local olddir = os.curdir() + -- done local ok, errors = os.cd(dir) if not ok then os.raise(errors) end + -- ok + return olddir end -- create directory diff --git a/xmake/plugins/project/makefile.lua b/xmake/plugins/project/makefile.lua index 60455ca6d..b3bbe58b2 100755 --- a/xmake/plugins/project/makefile.lua +++ b/xmake/plugins/project/makefile.lua @@ -196,7 +196,7 @@ end function make(outputfile) -- enter project directory - os.cd(project.directory()) + local olddir = os.cd(project.directory()) -- remove the log makefile first os.rm(_logfile()) @@ -211,6 +211,6 @@ function make(outputfile) makefile:close() -- leave project directory - os.cd("-") + os.cd(olddir) end diff --git a/xmake/tools/ar.lua b/xmake/tools/ar.lua index df9325763..6445c332b 100644 --- a/xmake/tools/ar.lua +++ b/xmake/tools/ar.lua @@ -69,7 +69,7 @@ function extract(libraryfile, objectdir) libraryfile = path.absolute(libraryfile) -- enter the object directory - os.cd(objectdir) + local olddir = os.cd(objectdir) -- extract it os.run("%s -x %s", _g.shellname, libraryfile) @@ -85,7 +85,7 @@ function extract(libraryfile, objectdir) end -- leave the object directory - os.cd("-") + os.cd(olddir) end -- run command |
