diff options
| author | ruki <[email protected]> | 2019-08-31 00:45:20 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2019-08-30 22:32:04 +0800 |
| commit | bb3a62022b775dc837cbd15359d6cc56588921ac (patch) | |
| tree | 0477b7e94c3e05f37c12a193dd76a6e4726a774c /xmake/modules/private/tools/ccache.lua | |
| parent | b58574872f3475ac541580ba29068a790a63ecaf (diff) | |
improve ccache
Diffstat (limited to 'xmake/modules/private/tools/ccache.lua')
| -rw-r--r-- | xmake/modules/private/tools/ccache.lua | 23 |
1 files changed, 22 insertions, 1 deletions
diff --git a/xmake/modules/private/tools/ccache.lua b/xmake/modules/private/tools/ccache.lua index d08b78d2b..5d3e6c6f0 100644 --- a/xmake/modules/private/tools/ccache.lua +++ b/xmake/modules/private/tools/ccache.lua @@ -19,12 +19,13 @@ -- -- imports +import("core.project.config") import("lib.detect.find_tool") -- get ccache tool function _ccache() local ccache = _g.ccache - if ccache == nil then + if ccache == nil and config.get("ccache") then ccache = find_tool("ccache") _g.ccache = ccache or false end @@ -36,3 +37,23 @@ function exists() return _ccache() ~= nil end +-- uses ccache to wrap the program and arguments +-- +-- e.g. ccache program argv +-- +function cmdargv(program, argv) + + -- uses ccache? + local ccache = _ccache() + if ccache then + + -- parse the filename and arguments, e.g. "xcrun -sdk macosx clang" + if not os.isexec(program) then + argv = table.join(program:split("%s"), argv) + else + table.insert(argv, 1, program) + end + return ccache.program, argv + end + return program, argv +end |
