xref: /dpdk/devtools/test-meson-builds.sh (revision 742bde12)
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 -f $0))/..
11MESON=${MESON:-meson}
12use_shared="--default-library=shared"
13
14if command -v ninja >/dev/null 2>&1 ; then
15	ninja_cmd=ninja
16elif command -v ninja-build >/dev/null 2>&1 ; then
17	ninja_cmd=ninja-build
18else
19	echo "ERROR: ninja is not found" >&2
20	exit 1
21fi
22
23build () # <directory> <meson options>
24{
25	builddir=$1
26	shift
27	if [ ! -f "$builddir/build.ninja" ] ; then
28		options="--werror -Dexamples=all $*"
29		echo "$MESON $options $srcdir $builddir"
30		$MESON $options $srcdir $builddir
31		unset CC
32	fi
33	if [ -n "$TEST_MESON_BUILD_VERY_VERBOSE" ] ; then
34		# for full output from ninja use "-v"
35		echo "$ninja_cmd -v -C $builddir"
36		$ninja_cmd -v -C $builddir
37	elif [ -n "$TEST_MESON_BUILD_VERBOSE" ] ; then
38		# for keeping the history of short cmds, pipe through cat
39		echo "$ninja_cmd -C $builddir | cat"
40		$ninja_cmd -C $builddir | cat
41	else
42		echo "$ninja_cmd -C $builddir"
43		$ninja_cmd -C $builddir
44	fi
45}
46
47if [ "$1" == "-vv" ] ; then
48	TEST_MESON_BUILD_VERY_VERBOSE=1
49elif [ "$1" == "-v" ] ; then
50	TEST_MESON_BUILD_VERBOSE=1
51fi
52
53# shared and static linked builds with gcc and clang
54for c in gcc clang ; do
55	for s in static shared ; do
56		export CC="ccache $c"
57		build build-$c-$s --default-library=$s
58	done
59done
60
61# test compilation with minimal x86 instruction set
62build build-x86-default -Dmachine=nehalem $use_shared
63
64# enable cross compilation if gcc cross-compiler is found
65c=aarch64-linux-gnu-gcc
66if command -v $c >/dev/null 2>&1 ; then
67	# compile the general v8a also for clang to increase coverage
68	export CC="ccache clang"
69	build build-arm64-host-clang $use_shared \
70		--cross-file config/arm/arm64_armv8_linuxapp_gcc
71
72	for f in config/arm/arm*gcc ; do
73		export CC="ccache gcc"
74		build build-$(basename $f | tr '_' '-' | cut -d'-' -f-2) \
75			$use_shared --cross-file $f
76	done
77fi
78