xref: /dpdk/devtools/test-meson-builds.sh (revision c0d02207)
1#! /bin/sh -e
2# SPDX-License-Identifier: BSD-3-Clause
3# Copyright(c) 2018 Intel Corporation
4
5# Run meson to auto-configure the various builds.
6# * all builds get put in a directory whose name starts with "build-"
7# * if a build-directory already exists we assume it was properly configured
8# Run ninja after configuration is done.
9
10srcdir=$(dirname $(readlink -m $0))/..
11MESON=${MESON:-meson}
12
13if command -v ninja >/dev/null 2>&1 ; then
14	ninja_cmd=ninja
15elif command -v ninja-build >/dev/null 2>&1 ; then
16	ninja_cmd=ninja-build
17else
18	echo "ERROR: ninja is not found" >&2
19	exit 1
20fi
21
22build () # <directory> <meson options>
23{
24	builddir=$1
25	shift
26	if [ ! -d "$builddir" ] ; then
27		options="--werror -Dexamples=all $*"
28		echo "$MESON $options $srcdir $builddir"
29		$MESON $options $srcdir $builddir
30		unset CC
31	fi
32	echo "$ninja_cmd -C $builddir"
33	$ninja_cmd -C $builddir
34}
35
36# shared and static linked builds with gcc and clang
37for c in gcc clang ; do
38	for s in static shared ; do
39		export CC="ccache $c"
40		build build-$c-$s --default-library=$s
41	done
42done
43
44# test compilation with minimal x86 instruction set
45build build-x86-default -Dmachine=nehalem
46
47# enable cross compilation if gcc cross-compiler is found
48for f in config/arm/arm*gcc ; do
49	c=aarch64-linux-gnu-gcc
50	if ! command -v $c >/dev/null 2>&1 ; then
51		continue
52	fi
53	build build-$(basename $f | tr '_' '-' | cut -d'-' -f-2) --cross-file $f
54done
55