From 680ff3f7b4da1dbf21d0c7cd87af9bb5ee8b230c Mon Sep 17 00:00:00 2001
From: Andres Freund <andres@anarazel.de>
Date: Wed, 21 Sep 2022 20:36:36 -0700
Subject: [PATCH v17 01/23] meson: ci: wip: move compilerwarnings task to meson

---
 .cirrus.yml                            | 92 +++++++++++++-------------
 src/tools/ci/linux-mingw-w64-64bit.txt | 13 ++++
 2 files changed, 59 insertions(+), 46 deletions(-)
 create mode 100644 src/tools/ci/linux-mingw-w64-64bit.txt

diff --git a/.cirrus.yml b/.cirrus.yml
index 7b5cb021027..eb33fdc4855 100644
--- a/.cirrus.yml
+++ b/.cirrus.yml
@@ -465,6 +465,10 @@ task:
   ccache_cache:
     folder: $CCACHE_DIR
 
+  ccache_stats_start_script:
+    ccache -s
+    ccache -z
+
   setup_additional_packages_script: |
     #apt-get update
     #DEBIAN_FRONTEND=noninteractive apt-get -y install ...
@@ -473,8 +477,6 @@ task:
   # Test that code can be built with gcc/clang without warnings
   ###
 
-  setup_script: echo "COPT=-Werror" > src/Makefile.custom
-
   # Trace probes have a history of getting accidentally broken. Use the
   # different compilers to build with different combinations of dtrace on/off
   # and cassert on/off.
@@ -482,57 +484,58 @@ task:
   # gcc, cassert off, dtrace on
   always:
     gcc_warning_script: |
-      time ./configure \
-        --cache gcc.cache \
-        --enable-dtrace \
-        ${LINUX_CONFIGURE_FEATURES} \
-        CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang"
-      make -s -j${BUILD_JOBS} clean
-      time make -s -j${BUILD_JOBS} world-bin
+      mkdir build && cd build
+      CC="ccache gcc" CXX="ccache g++" \
+        meson setup \
+          -Dwerror=true \
+          -Dcassert=false \
+          -Ddtrace=enabled \
+          ${LINUX_MESON_FEATURES} \
+          ..
+      time ninja -j${BUILD_JOBS}
 
   # gcc, cassert on, dtrace off
   always:
     gcc_a_warning_script: |
-      time ./configure \
-        --cache gcc.cache \
-        --enable-cassert \
-        ${LINUX_CONFIGURE_FEATURES} \
-        CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang"
-      make -s -j${BUILD_JOBS} clean
-      time make -s -j${BUILD_JOBS} world-bin
+      cd build
+      meson configure \
+        -Dcassert=true \
+        -Ddtrace=disabled
+      time ninja -j${BUILD_JOBS}
 
   # clang, cassert off, dtrace off
   always:
     clang_warning_script: |
-      time ./configure \
-        --cache clang.cache \
-        ${LINUX_CONFIGURE_FEATURES} \
-        CC="ccache clang" CXX="ccache clang++" CLANG="ccache clang"
-      make -s -j${BUILD_JOBS} clean
-      time make -s -j${BUILD_JOBS} world-bin
+      rm -rf build
+      mkdir build && cd build
+      CC="ccache clang" CXX="ccache clang++" \
+        meson setup \
+          -Dwerror=true \
+          -Dcassert=false \
+          -Ddtrace=disabled \
+          ${LINUX_MESON_FEATURES} \
+          ..
+      time ninja -j${BUILD_JOBS}
 
   # clang, cassert on, dtrace on
   always:
     clang_a_warning_script: |
-      time ./configure \
-        --cache clang.cache \
-        --enable-cassert \
-        --enable-dtrace \
-        ${LINUX_CONFIGURE_FEATURES} \
-        CC="ccache clang" CXX="ccache clang++" CLANG="ccache clang"
-      make -s -j${BUILD_JOBS} clean
-      time make -s -j${BUILD_JOBS} world-bin
+      cd build
+      meson configure \
+        -Dcassert=true \
+        -Ddtrace=enabled
+      time ninja -j${BUILD_JOBS}
 
   # cross-compile to windows
   always:
     mingw_cross_warning_script: |
-      time ./configure \
-        --host=x86_64-w64-mingw32 \
-        --enable-cassert \
-        CC="ccache x86_64-w64-mingw32-gcc" \
-        CXX="ccache x86_64-w64-mingw32-g++"
-      make -s -j${BUILD_JOBS} clean
-      time make -s -j${BUILD_JOBS} world-bin
+      mkdir build-w64 && cd build-w64
+      meson setup \
+        --cross-file=../src/tools/ci/linux-mingw-w64-64bit.txt \
+        -Dwerror=true \
+        -Dcassert=true \
+        ..
+      time ninja -j${BUILD_JOBS}
 
   ###
   # Verify docs can be built
@@ -540,13 +543,8 @@ task:
   # XXX: Only do this if there have been changes in doc/ since last build
   always:
     docs_build_script: |
-      time ./configure \
-        --cache gcc.cache \
-        CC="ccache gcc" \
-        CXX="ccache g++" \
-        CLANG="ccache clang"
-      make -s -j${BUILD_JOBS} clean
-      time make -s -j${BUILD_JOBS} -C doc
+      cd build
+      time ninja docs
 
   ###
   # Verify headerscheck / cpluspluscheck succeed
@@ -563,11 +561,13 @@ task:
         ${LINUX_CONFIGURE_FEATURES} \
         --without-icu \
         --quiet \
-        CC="gcc" CXX"=g++" CLANG="clang"
-      make -s -j${BUILD_JOBS} clean
+        CC="ccache gcc" CXX="ccache g++" CLANG="ccache clang"
+      make -s -j${BUILD_JOBS} world-bin
       time make -s headerscheck EXTRAFLAGS='-fmax-errors=10'
     headers_cpluspluscheck_script: |
       time make -s cpluspluscheck EXTRAFLAGS='-fmax-errors=10'
 
   always:
+    ccache_stats_end_script:
+      ccache -s
     upload_caches: ccache
diff --git a/src/tools/ci/linux-mingw-w64-64bit.txt b/src/tools/ci/linux-mingw-w64-64bit.txt
new file mode 100644
index 00000000000..9d43b6dcfbc
--- /dev/null
+++ b/src/tools/ci/linux-mingw-w64-64bit.txt
@@ -0,0 +1,13 @@
+[binaries]
+c = ['ccache', '/usr/bin/x86_64-w64-mingw32-gcc']
+cpp = ['ccache', '/usr/bin/x86_64-w64-mingw32-g++']
+ar = '/usr/bin/x86_64-w64-mingw32-ar'
+strip = '/usr/bin/x86_64-w64-mingw32-strip'
+pkgconfig = '/usr/bin/x86_64-w64-mingw32-pkg-config'
+windres = '/usr/bin/x86_64-w64-mingw32-windres'
+
+[host_machine]
+system = 'windows'
+cpu_family = 'x86_64'
+cpu = 'x86_64'
+endian = 'little'
-- 
2.37.3.542.gdd3f6c4cae

