diff options
| author | ruki <[email protected]> | 2016-05-25 08:58:52 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2016-05-25 08:58:52 +0800 |
| commit | 7545edd1693c3daa4ce9b8ac5ccba200c6858b61 (patch) | |
| tree | c7bc4a263e924bc6fb1448a5cb834c2b7a6deea6 | |
| parent | c5606b9bc54e3630898554f61fc191073506591b (diff) | |
check object name conflicts
| -rw-r--r-- | xmake/core/base/os.lua | 19 | ||||
| -rw-r--r-- | xmake/core/sandbox/modules/os.lua | 16 | ||||
| -rw-r--r-- | xmake/tools/ar.lua | 9 |
3 files changed, 43 insertions, 1 deletions
diff --git a/xmake/core/base/os.lua b/xmake/core/base/os.lua index ab073e914..bb73b6c43 100644 --- a/xmake/core/base/os.lua +++ b/xmake/core/base/os.lua @@ -264,6 +264,25 @@ function os.run(cmd) return true end +-- run shell with io +function os.iorun(cmd) + + -- make temporary data file + local datafile = path.join(os.tmpdir(), "xmake.os.iorun.data") + + -- run command + local ok = os.execute(cmd .. string.format(" > %s 2>&1", datafile)) + + -- get results + local results = io.readall(datafile) + + -- remove the temporary data file + os.rm(datafile) + + -- ok? + return ok == 0, results +end + -- run shell with coroutine function os.corun(cmd) diff --git a/xmake/core/sandbox/modules/os.lua b/xmake/core/sandbox/modules/os.lua index 71ff3c7a3..df2093f9f 100644 --- a/xmake/core/sandbox/modules/os.lua +++ b/xmake/core/sandbox/modules/os.lua @@ -187,6 +187,22 @@ function sandbox_os.run(cmd, ...) end end +-- run shell with io +function sandbox_os.iorun(cmd, ...) + + -- make command + cmd = vformat(cmd, ...) + + -- run it + local ok, results = os.iorun(cmd) + if not ok then + os.raise(results) + end + + -- ok + return results +end + -- run shell with coroutine function sandbox_os.corun(cmd, ...) diff --git a/xmake/tools/ar.lua b/xmake/tools/ar.lua index de220ca88..27ecd0a0f 100644 --- a/xmake/tools/ar.lua +++ b/xmake/tools/ar.lua @@ -71,8 +71,15 @@ function extract(libraryfile, objectdir) -- extract it os.run("%s -x %s", _g.shellname, libraryfile) - -- TODO -- check repeat object name + local repeats = {} + local results = os.iorun("%s -t %s", _g.shellname, libraryfile) + for _, line in ipairs(results:split('\n')) do + if repeats[line] then + raise("object name(%s) conflicts in library: %s", line, libraryfile) + end + repeats[line] = true + end -- leave the object directory os.cd("-") |
