diff options
| author | ruki <[email protected]> | 2016-07-10 10:18:05 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2016-07-10 10:18:05 +0800 |
| commit | fd39adb3d959e605370098a72ec7e92b462fce62 (patch) | |
| tree | 392b866ab32e33cae167c95daa7bff7cfbb9767c /xmake/tools/gcc.lua | |
| parent | 4d2231a5136ddf5dca5398feaccc2d82bb56e1e0 (diff) | |
check include dependence
Diffstat (limited to 'xmake/tools/gcc.lua')
| -rwxr-xr-x | xmake/tools/gcc.lua | 26 |
1 files changed, 21 insertions, 5 deletions
diff --git a/xmake/tools/gcc.lua b/xmake/tools/gcc.lua index 5019aa06f..85bc7a379 100755 --- a/xmake/tools/gcc.lua +++ b/xmake/tools/gcc.lua @@ -142,16 +142,32 @@ function link(objectfiles, targetfile, flags) end -- complie the source file -function compile(sourcefile, objectfile, flags, multitasking) +function compile(sourcefile, objectfile, incdepfile, flags, multitasking) -- ensure the object directory os.mkdir(path.directory(objectfile)) + -- run function + local run = ifelse(multitasking, os.corun, os.run) + -- compile it - if multitasking then - os.corun(compcmd(sourcefile, objectfile, flags)) - else - os.run(compcmd(sourcefile, objectfile, flags)) + run(compcmd(sourcefile, objectfile, flags)) + + -- generate includes file + if incdepfile then + + -- generate it + run(compcmd(sourcefile, incdepfile, flags .. " -MM")) + + -- translate it + local results = {} + local incdeps = io.read(incdepfile) + for includefile in string.gmatch(incdeps, "([%w|/|%.|%-|%+|_|%$]-%.[h|hpp])") do + table.insert(results, includefile) + end + + -- update it + io.save(incdepfile, results) end end |
