+ if [ -f "$builddir/build.ninja" ] ; then
+ # for existing environments, switch to debugoptimized if unset
+ # so that ABI checks can run
+ if ! $MESON configure $builddir |
+ awk '$1=="buildtype" {print $2}' |
+ grep -qw debugoptimized; then
+ $MESON configure --buildtype=debugoptimized $builddir
+ fi
+ return
+ fi
+ options=
+ options="$options --werror -Dexamples=all"
+ options="$options --buildtype=debugoptimized"
+ for option in $DPDK_MESON_OPTIONS ; do
+ options="$options -D$option"
+ done
+ options="$options $*"
+ echo "$MESON $options $dir $builddir"
+ $MESON $options $dir $builddir
+}
+
+compile () # <builddir>
+{
+ builddir=$1
+ if [ -n "$TEST_MESON_BUILD_VERY_VERBOSE" ] ; then
+ # for full output from ninja use "-v"
+ echo "$ninja_cmd -v -C $builddir"
+ $ninja_cmd -v -C $builddir
+ elif [ -n "$TEST_MESON_BUILD_VERBOSE" ] ; then
+ # for keeping the history of short cmds, pipe through cat
+ echo "$ninja_cmd -C $builddir | cat"
+ $ninja_cmd -C $builddir | cat
+ else
+ echo "$ninja_cmd -C $builddir"
+ $ninja_cmd -C $builddir
+ fi
+}
+
+install_target () # <builddir> <installdir>
+{
+ rm -rf $2
+ if [ -n "$TEST_MESON_BUILD_VERY_VERBOSE$TEST_MESON_BUILD_VERBOSE" ]; then
+ echo "DESTDIR=$2 $ninja_cmd -C $1 install"
+ DESTDIR=$2 $ninja_cmd -C $1 install
+ else
+ echo "DESTDIR=$2 $ninja_cmd -C $1 install >/dev/null"
+ DESTDIR=$2 $ninja_cmd -C $1 install >/dev/null
+ fi
+}
+
+build () # <directory> <target compiler> <meson options>
+{
+ targetdir=$1
+ shift
+ targetcc=$1
+ shift
+ # skip build if compiler not available
+ command -v ${CC##* } >/dev/null 2>&1 || return 0
+ load_env $targetcc || return 0
+ config $srcdir $builds_dir/$targetdir $*
+ compile $builds_dir/$targetdir
+ if [ -n "$DPDK_ABI_REF_VERSION" ]; then
+ abirefdir=${DPDK_ABI_REF_DIR:-reference}/$DPDK_ABI_REF_VERSION
+ if [ ! -d $abirefdir/$targetdir ]; then
+ # clone current sources
+ if [ ! -d $abirefdir/src ]; then
+ git clone --local --no-hardlinks \
+ --single-branch \
+ -b $DPDK_ABI_REF_VERSION \
+ $srcdir $abirefdir/src
+ fi
+
+ rm -rf $abirefdir/build
+ config $abirefdir/src $abirefdir/build $*
+ compile $abirefdir/build
+ install_target $abirefdir/build $abirefdir/$targetdir
+ $srcdir/devtools/gen-abi.sh $abirefdir/$targetdir
+ fi
+
+ install_target $builds_dir/$targetdir \
+ $(readlink -f $builds_dir/$targetdir/install)
+ $srcdir/devtools/gen-abi.sh \
+ $(readlink -f $builds_dir/$targetdir/install)
+ $srcdir/devtools/check-abi.sh $abirefdir/$targetdir \
+ $(readlink -f $builds_dir/$targetdir/install)