diff options
| author | ruki <[email protected]> | 2015-06-05 10:18:00 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2015-06-05 10:18:00 +0800 |
| commit | 12ce7dea3c7a74f77e9792236cb85bab4fd001e4 (patch) | |
| tree | a64fd1ef7c1380ae63e5c982472e8712489b3374 /xmake/scripts/base/makefile.lua | |
| parent | f9cecfd11c958122bb6d619069593b91333bdf6f (diff) | |
add ccache
Diffstat (limited to 'xmake/scripts/base/makefile.lua')
| -rw-r--r-- | xmake/scripts/base/makefile.lua | 29 |
1 files changed, 26 insertions, 3 deletions
diff --git a/xmake/scripts/base/makefile.lua b/xmake/scripts/base/makefile.lua index c3af02d05..275e15d07 100644 --- a/xmake/scripts/base/makefile.lua +++ b/xmake/scripts/base/makefile.lua @@ -34,6 +34,7 @@ local project = require("base/project") local linker = require("base/linker") local compiler = require("base/compiler") local tools = require("tools/tools") +local platform = require("platform/platform") -- make the object to the makefile function makefile._make_object(file, target, srcfile, objfile) @@ -49,6 +50,22 @@ function makefile._make_object(file, target, srcfile, objfile) return false end + -- get mode + local mode = config.get("mode") or "" + if mode == "release" then mode = ".r" + elseif mode == "debug" then mode = ".d" + elseif mode == "profile" then mode = ".p" + else mode = "" end + + -- get ccache + local ccache = platform.tool("ccache") + + -- make command + local cmd = compiler.make(c, target, srcfile, objfile) + if ccache then + cmd = ccache:append(cmd, " ") + end + -- make head file:write(string.format("%s:", objfile)) @@ -56,8 +73,7 @@ function makefile._make_object(file, target, srcfile, objfile) file:write(string.format(" %s\n", srcfile)) -- make body - local cmd = compiler.make(c, target, srcfile, objfile) - file:write(string.format("\t@echo [%s]: compiling %s\n", config.get("mode"), srcfile)) + file:write(string.format("\t@echo %scompiling%s %s\n", utils.ifelse(ccache, "ccache ", ""), mode, srcfile)) file:write(string.format("\t@xmake l $(VERBOSE) verbose \"%s\"\n", cmd:gsub("%s", "%%20"))) file:write(string.format("\t@xmake l mkdir %s\n", path.directory(objfile))) file:write(string.format("\t@%s > %s 2>&1\n", cmd, makefile._LOGFILE)) @@ -130,9 +146,16 @@ function makefile._make_target(file, name, target) -- make dependence end file:write("\n") + -- get mode + local mode = config.get("mode") or "" + if mode == "release" then mode = ".r" + elseif mode == "debug" then mode = ".d" + elseif mode == "profile" then mode = ".p" + else mode = "" end + -- make body local cmd = linker.make(l, target, objfiles, targetfile) - file:write(string.format("\t@echo [%s]: linking %s\n", config.get("mode"), path.filename(targetfile))) + file:write(string.format("\t@echo linking%s %s\n", mode, path.filename(targetfile))) file:write(string.format("\t@xmake l $(VERBOSE) verbose \"%s\"\n", cmd:gsub("%s", "%%20"))) file:write(string.format("\t@xmake l mkdir %s\n", path.directory(targetfile))) file:write(string.format("\t@%s > %s 2>&1\n", cmd, makefile._LOGFILE)) |
