This is an automated email from the ASF dual-hosted git repository.

gangwu pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/iceberg-cpp.git


The following commit(s) were added to refs/heads/main by this push:
     new 7e784dc5 chore: optimize windows ci by using sccache (#466)
7e784dc5 is described below

commit 7e784dc59c0ad81d11586cc58bcca392318ce9b9
Author: Gang Wu <[email protected]>
AuthorDate: Wed Dec 31 23:44:30 2025 +0800

    chore: optimize windows ci by using sccache (#466)
---
 .github/workflows/test.yml         | 13 +++++++++----
 CMakeLists.txt                     |  1 +
 ci/scripts/build_iceberg.sh        |  6 ++++++
 cmake_modules/IcebergSccache.cmake | 36 ++++++++++++++++++++++++++++++++++++
 4 files changed, 52 insertions(+), 4 deletions(-)

diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml
index 621c4b3c..298100bc 100644
--- a/.github/workflows/test.yml
+++ b/.github/workflows/test.yml
@@ -77,9 +77,9 @@ jobs:
         shell: bash
         run: ci/scripts/build_example.sh $(pwd)/example
   windows:
-    name: AMD64 Windows 2022
-    runs-on: windows-2022
-    timeout-minutes: 30
+    name: AMD64 Windows 2025
+    runs-on: windows-2025
+    timeout-minutes: 60
     strategy:
       fail-fast: false
     steps:
@@ -89,11 +89,16 @@ jobs:
         shell: cmd
         run: |
           vcpkg install zlib:x64-windows nlohmann-json:x64-windows 
nanoarrow:x64-windows roaring:x64-windows cpr:x64-windows
+      - name: Setup sccache
+        uses: 
mozilla-actions/sccache-action@7d986dd989559c6ecdb630a3fd2557667be217ad # v0.0.9
       - name: Build Iceberg
         shell: cmd
+        env:
+          SCCACHE_GHA_ENABLED: "true"
         run: |
           call "C:\Program Files\Microsoft Visual 
Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64
-          bash -c "ci/scripts/build_iceberg.sh $(pwd)"
+          bash -c "ci/scripts/build_iceberg.sh $(pwd) OFF ON"
+          sccache --show-stats
       - name: Build Example
         shell: cmd
         run: |
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 5c956b1b..abc2f3c4 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -69,6 +69,7 @@ endif()
 include(CMakeParseArguments)
 include(IcebergBuildUtils)
 include(IcebergSanitizer)
+include(IcebergSccache)
 include(IcebergThirdpartyToolchain)
 
 if(ICEBERG_BUILD_TESTS)
diff --git a/ci/scripts/build_iceberg.sh b/ci/scripts/build_iceberg.sh
index cb23a53c..102c8ec1 100755
--- a/ci/scripts/build_iceberg.sh
+++ b/ci/scripts/build_iceberg.sh
@@ -22,6 +22,7 @@ set -eux
 source_dir=${1}
 build_dir=${1}/build
 build_rest_integration_test=${2:-OFF}
+build_enable_sccache=${3:-OFF}
 
 mkdir ${build_dir}
 pushd ${build_dir}
@@ -45,6 +46,11 @@ else
     CMAKE_ARGS+=("-DCMAKE_BUILD_TYPE=Debug")
 fi
 
+if [[ "${build_enable_sccache}" == "ON" ]]; then
+    CMAKE_ARGS+=("-DCMAKE_CXX_COMPILER_LAUNCHER=sccache")
+    CMAKE_ARGS+=("-DCMAKE_C_COMPILER_LAUNCHER=sccache")
+fi
+
 cmake "${CMAKE_ARGS[@]}" ${source_dir}
 if is_windows; then
   cmake --build . --config Release --target install
diff --git a/cmake_modules/IcebergSccache.cmake 
b/cmake_modules/IcebergSccache.cmake
new file mode 100644
index 00000000..d02e65df
--- /dev/null
+++ b/cmake_modules/IcebergSccache.cmake
@@ -0,0 +1,36 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you 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.
+
+if(MSVC_TOOLCHAIN AND "${CMAKE_CXX_COMPILER_LAUNCHER}" STREQUAL "sccache")
+  message(STATUS "Configuring sccache for MSVC")
+
+  # Remove /Zi or /ZI
+  string(REGEX REPLACE "/Z[iI]" "" CMAKE_C_FLAGS_DEBUG 
"${CMAKE_C_FLAGS_DEBUG}")
+  string(REGEX REPLACE "/Z[iI]" "" CMAKE_CXX_FLAGS_DEBUG 
"${CMAKE_CXX_FLAGS_DEBUG}")
+
+  string(REGEX REPLACE "/Z[iI]" "" CMAKE_C_FLAGS_RELWITHDEBINFO
+                       "${CMAKE_C_FLAGS_RELWITHDEBINFO}")
+  string(REGEX REPLACE "/Z[iI]" "" CMAKE_CXX_FLAGS_RELWITHDEBINFO
+                       "${CMAKE_CXX_FLAGS_RELWITHDEBINFO}")
+
+  # Add /Z7
+  set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} /Z7")
+  set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} /Z7")
+
+  set(CMAKE_C_FLAGS_RELWITHDEBINFO "${CMAKE_C_FLAGS_RELWITHDEBINFO} /Z7")
+  set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO} /Z7")
+endif()

Reply via email to