diff options
| author | ruki <[email protected]> | 2023-03-20 22:29:12 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2023-03-20 22:29:12 +0800 |
| commit | 2891d0a122e4d320a7b3880810595652f21d0ce6 (patch) | |
| tree | 82c04a76178699ddd89499b62455f53d867bb86c | |
| parent | 8f80d4f01d31bf3a873e7b5797d3ed97c569f23e (diff) | |
disable ccache on ci
| -rw-r--r-- | tests/test_utils/test_build.lua | 3 | ||||
| -rw-r--r-- | xmake/actions/build/statistics.lua | 8 | ||||
| -rw-r--r-- | xmake/modules/private/cache/build_cache.lua | 7 | ||||
| -rw-r--r-- | xmake/modules/utils/ci/is_running.lua | 35 |
4 files changed, 46 insertions, 7 deletions
diff --git a/tests/test_utils/test_build.lua b/tests/test_utils/test_build.lua index 2a42e67d8..43941d320 100644 --- a/tests/test_utils/test_build.lua +++ b/tests/test_utils/test_build.lua @@ -17,7 +17,8 @@ function test_build:build(argv) os.exec("xmake uninstall --installdir=$(tmpdir) -D") end os.exec("xmake c -D") - os.exec("xmake f --mode=debug -D -y") + -- we force to enable ccache to test it on ci + os.exec("xmake f --mode=debug --policies=build.ccache:y -D -y") os.exec("xmake m -b") os.exec("xmake -r -a -D") os.exec("xmake m -e buildtest") diff --git a/xmake/actions/build/statistics.lua b/xmake/actions/build/statistics.lua index 9a4c196c5..7619526a5 100644 --- a/xmake/actions/build/statistics.lua +++ b/xmake/actions/build/statistics.lua @@ -23,6 +23,7 @@ import("core.base.option") import("core.base.process") import("core.project.config") import("core.platform.platform") +import("utils.ci.is_running", {alias = "ci_is_running"}) import("private.action.update.fetch_version") import("private.action.require.impl.packagenv") @@ -35,14 +36,11 @@ function _is_enabled() return false end - -- is in ci(travis/appveyor/...)? need not post it - local ci = (os.getenv("CI") or os.getenv("GITHUB_ACTIONS") or ""):lower() - if ci == "true" then + -- is running on ci(travis/appveyor/...)? need not post it + if ci_is_running() then os.setenv("XMAKE_STATS", "false") return false end - - -- ok return true end diff --git a/xmake/modules/private/cache/build_cache.lua b/xmake/modules/private/cache/build_cache.lua index 27e4cee7c..bac6c069b 100644 --- a/xmake/modules/private/cache/build_cache.lua +++ b/xmake/modules/private/cache/build_cache.lua @@ -25,6 +25,7 @@ import("core.cache.memcache") import("core.project.config") import("core.project.policy") import("core.project.project") +import("utils.ci.is_running", {alias = "ci_is_running"}) import("private.service.client_config") import("private.service.remote_cache.client", {alias = "remote_cache_client"}) @@ -54,7 +55,7 @@ function is_enabled(target) local result = _memcache():get2("enabled", key) if result == nil then -- target may be option instance - if target and target.policy then + if result == nil and target and target.policy then result = target:policy("build.ccache") end if result == nil and os.isfile(os.projectfile()) then @@ -63,6 +64,10 @@ function is_enabled(target) result = policy end end + -- disable ccache on ci + if result == nil and ci_is_running() then + result = false + end -- disable ccache for msvc, because cl.exe preprocessor is too slower -- @see https://github.com/xmake-io/xmake/issues/3532 if result == nil and is_host("windows") and diff --git a/xmake/modules/utils/ci/is_running.lua b/xmake/modules/utils/ci/is_running.lua new file mode 100644 index 000000000..515f3c276 --- /dev/null +++ b/xmake/modules/utils/ci/is_running.lua @@ -0,0 +1,35 @@ +--!A cross-platform build utility based on Lua +-- +-- Licensed under the Apache License, Version 2.0 (the "License"); +-- you may not use this file except in compliance with the License. +-- You may obtain a copy of the License at +-- +-- http://www.apache.org/licenses/LICENSE-2.0 +-- +-- Unless required by applicable law or agreed to in writing, software +-- distributed under the License is distributed on an "AS IS" BASIS, +-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +-- See the License for the specific language governing permissions and +-- limitations under the License. +-- +-- Copyright (C) 2015-present, TBOOX Open Source Group. +-- +-- @author ruki +-- @file is_running.lua +-- + +-- is running on ci(travis/appveyor/...)? +function main() + local on_ci = _g._ON_CI + if on_ci == nil then + local ci = (os.getenv("CI") or os.getenv("GITHUB_ACTIONS") or ""):lower() + if ci == "true" or ci == "1" then + on_ci = true + else + on_ci = false + end + _g._ON_CI = on_ci + end + return on_ci +end + |
