diff options
| author | ruki <[email protected]> | 2016-07-10 16:07:52 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2016-07-10 16:07:52 +0800 |
| commit | e281ea26c19103dcbc7f951a8592eeb6a1ff63a3 (patch) | |
| tree | b2ef3ea44478ad5d7ec5cf3f1a11e65213fd379b /xmake/tools | |
| parent | fd39adb3d959e605370098a72ec7e92b462fce62 (diff) | |
parse includes from cl.exe
Diffstat (limited to 'xmake/tools')
| -rwxr-xr-x | xmake/tools/cl.lua | 22 | ||||
| -rwxr-xr-x | xmake/tools/gcc.lua | 17 | ||||
| -rw-r--r-- | xmake/tools/swiftc.lua | 8 |
3 files changed, 29 insertions, 18 deletions
diff --git a/xmake/tools/cl.lua b/xmake/tools/cl.lua index 30d30a6f3..faba74124 100755 --- a/xmake/tools/cl.lua +++ b/xmake/tools/cl.lua @@ -112,16 +112,28 @@ function compcmd(sourcefile, objectfile, flags) end -- complie the source file -function compile(sourcefile, objectfile, incdepfile, flags, multitasking) +function compile(sourcefile, objectfile, incdepfile, flags) -- ensure the object directory os.mkdir(path.directory(objectfile)) + -- generate includes file + if incdepfile then + flags = (flags or "") .. " -showIncludes" + end + -- compile it - if multitasking then - os.corun(compcmd(sourcefile, objectfile, flags)) - else - os.run(compcmd(sourcefile, objectfile, flags)) + local outdata = os.iorun(compcmd(sourcefile, objectfile, flags)) + if incdepfile and outdata then + + -- translate it + local results = {} + for includefile in string.gmatch(outdata, "including file:%s*(.-%.[h|hpp])") do + table.insert(results, includefile) + end + + -- update it + io.save(incdepfile, results) end end diff --git a/xmake/tools/gcc.lua b/xmake/tools/gcc.lua index 85bc7a379..68c7c9100 100755 --- a/xmake/tools/gcc.lua +++ b/xmake/tools/gcc.lua @@ -142,32 +142,35 @@ function link(objectfiles, targetfile, flags) end -- complie the source file -function compile(sourcefile, objectfile, incdepfile, flags, multitasking) +function compile(sourcefile, objectfile, incdepfile, flags) -- ensure the object directory os.mkdir(path.directory(objectfile)) - -- run function - local run = ifelse(multitasking, os.corun, os.run) - -- compile it - run(compcmd(sourcefile, objectfile, flags)) + os.run(compcmd(sourcefile, objectfile, flags)) -- generate includes file if incdepfile then + -- the temporary file + local tmpfile = os.tmpfile() + -- generate it - run(compcmd(sourcefile, incdepfile, flags .. " -MM")) + os.run(compcmd(sourcefile, tmpfile, (flags or "") .. " -MM")) -- translate it local results = {} - local incdeps = io.read(incdepfile) + local incdeps = io.read(tmpfile) for includefile in string.gmatch(incdeps, "([%w|/|%.|%-|%+|_|%$]-%.[h|hpp])") do table.insert(results, includefile) end -- update it io.save(incdepfile, results) + + -- remove the temporary file + os.rm(tmpfile) end end diff --git a/xmake/tools/swiftc.lua b/xmake/tools/swiftc.lua index 49b9476b2..eb304e420 100644 --- a/xmake/tools/swiftc.lua +++ b/xmake/tools/swiftc.lua @@ -94,17 +94,13 @@ function compcmd(sourcefile, objectfile, flags) end -- complie the source file -function compile(sourcefile, objectfile, incdepfile, flags, multitasking) +function compile(sourcefile, objectfile, incdepfile, flags) -- ensure the object directory os.mkdir(path.directory(objectfile)) -- compile it - if multitasking then - os.corun(compcmd(sourcefile, objectfile, flags)) - else - os.run(compcmd(sourcefile, objectfile, flags)) - end + os.run(compcmd(sourcefile, objectfile, flags)) end -- make the includedir flag |
