summaryrefslogtreecommitdiff
path: root/10-build-matrix.sh
diff options
context:
space:
mode:
authorKieran Bingham <kieran.bingham@ideasonboard.com>2021-06-28 16:15:49 +0100
committerKieran Bingham <kieran.bingham@ideasonboard.com>2021-07-07 11:02:50 +0100
commit5eed21511f8aca1e74c6622569e61d32a128cb4f (patch)
tree46ca2258a8bed9c3ca1c852fd187980ffa1795ea /10-build-matrix.sh
parent59d85c19fd063e5a24fcf09894730bcf6ebaedc4 (diff)
ci: Introduce the matrix build
Provide a matrix builder for all compilers detected on this system. Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Diffstat (limited to '10-build-matrix.sh')
-rwxr-xr-x10-build-matrix.sh156
1 files changed, 156 insertions, 0 deletions
diff --git a/10-build-matrix.sh b/10-build-matrix.sh
new file mode 100755
index 0000000..6aebd7a
--- /dev/null
+++ b/10-build-matrix.sh
@@ -0,0 +1,156 @@
+#!/bin/bash
+
+# SPDX-License-Identifier: GPL-2.0-or-later
+#
+# Compile test builder.
+#
+# Call a meson/ninja build with all combinations of gcc/clang identifyied in
+# the path using compgen. Builds are left in tree, allowing incremental builds
+# on each call.
+
+
+source ./common.sh
+
+LIBCAMERA=${1:-$(pwd)/libcamera}
+ID=build-matrix
+
+check_version $LIBCAMERA $ID
+
+echo "Build-matrix for libcamera at version : " $(libcamera_version "$LIBCAMERA")
+
+## Identify supported compilers
+
+# CLANG uses clang and clang++
+function find_clang_compilers() {
+ compgen -c clang | grep -E "^clang[++]*-[0-9]+"
+}
+
+# GCC uses g++ and gcc
+function find_gcc_compilers() {
+ compgen -c gcc | grep -E "^gcc-[0-9]+"
+ compgen -c g++ | grep -E "^g\+\+-[0-9]+"
+}
+
+gccs=$(find_gcc_compilers)
+clangs=$(find_clang_compilers)
+
+# Given a list of xxx-[0-9]+ return a list of
+# [0-9]+ where two occurences appear in the list.
+function filter_version_pairs() {
+ for v in "$@";
+ do echo "$v" | sed 's/.*-//';
+ done | sort -n | uniq -d;
+}
+
+configurations=()
+
+# Generate a list of compiler configurations where both the C and C++ compiler
+# have been identified
+for v in $(filter_version_pairs $gccs); do
+ configurations+="gcc-$v:g++-$v "
+done;
+
+for v in $(filter_version_pairs $clangs); do
+ configurations+="clang-$v:clang++-$v "
+done;
+
+#### Building and compiling
+
+function build() {
+ echo "Building for $1"
+
+ BUILDDIR="$(builddir $ID)/$1"
+ CC="$1"
+ CXX="$2"
+
+ echo "Checking for libcamera builddir: $BUILDDIR"
+
+ if [ ! -d "$BUILDDIR" ]; then
+ CC=$CC \
+ CXX=$CXX \
+ meson "$BUILDDIR" "$LIBCAMERA" \
+ -Dv4l2=true \
+ -Dandroid=enabled \
+ -Ddocumentation=disabled \
+ -Dgstreamer=enabled
+ fi
+
+ ninja -C "$BUILDDIR"
+}
+
+function build_simple_cam() {
+ LIBCAMERA_BUILD="$(builddir $ID)/$1"
+ LIBCAMERA_BUILD=$(realpath -L $LIBCAMERA_BUILD/meson-uninstalled/)
+
+ CC="$1"
+ CXX="$2"
+
+ SIMPLE_CAM=./simple-cam
+
+ if [ ! -d $SIMPLE_CAM ]; then
+ git clone https://git.libcamera.org/libcamera/simple-cam.git
+ fi
+
+ echo Using: $LIBCAMERA_BUILD
+
+ cd $SIMPLE_CAM
+ git pull --ff-only
+
+ BUILDDIR="$(builddir $ID)/$1-simple-cam"
+
+ # Always build simple-cam from clean
+ rm -fr "$BUILDDIR"
+
+ PKG_CONFIG_PATH=$LIBCAMERA_BUILD \
+ CC=$CC \
+ CXX=$CXX \
+ meson "$BUILDDIR"
+
+ ninja -C "$BUILDDIR"
+ ret=$?
+
+ cd ..
+
+ return $ret
+}
+
+mkdir -p $(builddir $ID)
+
+echo "Identified toolchain configurations:"
+
+for conf in ${configurations}
+do
+ # Split gcc-7:g++-7 to gcc-7 g++-7
+ parsed=(${conf//:/ })
+
+ echo " Configuration: $conf"
+done
+echo
+
+echo "Commencing builds:"
+
+for conf in ${configurations}
+do
+ # Split gcc-7:g++-7 to gcc-7 g++-7
+ parsed=(${conf//:/ })
+
+ toolchain=${parsed[0]}
+ logfile=$(log_filename $ID-$toolchain)
+
+ echo "Configuration: $conf ($logfile)"
+
+ build ${parsed[@]} > $logfile
+ pass_fail $? "libcamera $toolchain:"
+
+ build_simple_cam ${parsed[@]} >> $logfile
+ #pass_fail $? "simple-cam $toolchain:"
+
+done
+
+# Summarise build results
+BUILDDIR="$(builddir $ID)/$1"
+
+(cd $(builddir $ID) && ls -alh -sv */src/libcamera/libcamera.so)
+
+completed $ID
+