summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorruki <[email protected]>2016-05-21 20:52:53 +0800
committerruki <[email protected]>2016-05-21 20:52:53 +0800
commit273e6abaea05b469bdb10b5cce57ff064886fe52 (patch)
tree8a089a1e70a158eb4854ac02e53bc97277bdef48
parentddcfa86234460ca764e49f8a64db05c697ffa8b6 (diff)
check the file mtime
-rwxr-xr-xxmake/actions/build/builder.lua49
-rwxr-xr-xxmake/actions/config/main.lua5
-rw-r--r--xmake/core/sandbox/modules/math.lua25
-rw-r--r--xmake/core/sandbox/modules/os.lua5
4 files changed, 56 insertions, 28 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)
diff --git a/xmake/actions/config/main.lua b/xmake/actions/config/main.lua
index 650370087..6997d8896 100755
--- a/xmake/actions/config/main.lua
+++ b/xmake/actions/config/main.lua
@@ -134,7 +134,8 @@ function main()
end
-- merge the checked configure
- if _need_check() then
+ local recheck = _need_check()
+ if recheck then
config.check()
project.check()
end
@@ -167,7 +168,7 @@ function main()
end
-- need rebuild it
- cache.set("rebuild", true)
+ cache.set("rebuild", recheck)
-- save options
cache.set("options_" .. targetname, options)
diff --git a/xmake/core/sandbox/modules/math.lua b/xmake/core/sandbox/modules/math.lua
new file mode 100644
index 000000000..a8e05cc2a
--- /dev/null
+++ b/xmake/core/sandbox/modules/math.lua
@@ -0,0 +1,25 @@
+--!The Automatic Cross-platform Build Tool
+--
+-- XMake is free software; you can redistribute it and/or modify
+-- it under the terms of the GNU Lesser General Public License as published by
+-- the Free Software Foundation; either version 2.1 of the License, or
+-- (at your option) any later version.
+--
+-- XMake is distributed in the hope that it will be useful,
+-- but WITHOUT ANY WARRANTY; without even the implied warranty of
+-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+-- GNU Lesser General Public License for more details.
+--
+-- You should have received a copy of the GNU Lesser General Public License
+-- along with XMake;
+-- If not, see <a href="http://www.gnu.org/licenses/"> http://www.gnu.org/licenses/</a>
+--
+-- Copyright (C) 2015 - 2016, ruki All rights reserved.
+--
+-- @author ruki
+-- @file math.lua
+--
+
+-- load module
+return math
+
diff --git a/xmake/core/sandbox/modules/os.lua b/xmake/core/sandbox/modules/os.lua
index 1ace961b2..71ff3c7a3 100644
--- a/xmake/core/sandbox/modules/os.lua
+++ b/xmake/core/sandbox/modules/os.lua
@@ -30,8 +30,9 @@ local vformat = require("sandbox/modules/vformat")
local sandbox_os = sandbox_os or {}
-- inherit some builtin interfaces
-sandbox_os.date = os.date
-sandbox_os.time = os.time
+sandbox_os.date = os.date
+sandbox_os.time = os.time
+sandbox_os.mtime = os.mtime
-- copy file or directory
function sandbox_os.cp(src, dst)