diff options
| author | ruki <[email protected]> | 2020-06-17 00:38:59 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2020-06-16 21:53:57 +0800 |
| commit | 5e805a59c6c7e1e32292b78853002c9766ac491b (patch) | |
| tree | ec8af123f1c1b315595268a1d7fc2dc9b3c3e654 | |
| parent | 973f85fd0f602b868a90725408507bd99ceb210a (diff) | |
support chdir for process
| m--------- | core/src/tbox/tbox | 0 | ||||
| -rw-r--r-- | core/src/xmake/process/open.c | 6 | ||||
| -rw-r--r-- | core/src/xmake/process/openv.c | 8 | ||||
| -rw-r--r-- | xmake/core/base/os.lua | 11 | ||||
| -rw-r--r-- | xmake/modules/core/tools/ar.lua | 4 |
5 files changed, 16 insertions, 13 deletions
diff --git a/core/src/tbox/tbox b/core/src/tbox/tbox -Subproject 2c18435e5035f29e9393d47dfb5fcd74ef2cea6 +Subproject 015ae373ddefaad1762567575034aa3ca9d459b diff --git a/core/src/xmake/process/open.c b/core/src/xmake/process/open.c index 365876047..d027887b7 100644 --- a/core/src/xmake/process/open.c +++ b/core/src/xmake/process/open.c @@ -69,6 +69,12 @@ tb_int_t xm_process_open(lua_State* lua) attr.flags |= TB_PROCESS_FLAG_DETACH; lua_pop(lua, 1); + // get curdir + lua_pushstring(lua, "curdir"); + lua_gettable(lua, 3); + attr.curdir = lua_tostring(lua, -1); + lua_pop(lua, 1); + // get outpath lua_pushstring(lua, "outpath"); lua_gettable(lua, 2); diff --git a/core/src/xmake/process/openv.c b/core/src/xmake/process/openv.c index 4ec2399fc..c81e98d88 100644 --- a/core/src/xmake/process/openv.c +++ b/core/src/xmake/process/openv.c @@ -111,6 +111,12 @@ tb_int_t xm_process_openv(lua_State* lua) attr.flags |= TB_PROCESS_FLAG_DETACH; lua_pop(lua, 1); + // get curdir + lua_pushstring(lua, "curdir"); + lua_gettable(lua, 3); + attr.curdir = lua_tostring(lua, -1); + lua_pop(lua, 1); + // get outpath lua_pushstring(lua, "outpath"); lua_gettable(lua, 3); @@ -201,7 +207,7 @@ tb_int_t xm_process_openv(lua_State* lua) } lua_pop(lua, 1); } - + // redirect stdout? if (outpath) { diff --git a/xmake/core/base/os.lua b/xmake/core/base/os.lua index e681c0065..269ed22eb 100644 --- a/xmake/core/base/os.lua +++ b/xmake/core/base/os.lua @@ -699,20 +699,11 @@ function os.execv(program, argv, opt) end -- init open options - local openopt = {envs = envs, stdout = opt.stdout, stderr = opt.stderr} - - -- change the current working directory for child process - local oldir - if opt.curdir then - oldir = os.cd(opt.curdir) - end + local openopt = {envs = envs, stdout = opt.stdout, stderr = opt.stderr, curdir = opt.curdir} -- open command local ok = -1 local proc = process.openv(filename, argv or {}, openopt) - if oldir then - os.cd(oldir) - end if proc ~= nil then -- wait process diff --git a/xmake/modules/core/tools/ar.lua b/xmake/modules/core/tools/ar.lua index 7cf5a2351..576d40695 100644 --- a/xmake/modules/core/tools/ar.lua +++ b/xmake/modules/core/tools/ar.lua @@ -84,11 +84,11 @@ function extract(self, libraryfile, objectdir) libraryfile = path.absolute(libraryfile) -- extract it - os.runv(self:program(), {"-x", libraryfile}) + os.runv(self:program(), {"-x", libraryfile}, {curdir = objectdir}) -- check repeat object name local repeats = {} - local objectfiles = os.iorunv(self:program(), {"-t", libraryfile}, {curdir = objectdir}) + local objectfiles = os.iorunv(self:program(), {"-t", libraryfile}) for _, objectfile in ipairs(objectfiles:split('\n')) do if repeats[objectfile] then raise("object name(%s) conflicts in library: %s", objectfile, libraryfile) |
