#!/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:-$(srcdir libcamera)} # Override the default build ID 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 \ -Dpipelines=all \ -Dandroid=enabled \ -Ddocumentation=disabled \ -Dgstreamer=enabled \ -Dlc-compliance=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=$(srcdir simple-cam) if [ ! -d $SIMPLE_CAM ]; then git clone https://git.libcamera.org/libcamera/simple-cam.git $SIMPLE_CAM 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