diff options
| author | star9029 <[email protected]> | 2024-12-02 22:53:20 +0800 |
|---|---|---|
| committer | star9029 <[email protected]> | 2024-12-02 22:53:20 +0800 |
| commit | d9bc6250c4cab08285cbeab73293886527098f14 (patch) | |
| tree | a69ff7b0f85a12e5009b76af4c52e61aafbb54ce | |
| parent | 42934990cefe25d78a98e4314a56f9c8b9b6f281 (diff) | |
Improve ccache tool
| -rw-r--r-- | xmake/modules/private/action/require/impl/actions/install.lua | 8 | ||||
| -rw-r--r-- | xmake/modules/private/tools/ccache.lua | 10 | ||||
| -rw-r--r-- | xmake/rules/platform/linux/driver/driver_modules.lua | 1 |
3 files changed, 8 insertions, 11 deletions
diff --git a/xmake/modules/private/action/require/impl/actions/install.lua b/xmake/modules/private/action/require/impl/actions/install.lua index 0a6e9b0be..1e64be14e 100644 --- a/xmake/modules/private/action/require/impl/actions/install.lua +++ b/xmake/modules/private/action/require/impl/actions/install.lua @@ -26,7 +26,7 @@ import("core.project.target") import("core.project.project") import("core.platform.platform") import("lib.detect.find_file") -import("lib.detect.find_tool") +import("private.tools.ccache") import("private.action.require.impl.actions.test") import("private.action.require.impl.actions.patch_sources") import("private.action.require.impl.actions.download_resources") @@ -354,11 +354,7 @@ function _enable_ccache(package) return end - local ccache = find_tool("ccache") - if not ccache then - ccache = find_tool("sccache") - end - + local ccache = ccache.get() if ccache then local name = path.basename(ccache.program) package:data_set("ccache", name) diff --git a/xmake/modules/private/tools/ccache.lua b/xmake/modules/private/tools/ccache.lua index 4a877d2b1..12bb0cdd0 100644 --- a/xmake/modules/private/tools/ccache.lua +++ b/xmake/modules/private/tools/ccache.lua @@ -23,18 +23,20 @@ import("core.project.config") import("lib.detect.find_tool") -- get ccache tool -function _ccache() +function get() local ccache = _g.ccache if ccache == nil and config.get("ccache") then ccache = find_tool("ccache") + if not ccache then + ccache = find_tool("sccache") + end _g.ccache = ccache or false end return ccache or nil end --- exists ccache? function exists() - return _ccache() ~= nil + return get() ~= nil end -- uses ccache to wrap the program and arguments @@ -44,7 +46,7 @@ end function cmdargv(program, argv) -- uses ccache? - local ccache = _ccache() + local ccache = get() if ccache then -- parse the filename and arguments, e.g. "xcrun -sdk macosx clang" diff --git a/xmake/rules/platform/linux/driver/driver_modules.lua b/xmake/rules/platform/linux/driver/driver_modules.lua index a89a28938..8218a972c 100644 --- a/xmake/rules/platform/linux/driver/driver_modules.lua +++ b/xmake/rules/platform/linux/driver/driver_modules.lua @@ -24,7 +24,6 @@ import("core.project.depend") import("core.cache.memcache") import("lib.detect.find_tool") import("utils.progress") -import("private.tools.ccache") -- get linux-headers sdk function _get_linux_headers_sdk(target) |
