diff options
| author | ruki <[email protected]> | 2016-05-21 20:52:53 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2016-05-21 20:52:53 +0800 |
| commit | 273e6abaea05b469bdb10b5cce57ff064886fe52 (patch) | |
| tree | 8a089a1e70a158eb4854ac02e53bc97277bdef48 /xmake/actions/build/builder.lua | |
| parent | ddcfa86234460ca764e49f8a64db05c697ffa8b6 (diff) | |
check the file mtime
Diffstat (limited to 'xmake/actions/build/builder.lua')
| -rwxr-xr-x | xmake/actions/build/builder.lua | 49 |
1 files changed, 25 insertions, 24 deletions
diff --git a/xmake/actions/build/builder.lua b/xmake/actions/build/builder.lua index 2ad474934..e9880eead 100755 --- a/xmake/actions/build/builder.lua +++ b/xmake/actions/build/builder.lua @@ -25,10 +25,10 @@ import("core.base.option") import("core.project.task") import("core.project.config") import("core.project.project") -import("core.project.cache") import("core.tool.tool") import("core.tool.linker") import("core.tool.compiler") +import("core.project.cache") import("core.platform.environment") -- build the object for the *.[o|obj] source file @@ -56,6 +56,11 @@ function _build_object(target, index) local sourcefile = sourcefiles[index] local objectfile = objectfiles[index] + -- we need not rebuild it if the files are not modified + if os.mtime(sourcefile) < os.mtime(objectfile) then + return + end + -- get the source file type local filetype = path.extension(sourcefile):lower() @@ -149,18 +154,31 @@ end -- build the given target function _build_target(target) - -- trace - print("[%02d%%]: building.$(mode) %s", _g.targetindex * 100 / _g.targetcount, target:name()) - -- build objects _build_objects(target) + -- make headers + local srcheaders, dstheaders = target:headerfiles() + if srcheaders and dstheaders then + local i = 1 + for _, srcheader in ipairs(srcheaders) do + local dstheader = dstheaders[i] + if dstheader then + os.cp(srcheader, dstheader) + end + i = i + 1 + end + end + + -- update target index + _g.targetindex = _g.targetindex + 1 + -- make the command for linking target local targetfile = target:targetfile() local command = linker.command(target) -- trace - print("[%02d%%]: linking.$(mode) %s", (_g.targetindex + 1) * 100 / _g.targetcount, path.filename(targetfile)) + print("[%02d%%]: linking.$(mode) %s", _g.targetindex * 100 / _g.targetcount, path.filename(targetfile)) -- trace verbose info if option.get("verbose") then @@ -172,22 +190,6 @@ function _build_target(target) -- run command os.run(command) - - -- make headers - local srcheaders, dstheaders = target:headerfiles() - if srcheaders and dstheaders then - local i = 1 - for _, srcheader in ipairs(srcheaders) do - local dstheader = dstheaders[i] - if dstheader then - os.cp(srcheader, dstheader) - end - i = i + 1 - end - end - - -- update target index - _g.targetindex = _g.targetindex + 1 end -- make the given target @@ -205,7 +207,7 @@ function _make_target(target) for i = 1, 3 do local script = scripts[i] if script ~= nil then - script(target) + return script(target) end end end @@ -220,7 +222,7 @@ function _make_target_and_deps(target) -- make for all dependent targets for _, depname in ipairs(target:get("deps")) do - _make_target_and_deps(project.target(depname)) + _make_target_and_deps(project.target(depname)) end -- make target @@ -230,7 +232,6 @@ function _make_target_and_deps(target) _g.finished[target:name()] = true end - -- stats the given target and deps function _stat_target_count_and_deps(target) |
