diff options
| author | ruki <[email protected]> | 2016-07-05 16:37:41 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2016-07-05 16:37:41 +0800 |
| commit | 7af1dcdeed9e2ecbfc0ba0f4c34e52c99e1cdd89 (patch) | |
| tree | 5d8b2b77ddca5024f350093f882c93a03f7a69e9 | |
| parent | 7f75b2583b94e733ba0b974860174a9021bc8767 (diff) | |
uses os.exec instead of os.execute
| -rwxr-xr-x | core/src/xmake/process/open.c | 5 | ||||
| -rwxr-xr-x | core/src/xmake/process/openv.c | 5 | ||||
| -rw-r--r-- | xmake/core/base/os.lua | 6 | ||||
| -rw-r--r-- | xmake/core/sandbox/modules/os.lua | 27 | ||||
| -rw-r--r-- | xmake/core/tool/tool.lua | 2 | ||||
| -rw-r--r-- | xmake/platforms/iphoneos/checker.lua | 2 | ||||
| -rw-r--r-- | xmake/platforms/watchos/checker.lua | 2 | ||||
| -rwxr-xr-x | xmake/plugins/macro/macros/package.lua | 2 |
8 files changed, 24 insertions, 27 deletions
diff --git a/core/src/xmake/process/open.c b/core/src/xmake/process/open.c index 2a2ee99af..55d4fab0b 100755 --- a/core/src/xmake/process/open.c +++ b/core/src/xmake/process/open.c @@ -78,9 +78,8 @@ tb_int_t xm_process_open(lua_State* lua) // init process tb_process_ref_t process = tb_process_init_cmd(command, &attr); - - // save the process reference - lua_pushlightuserdata(lua, process); + if (process) lua_pushlightuserdata(lua, process); + else lua_pushnil(lua); // ok return 1; diff --git a/core/src/xmake/process/openv.c b/core/src/xmake/process/openv.c index 8f99c4535..692d18754 100755 --- a/core/src/xmake/process/openv.c +++ b/core/src/xmake/process/openv.c @@ -120,9 +120,8 @@ tb_int_t xm_process_openv(lua_State* lua) // init process tb_process_ref_t process = tb_process_init(shellname, argv, &attr); - - // save the process reference - lua_pushlightuserdata(lua, process); + if (process) lua_pushlightuserdata(lua, process); + else lua_pushnil(lua); // exit argv if (argv) tb_free(argv); diff --git a/xmake/core/base/os.lua b/xmake/core/base/os.lua index 92b37c708..a25dcbdc0 100644 --- a/xmake/core/base/os.lua +++ b/xmake/core/base/os.lua @@ -298,7 +298,7 @@ function os.runv(shellname, argv) local log = path.join(os.tmpdir(), "xmake.os.runv.log") -- execute it - local ok = os.execv(shellname, argv, log, log) + local ok = os.execv(shellname, table.wrap(argv), log, log) if ok ~= 0 then -- make errors @@ -345,7 +345,7 @@ function os.execv(shellname, argv, outfile, errfile) -- open command local ok = -1 - local proc = process.openv(shellname, argv, outfile, errfile) + local proc = process.openv(shellname, table.wrap(argv), outfile, errfile) if proc ~= nil then -- wait process @@ -369,7 +369,7 @@ function os.iorun(cmd) local datafile = path.join(os.tmpdir(), "xmake.os.iorun.data") -- run command - local ok = os.execute(cmd .. string.format(" > %s 2>&1", datafile)) + local ok = os.exec(cmd, datafile, datafile) -- get results local results = io.readall(datafile) diff --git a/xmake/core/sandbox/modules/os.lua b/xmake/core/sandbox/modules/os.lua index 0c06d7dff..f4d6efb6e 100644 --- a/xmake/core/sandbox/modules/os.lua +++ b/xmake/core/sandbox/modules/os.lua @@ -208,6 +208,19 @@ function sandbox_os.run(cmd, ...) end end +-- run shell with arguments list +function sandbox_os.runv(shellname, argv) + + -- make shellname + shellname = vformat(shellname) + + -- run it + local ok, errors = os.runv(shellname, argv) + if not ok then + os.raise(errors) + end +end + -- run shell with io function sandbox_os.iorun(cmd, ...) @@ -244,7 +257,7 @@ function sandbox_os.exec(cmd, ...) cmd = vformat(cmd, ...) -- run it - local ok = os.execute(cmd) + local ok = os.exec(cmd) if ok ~= 0 then os.raise("exec(%s) failed(%d)!", cmd, ok) end @@ -259,20 +272,10 @@ function sandbox_os.execv(shellname, argv) -- run it local ok = os.execv(shellname, argv) if ok ~= 0 then - os.raise("execv(%s) failed(%d)!", shellname, ok) + os.raise("execv(%s %s) failed(%d)!", shellname, table.concat(argv, ' '), ok) end end --- execute shell and return error code -function sandbox_os.execute(cmd, ...) - - -- make command - cmd = vformat(cmd, ...) - - -- run it - return os.execute(cmd) -end - -- match files or directories function sandbox_os.match(pattern, findir, ...) diff --git a/xmake/core/tool/tool.lua b/xmake/core/tool/tool.lua index ffdf748f4..ec832d781 100644 --- a/xmake/core/tool/tool.lua +++ b/xmake/core/tool/tool.lua @@ -206,7 +206,7 @@ function tool._check(shellname, check) -- no checker? attempt to run it directly if not module or not module.check then - return 0 == os.execute(string.format("%s > %s 2>&1", shellname, xmake._NULDEV)) + return 0 == os.exec(shellname, xmake._NULDEV, xmake._NULDEV) end -- check it diff --git a/xmake/platforms/iphoneos/checker.lua b/xmake/platforms/iphoneos/checker.lua index 09e033d62..172b9d889 100644 --- a/xmake/platforms/iphoneos/checker.lua +++ b/xmake/platforms/iphoneos/checker.lua @@ -58,7 +58,6 @@ function _check_toolchains(config) checker.check_toolchain(config, "sh", "xcrun -sdk iphonesimulator ", "clang++", "the shared library linker") checker.check_toolchain(config, "sh", "xcrun -sdk iphonesimulator ", "clang", "the shared library linker") checker.check_toolchain(config, "sc", "xcrun -sdk iphonesimulator ", "swiftc", "the swift compiler") - checker.check_toolchain(config, "lipo", "xcrun -sdk iphonesimulator ", "lipo", "the universal files creater") else checker.check_toolchain(config, "cc", "xcrun -sdk iphoneos ", "clang", "the c compiler") checker.check_toolchain(config, "cxx", "xcrun -sdk iphoneos ", "clang", "the c++ compiler") @@ -74,7 +73,6 @@ function _check_toolchains(config) checker.check_toolchain(config, "sh", "xcrun -sdk iphoneos ", "clang++", "the shared library linker") checker.check_toolchain(config, "sh", "xcrun -sdk iphoneos ", "clang", "the shared library linker") checker.check_toolchain(config, "sc", "xcrun -sdk iphoneos ", "swiftc", "the swift compiler") - checker.check_toolchain(config, "lipo", "xcrun -sdk iphoneos ", "lipo", "the universal files creater") end end diff --git a/xmake/platforms/watchos/checker.lua b/xmake/platforms/watchos/checker.lua index 2a76ac1f3..2cdd0d5a7 100644 --- a/xmake/platforms/watchos/checker.lua +++ b/xmake/platforms/watchos/checker.lua @@ -58,7 +58,6 @@ function _check_toolchains(config) checker.check_toolchain(config, "sh", "xcrun -sdk watchsimulator ", "clang++", "the shared library linker") checker.check_toolchain(config, "sh", "xcrun -sdk watchsimulator ", "clang", "the shared library linker") checker.check_toolchain(config, "sc", "xcrun -sdk watchsimulator ", "swiftc", "the swift compiler") - checker.check_toolchain(config, "lipo", "xcrun -sdk watchsimulator ", "lipo", "the universal files creater") else checker.check_toolchain(config, "cc", "xcrun -sdk watchos ", "clang", "the c compiler") checker.check_toolchain(config, "cxx", "xcrun -sdk watchos ", "clang", "the c++ compiler") @@ -74,7 +73,6 @@ function _check_toolchains(config) checker.check_toolchain(config, "sh", "xcrun -sdk watchos ", "clang++", "the shared library linker") checker.check_toolchain(config, "sh", "xcrun -sdk watchos ", "clang", "the shared library linker") checker.check_toolchain(config, "sc", "xcrun -sdk watchos ", "swiftc", "the swift compiler") - checker.check_toolchain(config, "lipo", "xcrun -sdk watchos ", "lipo", "the universal files creater") end end diff --git a/xmake/plugins/macro/macros/package.lua b/xmake/plugins/macro/macros/package.lua index 0fd4e498c..a6edaa5aa 100755 --- a/xmake/plugins/macro/macros/package.lua +++ b/xmake/plugins/macro/macros/package.lua @@ -104,7 +104,7 @@ function main(argv) os.mkdir(format("%s/%s.pkg/lib/%s/%s/universal", outputdir, target:name(), mode, plat)) -- package all archs - os.exec("xmake l lipo \"%s\"", lipoargs) + os.execv("xmake", {"l", "lipo", lipoargs}) end end end |
