From 63f1b4531bad1b529e33918fd3bb39e3dc30a6d7 Mon Sep 17 00:00:00 2001 From: Eric Engestrom Date: Fri, 17 Mar 2023 23:51:21 +0000 Subject: [PATCH] ci: deduplicate compiler wrappers MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Eric Engestrom Suggested-by: Michel Dänzer Reviewed-by: Michel Dänzer Part-of: --- .gitlab-ci/build/clang-link-werror.sh | 21 --------------------- .gitlab-ci/build/compiler-wrapper-clang++.sh | 3 +++ .gitlab-ci/build/compiler-wrapper-clang.sh | 3 +++ .gitlab-ci/build/compiler-wrapper-g++.sh | 3 +++ .gitlab-ci/build/compiler-wrapper-gcc.sh | 3 +++ .../{clang++-link-werror.sh => compiler-wrapper.sh} | 6 +++--- .gitlab-ci/build/g++-link-werror.sh | 21 --------------------- .gitlab-ci/build/gcc-link-werror.sh | 21 --------------------- .gitlab-ci/meson/build.sh | 4 ++-- 9 files changed, 17 insertions(+), 68 deletions(-) delete mode 100755 .gitlab-ci/build/clang-link-werror.sh create mode 100755 .gitlab-ci/build/compiler-wrapper-clang++.sh create mode 100755 .gitlab-ci/build/compiler-wrapper-clang.sh create mode 100755 .gitlab-ci/build/compiler-wrapper-g++.sh create mode 100755 .gitlab-ci/build/compiler-wrapper-gcc.sh rename .gitlab-ci/build/{clang++-link-werror.sh => compiler-wrapper.sh} (83%) delete mode 100755 .gitlab-ci/build/g++-link-werror.sh delete mode 100755 .gitlab-ci/build/gcc-link-werror.sh diff --git a/.gitlab-ci/build/clang-link-werror.sh b/.gitlab-ci/build/clang-link-werror.sh deleted file mode 100755 index 0486782..0000000 --- a/.gitlab-ci/build/clang-link-werror.sh +++ /dev/null @@ -1,21 +0,0 @@ -#!/bin/sh -e - -if command -V ccache >/dev/null 2>/dev/null; then - CCACHE=ccache -else - CCACHE= -fi - -if [ "$(ps -p $(ps -p $PPID -o ppid --no-headers) -o comm --no-headers)" != ninja ]; then - # Not invoked by ninja (e.g. for a meson feature check) - exec $CCACHE clang "$@" -fi - -if [ "$(eval printf "'%s'" "\"\${$(($#-1))}\"")" = "-c" ]; then - # Not invoked for linking - exec $CCACHE clang "$@" -fi - -# Compiler invoked by ninja for linking. Add -Werror to turn compiler warnings into errors -# with LTO. (meson's werror should arguably do this, but meanwhile we need to) -exec $CCACHE clang "$@" -Werror diff --git a/.gitlab-ci/build/compiler-wrapper-clang++.sh b/.gitlab-ci/build/compiler-wrapper-clang++.sh new file mode 100755 index 0000000..69c28bf --- /dev/null +++ b/.gitlab-ci/build/compiler-wrapper-clang++.sh @@ -0,0 +1,3 @@ +#!/bin/sh +_COMPILER=clang++ +. compiler-wrapper.sh diff --git a/.gitlab-ci/build/compiler-wrapper-clang.sh b/.gitlab-ci/build/compiler-wrapper-clang.sh new file mode 100755 index 0000000..a4e119b --- /dev/null +++ b/.gitlab-ci/build/compiler-wrapper-clang.sh @@ -0,0 +1,3 @@ +#!/bin/sh +_COMPILER=clang +. compiler-wrapper.sh diff --git a/.gitlab-ci/build/compiler-wrapper-g++.sh b/.gitlab-ci/build/compiler-wrapper-g++.sh new file mode 100755 index 0000000..a0bfadb --- /dev/null +++ b/.gitlab-ci/build/compiler-wrapper-g++.sh @@ -0,0 +1,3 @@ +#!/bin/sh +_COMPILER=g++ +. compiler-wrapper.sh diff --git a/.gitlab-ci/build/compiler-wrapper-gcc.sh b/.gitlab-ci/build/compiler-wrapper-gcc.sh new file mode 100755 index 0000000..e9c0d15 --- /dev/null +++ b/.gitlab-ci/build/compiler-wrapper-gcc.sh @@ -0,0 +1,3 @@ +#!/bin/sh +_COMPILER=gcc +. compiler-wrapper.sh diff --git a/.gitlab-ci/build/clang++-link-werror.sh b/.gitlab-ci/build/compiler-wrapper.sh similarity index 83% rename from .gitlab-ci/build/clang++-link-werror.sh rename to .gitlab-ci/build/compiler-wrapper.sh index 938327a..12a70fe 100755 --- a/.gitlab-ci/build/clang++-link-werror.sh +++ b/.gitlab-ci/build/compiler-wrapper.sh @@ -8,14 +8,14 @@ fi if [ "$(ps -p $(ps -p $PPID -o ppid --no-headers) -o comm --no-headers)" != ninja ]; then # Not invoked by ninja (e.g. for a meson feature check) - exec $CCACHE clang++ "$@" + exec $CCACHE $_COMPILER "$@" fi if [ "$(eval printf "'%s'" "\"\${$(($#-1))}\"")" = "-c" ]; then # Not invoked for linking - exec $CCACHE clang++ "$@" + exec $CCACHE $_COMPILER "$@" fi # Compiler invoked by ninja for linking. Add -Werror to turn compiler warnings into errors # with LTO. (meson's werror should arguably do this, but meanwhile we need to) -exec $CCACHE clang++ "$@" -Werror +exec $CCACHE $_COMPILER "$@" -Werror diff --git a/.gitlab-ci/build/g++-link-werror.sh b/.gitlab-ci/build/g++-link-werror.sh deleted file mode 100755 index 649549c..0000000 --- a/.gitlab-ci/build/g++-link-werror.sh +++ /dev/null @@ -1,21 +0,0 @@ -#!/bin/sh -e - -if command -V ccache >/dev/null 2>/dev/null; then - CCACHE=ccache -else - CCACHE= -fi - -if [ "$(ps -p $(ps -p $PPID -o ppid --no-headers) -o comm --no-headers)" != ninja ]; then - # Not invoked by ninja (e.g. for a meson feature check) - exec $CCACHE g++ "$@" -fi - -if [ "$(eval printf "'%s'" "\"\${$(($#-1))}\"")" = "-c" ]; then - # Not invoked for linking - exec $CCACHE g++ "$@" -fi - -# Compiler invoked by ninja for linking. Add -Werror to turn compiler warnings into errors -# with LTO. (meson's werror should arguably do this, but meanwhile we need to) -exec $CCACHE g++ "$@" -Werror diff --git a/.gitlab-ci/build/gcc-link-werror.sh b/.gitlab-ci/build/gcc-link-werror.sh deleted file mode 100755 index 3e8c69f..0000000 --- a/.gitlab-ci/build/gcc-link-werror.sh +++ /dev/null @@ -1,21 +0,0 @@ -#!/bin/sh -e - -if command -V ccache >/dev/null 2>/dev/null; then - CCACHE=ccache -else - CCACHE= -fi - -if [ "$(ps -p $(ps -p $PPID -o ppid --no-headers) -o comm --no-headers)" != ninja ]; then - # Not invoked by ninja (e.g. for a meson feature check) - exec $CCACHE gcc "$@" -fi - -if [ "$(eval printf "'%s'" "\"\${$(($#-1))}\"")" = "-c" ]; then - # Not invoked for linking - exec $CCACHE gcc "$@" -fi - -# Compiler invoked by ninja for linking. Add -Werror to turn compiler warnings into errors -# with LTO. (meson's werror should arguably do this, but meanwhile we need to) -exec $CCACHE gcc "$@" -Werror diff --git a/.gitlab-ci/meson/build.sh b/.gitlab-ci/meson/build.sh index 47b0693..f6e57e7 100755 --- a/.gitlab-ci/meson/build.sh +++ b/.gitlab-ci/meson/build.sh @@ -12,8 +12,8 @@ export PATH=$PATH:$PWD/.gitlab-ci/build touch native.file printf > native.file "%s\n" \ "[binaries]" \ - "c = '${CC:-gcc}-link-werror.sh'" \ - "cpp = '${CXX:-g++}-link-werror.sh'" + "c = 'compiler-wrapper-${CC:-gcc}.sh'" \ + "cpp = 'compiler-wrapper-${CXX:-g++}.sh'" # We need to control the version of llvm-config we're using, so we'll # tweak the cross file or generate a native file to do so. -- 2.7.4