Krolyxon
Commit aa56aa2

Branches

Refs →

nsxivaa56aa2

[ci]: try building all combination with tcc (#338)

this will hopefully catch issues like [337] in the future.

not using gcc and/or clang since we have 5 build options right now,
which means 2^5 = 32 different combination. using gcc/clang would take
too much resources and time; meanwhile tcc is lightning fast.

[337]: https://codeberg.org/nsxiv/nsxiv/pulls/337
Author
NRK
Date
2022-10-07 15:37 +0200
Parent
85fffbb
Commit
aa56aa23030e9f8680d5ef366f2bd72fd342c14f

+49 −7

3 files changed

  1. M .github/workflows/build.yml +6 −4
  2. M etc/woodpecker/build.yml +5 −3
  3. A etc/woodpecker/try-all-builds.sh +38 −0
M .github/workflows/build.yml View
@@ -15,20 +15,22 @@ jobs:
1515 sudo apt-get update
1616 sudo apt-get install libimlib2 libimlib2-dev xserver-xorg-core xserver-xorg-dev \
1717 libxft2 libxft-dev libexif12 libexif-dev \
18− gcc clang git
18+ gcc clang git bc
1919 TCC_SHA="027b8fb9b88fe137447fb8bb1b61079be9702472"
2020 wget "https://github.com/TinyCC/tinycc/archive/${TCC_SHA}.tar.gz" && tar xzf "${TCC_SHA}.tar.gz"
21− ( cd "tinycc-$TCC_SHA" && ./configure && make && sudo make install; )
21+ ( cd "tinycc-$TCC_SHA" && ./configure && make -j"$(nproc)" && sudo make install; )
2222 - name: build
2323 run: |
2424 CFLAGS="$(sed '/^#/d' etc/woodpecker/CFLAGS | paste -d ' ' -s)"
2525 build () {
26− for cc in "gcc" "clang" "tcc"; do
26+ for cc in "gcc" "clang"; do
2727 echo "### $cc - $2 build ###"
2828 make clean && make -s -j"$(nproc)" CC="$cc" CFLAGS="$CFLAGS" LDFLAGS="$CFLAGS" OPT_DEP_DEFAULT="$1"
2929 done
3030 }
31− # full-build #
31+ # try all combination with tcc #
32+ etc/woodpecker/try-all-builds.sh
33+ # full-build with gcc and clang #
3234 build "1" "full"
3335 # ensure minimal-build works without opt deps installed
3436 sudo apt-get remove libxft2 libxft-dev libexif12 libexif-dev >/dev/null
M etc/woodpecker/build.yml View
@@ -10,18 +10,20 @@ pipeline:
1010 apk add --no-cache \
1111 imlib2 imlib2-dev xorgproto \
1212 libxft libxft-dev libexif libexif-dev giflib giflib-dev libwebp libwebp-dev \
13− gcc clang llvm llvm-dev build-base wget ca-certificates >/dev/null
13+ gcc clang llvm llvm-dev build-base wget ca-certificates bc >/dev/null
1414 wget "https://github.com/TinyCC/tinycc/archive/$TCC_SHA.tar.gz" >/dev/null
1515 tar xzf "$TCC_SHA.tar.gz" >/dev/null
1616 ( cd "tinycc-$TCC_SHA" && ./configure --config-musl && make -s -j"$(nproc)" && make install; ) >/dev/null
1717 CFLAGS="$(sed '/^#/d' etc/woodpecker/CFLAGS | paste -d ' ' -s)"
1818 build () {
19− for cc in "gcc" "clang" "tcc"; do
19+ for cc in "gcc" "clang"; do
2020 echo "### $cc - $2 build ###"
2121 make clean && make -s -j"$(nproc)" CC="$cc" CFLAGS="$CFLAGS" LDFLAGS="$CFLAGS" OPT_DEP_DEFAULT="$1"
2222 done
2323 }
24− # full-build #
24+ # try all combination with tcc #
25+ etc/woodpecker/try-all-builds.sh
26+ # full-build with gcc and clang #
2527 build "1" "full"
2628 # ensure minimal-build works without opt deps installed
2729 apk del libxft libxft-dev libexif libexif-dev giflib giflib-dev libwebp libwebp-dev >/dev/null
A etc/woodpecker/try-all-builds.sh View
@@ -0,0 +1,38 @@
1+#!/bin/sh
2+#
3+# Shell script that checks for all possible build combination with TCC.
4+# Usage: call the script while in the nsxiv root directory
5+
6+set -- $(grep -o '^HAVE_[[:alpha:]]* ' config.mk)
7+CFLAGS="$(sed '/^#/d' etc/woodpecker/CFLAGS | paste -d ' ' -s)"
8+z=$(echo "2 ^ $#" | bc)
9+
10+print_opt_name() {
11+ shift "$(( $1 + 1 ))"
12+ printf "%s=" "$1"
13+}
14+
15+print_opt_arg() {
16+ bn=$(echo "$1 / (2 ^ $2)" | bc)
17+ printf "%d " $(( bn % 2 ))
18+}
19+
20+n=0
21+while [ "$n" -lt "$z" ]; do
22+ i=0
23+ while [ "$i" -lt "$#" ]; do
24+ print_opt_name "$i" "$@"
25+ print_opt_arg "$n" "$i"
26+ i=$((i + 1))
27+ done | tee "/dev/stderr" | (
28+ make clean
29+ if ! xargs make -j"$(nproc)" CC=tcc CFLAGS="$CFLAGS" LDFLAGS="$CFLAGS"; then
30+ echo "[FAILED]" >&2
31+ exit 1
32+ else
33+ echo "[SUCCESS]" >&2
34+ fi
35+ )
36+ [ "$?" -ne 0 ] && exit "$?"
37+ n=$((n + 1))
38+done >/dev/null