From c6ec99c5d674872df8d89b6b9a90b16b8eb63c34 Mon Sep 17 00:00:00 2001
From: Justin Pryzby <pryzbyj@telsasoft.com>
Date: Wed, 25 May 2022 22:05:13 -0500
Subject: [PATCH 12/21] WIP: cirrus/windows: ccache

https://www.postgresql.org/message-id/flat/20220522232606.GZ19626%40telsasoft.com

Note that cache misses are *several times* slower than running the compiler
directly, so maybe this should be "opt-in" but not used by cfbot with msbuild.

https://cirrus-ci.com/task/5860173364330496 build: 12min 44sec
https://cirrus-ci.com/task/5802653564272640 build: 1min 39sec

ci-os-only: windows, windows-msvc
---
 .cirrus.yml | 19 ++++++++++++++++---
 1 file changed, 16 insertions(+), 3 deletions(-)

diff --git a/.cirrus.yml b/.cirrus.yml
index 02f04aa98bb..50a34373647 100644
--- a/.cirrus.yml
+++ b/.cirrus.yml
@@ -372,7 +372,10 @@ task:
     # disable file tracker, we're never going to rebuild, and it slows down the
     #   build
     # -fileLoggerParameters1: write warnings to msbuild.warn.log.
-    MSBFLAGS: -m -verbosity:minimal "-consoleLoggerParameters:Summary;ForceNoAlign" /p:TrackFileAccess=false -nologo -fileLoggerParameters1:warningsonly;logfile=msbuild.warn.log
+    MSBFLAGS: -m -verbosity:minimal "-consoleLoggerParameters:Summary;ForceNoAlign" /p:TrackFileAccess=false -nologo -fileLoggerParameters1:warningsonly;logfile=msbuild.warn.log /p:UseMultiToolTask=true /p:EnforceProcessCountAcrossBuilds=true /p:CLToolPath=c:\ProgramData\chocolatey\bin
+
+    CCACHE_DIR: $CIRRUS_WORKING_DIR/.ccache
+    CCACHE_LOGFILE: ccache.log
 
     DebugInformationFormat: OldStyle
 
@@ -396,6 +399,7 @@ task:
     image: $CONTAINER_REPO/windows_ci_vs_2019:latest
     cpu: $CPUS
     memory: 4G
+    greedy: true
 
   sysinfo_script: |
     chcp
@@ -403,8 +407,12 @@ task:
     powershell -Command get-psdrive -psprovider filesystem
     set
 
-  setup_additional_packages_script: |
-    REM choco install -y --no-progress ...
+  setup_additional_packages_script:
+    - choco install -y --no-progress ccache --version 4.6.1
+    - cp c:\ProgramData\chocolatey\lib\ccache\tools\ccache-4.6.1-windows-x86_64\ccache.exe \ProgramData\chocolatey\bin\cl.exe
+
+  ccache_cache:
+    folder: $CCACHE_DIR
 
   configure_script:
     # copy errors out when using forward slashes
@@ -412,8 +420,13 @@ task:
     - vcvarsall x64
     - perl src/tools/msvc/mkvcbuild.pl
   build_script:
+    #- ccache --clear
     - vcvarsall x64
     - msbuild %MSBFLAGS% pgsql.sln
+
+  always:
+    upload_caches: ccache
+
   tempinstall_script:
     # Installation on windows currently only completely works from src/tools/msvc
     - cd src/tools/msvc && perl install.pl %CIRRUS_WORKING_DIR%/tmp_install
-- 
2.17.1

