summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorruki <[email protected]>2017-06-19 09:48:01 +0800
committerruki <[email protected]>2017-06-19 09:48:01 +0800
commit5955e98a081d7474e1701e5fcf76a30b63f9b000 (patch)
treee0784e55ba76aa9ba38fb25127c7f4367a1f1b57
parentab8048f449cf267cadcd79ba1862985cdebaf3b7 (diff)
avoid to find ccache at same time
-rw-r--r--xmake/actions/build/kinds/object.lua30
1 files changed, 12 insertions, 18 deletions
diff --git a/xmake/actions/build/kinds/object.lua b/xmake/actions/build/kinds/object.lua
index aa738108d..1d75dd1d4 100644
--- a/xmake/actions/build/kinds/object.lua
+++ b/xmake/actions/build/kinds/object.lua
@@ -75,7 +75,7 @@ function _build_from_static(target, sourcefile, objectfile, percent)
end
-- build object
-function _build_object(target, buildinfo, index, sourcebatch)
+function _build_object(target, buildinfo, index, sourcebatch, ccache)
-- get the object and source with the given index
local sourcefile = sourcebatch.sourcefiles[index]
@@ -144,12 +144,6 @@ function _build_object(target, buildinfo, index, sourcebatch)
-- is verbose?
local verbose = option.get("verbose")
- -- get ccache
- local ccache = nil
- if config.get("ccache") then
- ccache = find_ccache()
- end
-
-- trace percent info
if verbose then
cprint("${green}[%02d%%]:${dim} %scompiling.$(mode) %s", percent, ifelse(ccache, "ccache ", ""), sourcefile)
@@ -167,7 +161,7 @@ function _build_object(target, buildinfo, index, sourcebatch)
end
-- build each objects from the given source batch
-function _build_each_objects(target, buildinfo, sourcekind, sourcebatch, jobs)
+function _build_each_objects(target, buildinfo, sourcekind, sourcebatch, jobs, ccache)
-- run build jobs for each source file
local curdir = os.curdir()
@@ -177,7 +171,7 @@ function _build_each_objects(target, buildinfo, sourcekind, sourcebatch, jobs)
os.cd(curdir)
-- build object
- _build_object(target, buildinfo, index, sourcebatch)
+ _build_object(target, buildinfo, index, sourcebatch, ccache)
end, #sourcebatch.sourcefiles, jobs)
@@ -186,7 +180,7 @@ function _build_each_objects(target, buildinfo, sourcekind, sourcebatch, jobs)
end
-- compile source files to single object at the same time
-function _build_single_object(target, buildinfo, sourcekind, sourcebatch, jobs)
+function _build_single_object(target, buildinfo, sourcekind, sourcebatch, jobs, ccache)
-- is verbose?
local verbose = option.get("verbose")
@@ -196,12 +190,6 @@ function _build_single_object(target, buildinfo, sourcekind, sourcebatch, jobs)
local objectfiles = sourcebatch.objectfiles
local incdepfiles = sourcebatch.incdepfiles
- -- get ccache
- local ccache = nil
- if config.get("ccache") then
- ccache = find_ccache()
- end
-
-- trace percent info
for index, sourcefile in ipairs(sourcefiles) do
@@ -238,6 +226,12 @@ function build(target, buildinfo)
-- get the max job count
local jobs = tonumber(option.get("jobs") or "4")
+ -- get ccache
+ local ccache = nil
+ if config.get("ccache") then
+ ccache = find_ccache()
+ end
+
-- build source batches
for sourcekind, sourcebatch in pairs(target:sourcebatches()) do
@@ -245,12 +239,12 @@ function build(target, buildinfo)
if type(sourcebatch.objectfiles) == "string" then
-- build single object
- _build_single_object(target, buildinfo, sourcekind, sourcebatch, jobs)
+ _build_single_object(target, buildinfo, sourcekind, sourcebatch, jobs, ccache)
else
-- build each objects
- _build_each_objects(target, buildinfo, sourcekind, sourcebatch, jobs)
+ _build_each_objects(target, buildinfo, sourcekind, sourcebatch, jobs, ccache)
end
end
end