diff options
| author | ruki <[email protected]> | 2016-07-11 20:47:43 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2016-07-11 20:47:43 +0800 |
| commit | 4edc7a64043a5c5c2116260e00837b3f0e746c17 (patch) | |
| tree | f1c1eeebd2c2e32cd6bfc705ff3c1abec0714294 | |
| parent | 269f06dee29dd8abb0f09a9aa8be5386445ae812 (diff) | |
optimizate to generate includes
| -rwxr-xr-x | xmake/actions/build/kinds/object.lua | 47 | ||||
| -rwxr-xr-x | xmake/tools/cl.lua | 14 | ||||
| -rwxr-xr-x | xmake/tools/gcc.lua | 7 |
3 files changed, 48 insertions, 20 deletions
diff --git a/xmake/actions/build/kinds/object.lua b/xmake/actions/build/kinds/object.lua index f3ca7b0a4..85163ece8 100755 --- a/xmake/actions/build/kinds/object.lua +++ b/xmake/actions/build/kinds/object.lua @@ -99,26 +99,43 @@ function _build(target, g, index) -- check the dependent files are modified? local modified = false - _g.depfile_mtimes = _g.depfile_mtimes or {} + local objectmtime = nil + _g.depfile_results = _g.depfile_results or {} for _, depfile in ipairs(depfiles) do - -- cache the mtimes for depfiles - local depfile_mtime = _g.depfile_mtimes[depfile] - if not depfile_mtime then - depfile_mtime = os.mtime(depfile) - _g.depfile_mtimes[depfile] = depfile_mtime - end + -- optimization: this depfile has been not checked? + local status = _g.depfile_results[depfile] + if status == nil then + + -- optimization: only uses the mtime of first object file + objectmtime = objectmtime or os.mtime(objectfile) + + -- source and header files have been modified? + if os.mtime(depfile) > objectmtime then - -- source and header files have been modified? - if depfile_mtime > os.mtime(objectfile) then + -- ignore the config header, because it always changed with build version. + -- and other config content will not be changed when building each time(without reconfig or rebuild) + -- + if depfile ~= configheader then - -- ignore the config header, because it always changed with build version. - -- and other config content will not be changed when building each time(without reconfig or rebuild) - -- - if depfile ~= configheader then - modified = true - break + -- modified + modified = true + + -- mark this depfile as modified + _g.depfile_results[depfile] = true + break + end end + + -- mark this depfile as not modified + _g.depfile_results[depfile] = false + + -- has been checked and modified? + elseif status then + + -- modified + modified = true + break end end diff --git a/xmake/tools/cl.lua b/xmake/tools/cl.lua index 675bf08a3..660c47ed8 100755 --- a/xmake/tools/cl.lua +++ b/xmake/tools/cl.lua @@ -131,22 +131,28 @@ function compile(sourcefile, objectfile, incdepfile, flags) -- translate it local results = {} + local uniques = {} for includefile in string.gmatch(outdata, "including file:%s*(.-)\r*\n") do - -- check - assert(os.isfile(includefile), "invalid include file: %s for %s", includefile, incdepfile) + -- slower, only for debuging +-- assert(os.isfile(includefile), "invalid include file: %s for %s", includefile, incdepfile) -- get the relative includefile = path.relative(includefile, project.directory()) -- save it if belong to the project if not path.is_absolute(includefile) then - table.insert(results, includefile) + + -- insert it and filter repeat + if not uniques[includefile] then + table.insert(results, includefile) + uniques[includefile] = true + end end end -- update it - io.save(incdepfile, table.unique(results)) + io.save(incdepfile, results) end end diff --git a/xmake/tools/gcc.lua b/xmake/tools/gcc.lua index ebcf54050..182ce173c 100755 --- a/xmake/tools/gcc.lua +++ b/xmake/tools/gcc.lua @@ -23,6 +23,7 @@ -- imports import("core.tool.tool") import("core.project.config") +import("core.project.project") -- init it function init(shellname, kind) @@ -163,7 +164,11 @@ function compile(sourcefile, objectfile, incdepfile, flags) local results = {} local incdeps = io.read(tmpfile) for includefile in string.gmatch(incdeps, "([%w|/|%.|%-|%+|_|%$]-%.hp*)") do - table.insert(results, includefile) + + -- save it if belong to the project + if not path.is_absolute(includefile) then + table.insert(results, includefile) + end end -- update it |
