From db7508f7e43910c925e54369f2c15543d9909683 Mon Sep 17 00:00:00 2001
From: Alam Ed Arias <alam@srb2.org>
Date: Wed, 26 Feb 2025 21:02:48 -0500
Subject: [PATCH] GitLab CI: use "ccache --set-config" over tee on the
 ccache.conf file

---
 .gitlab/ci/jobs/alpine-3-gcc-makefile.yml | 12 +++++-------
 .gitlab/ci/jobs/alpine-3-gcc.yml          | 12 +++++-------
 .gitlab/ci/templates/srb2ci.yml           | 12 +++++-------
 3 files changed, 15 insertions(+), 21 deletions(-)

diff --git a/.gitlab/ci/jobs/alpine-3-gcc-makefile.yml b/.gitlab/ci/jobs/alpine-3-gcc-makefile.yml
index 6b0b6a06f5..3a17e09333 100644
--- a/.gitlab/ci/jobs/alpine-3-gcc-makefile.yml
+++ b/.gitlab/ci/jobs/alpine-3-gcc-makefile.yml
@@ -58,26 +58,24 @@ Alpine 3 GCC Makefile:
     - - |
           # ccache_config
           echo -e "\e[0Ksection_start:`date +%s`:ccache_config[collapsed=true]\r\e[0KSetting up ccache config"
-      - mkdir --parents --verbose ~/.ccache/
-      - touch ~/.ccache/ccache.conf
       - |
           # cache.conf
           echo Adding ccache configution option
       - |
           # base_dir
-          echo base_dir = $PWD                  | tee -a ~/.ccache/ccache.conf
+          ccache --set-config base_dir=$CI_PROJECT_DIR
       - |
           # cache_dir
-          echo cache_dir = $PWD/ccache          | tee -a ~/.ccache/ccache.conf
+          ccache --set-config cache_dir=$CI_PROJECT_DIR/build/ccache
       - |
           # compiler_check
-          echo compiler_check = content         | tee -a ~/.ccache/ccache.conf
+          ccache --set-config compiler_check=content
       - |
           # stats_log
-          echo stats_log = $PWD/ccache_statslog | tee -a ~/.ccache/ccache.conf
+          ccache --set-config stats_log=$CI_PROJECT_DIR/build/ccache_statslog
       - |
           # max_size
-          echo max_size = 50M                   | tee -a ~/.ccache/ccache.conf
+          ccache --set-config max_size=300M
       - |
           # ccache_config
           echo -e "\e[0Ksection_end:`date +%s`:ccache_config\r\e[0K"
diff --git a/.gitlab/ci/jobs/alpine-3-gcc.yml b/.gitlab/ci/jobs/alpine-3-gcc.yml
index 72994d405b..56339e3325 100644
--- a/.gitlab/ci/jobs/alpine-3-gcc.yml
+++ b/.gitlab/ci/jobs/alpine-3-gcc.yml
@@ -58,26 +58,24 @@ Alpine 3 GCC:
     - - |
           # ccache_config
           echo -e "\e[0Ksection_start:`date +%s`:ccache_config[collapsed=true]\r\e[0KSetting up ccache config"
-      - mkdir --parents --verbose ~/.ccache/
-      - touch ~/.ccache/ccache.conf
       - |
           # cache.conf
           echo Adding ccache configution option
       - |
           # base_dir
-          echo base_dir = $PWD                  | tee -a ~/.ccache/ccache.conf
+          ccache --set-config base_dir=$CI_PROJECT_DIR
       - |
           # cache_dir
-          echo cache_dir = $PWD/ccache          | tee -a ~/.ccache/ccache.conf
+          ccache --set-config cache_dir=$CI_PROJECT_DIR/build/ccache
       - |
           # compiler_check
-          echo compiler_check = content         | tee -a ~/.ccache/ccache.conf
+          ccache --set-config compiler_check=content
       - |
           # stats_log
-          echo stats_log = $PWD/ccache_statslog | tee -a ~/.ccache/ccache.conf
+          ccache --set-config stats_log=$CI_PROJECT_DIR/build/ccache_statslog
       - |
           # max_size
-          echo max_size = 50M                   | tee -a ~/.ccache/ccache.conf
+          ccache --set-config max_size=300M
       - |
           # ccache_config
           echo -e "\e[0Ksection_end:`date +%s`:ccache_config\r\e[0K"
diff --git a/.gitlab/ci/templates/srb2ci.yml b/.gitlab/ci/templates/srb2ci.yml
index bdf8a3ed66..102f5925dd 100644
--- a/.gitlab/ci/templates/srb2ci.yml
+++ b/.gitlab/ci/templates/srb2ci.yml
@@ -93,26 +93,24 @@
     - - |
           # ccache_config
           echo -e "\e[0Ksection_start:`date +%s`:ccache_config[collapsed=true]\r\e[0KSetting up ccache config"
-      - mkdir --parents --verbose ~/.ccache/
-      - touch ~/.ccache/ccache.conf
       - |
           # cache.conf
           echo Adding ccache configution option
       - |
           # base_dir
-          echo base_dir = $CI_PROJECT_DIR                        | tee --append ~/.ccache/ccache.conf
+          ccache --set-config base_dir=$CI_PROJECT_DIR
       - |
           # cache_dir
-          echo cache_dir = $CI_PROJECT_DIR/build/ccache          | tee --append ~/.ccache/ccache.conf
+          ccache --set-config cache_dir=$CI_PROJECT_DIR/build/ccache
       - |
           # compiler_check
-          echo compiler_check = content                          | tee --append ~/.ccache/ccache.conf
+          ccache --set-config compiler_check=content
       - |
           # stats_log
-          echo stats_log = $CI_PROJECT_DIR/build/ccache_statslog | tee --append ~/.ccache/ccache.conf
+          ccache --set-config stats_log=$CI_PROJECT_DIR/build/ccache_statslog
       - |
           # max_size
-          echo max_size = 300M                                   | tee --append ~/.ccache/ccache.conf
+          ccache --set-config max_size=300M
       - |
           # ccache_config
           echo -e "\e[0Ksection_end:`date +%s`:ccache_config\r\e[0K"
-- 
GitLab