function _extract_includes(content)
local includes = {}
for line in string.gmatch(content, "[^\r\n]+") do
for include in string.gmatch(line, "/[%a%d%p\\]+") do
table.insert(includes, path.normalize(include))
end
end
table.remove(includes, 1)
return includes
end
function scan(target, sourcefile, opt)
local compinst = target:compiler("cxx")
local ifile = path.translate(path.join(outputdir, sourcefile .. ".i"))
local compflags = compinst:compflags({sourcefile = sourcefile, target = target})
local flags = table.join(compflags, {"-M", "-c", "-x", "c++", sourcefile})
local content, _ = os.iorunv(compinst:program(), flags)
return _extract_includes(content)
end