[dpdk-dev,v5] devtools: add test script for meson builds

Message ID 20180529144243.9619-1-thomas@monjalon.net (mailing list archive)
State Accepted, archived
Headers

Checks

Context Check Description
ci/checkpatch warning coding style issues
ci/Intel-compilation success Compilation OK

Commit Message

Thomas Monjalon May 29, 2018, 2:42 p.m. UTC
  From: Bruce Richardson <bruce.richardson@intel.com>

To simplify testing with the meson and ninja builds, we can add a script
to set up and do multiple builds. Currently this script sets up:

* clang and gcc builds
* builds using static and shared linkage for binaries (libs are always
   built as both)
* a build using the lowest instruction-set level for x86 (-march=nehalem)
* cross-builds for each cross-file listed in config/arm

Each build is configured in a directory ending in *-build, and then for
the build stage, we just call ninja in each directory in turn. [i.e. we
assume every directory starting with "build-" is a meson build, which is
probably an ok assumption].

Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
Signed-off-by: Thomas Monjalon <thomas@monjalon.net>
---
v2: it is a rework with 3 major changes
   - automatically stop on error thanks to -e
   - directory name starts with "build-"
   - optionally load a config file to get some environment variables
v3:
   - remove forcing "cd": use current directory
   - remove CROSS: use hard-written aarch64-linux-gnu-gcc
   - remove config load in script start
v4:
   - remove config file loading (will be improved and sent later)
   - the v4 is closer to what Bruce sent as v1
v5:
   - specify srcdir to build from anywhere
   - use ccache for ARM
---
 MAINTAINERS                   |  1 +
 devtools/test-meson-builds.sh | 46 +++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 47 insertions(+)
 create mode 100755 devtools/test-meson-builds.sh
  

Comments

Bruce Richardson May 29, 2018, 2:58 p.m. UTC | #1
> -----Original Message-----
> From: Thomas Monjalon [mailto:thomas@monjalon.net]
> Sent: Tuesday, May 29, 2018 3:43 PM
> To: dev@dpdk.org
> Cc: Richardson, Bruce <bruce.richardson@intel.com>
> Subject: [PATCH v5] devtools: add test script for meson builds
> 
> From: Bruce Richardson <bruce.richardson@intel.com>
> 
> To simplify testing with the meson and ninja builds, we can add a script
> to set up and do multiple builds. Currently this script sets up:
> 
> * clang and gcc builds
> * builds using static and shared linkage for binaries (libs are always
>    built as both)
> * a build using the lowest instruction-set level for x86 (-march=nehalem)
> * cross-builds for each cross-file listed in config/arm
> 
> Each build is configured in a directory ending in *-build, and then for
> the build stage, we just call ninja in each directory in turn. [i.e. we
> assume every directory starting with "build-" is a meson build, which is
> probably an ok assumption].
> 
> Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
> Signed-off-by: Thomas Monjalon <thomas@monjalon.net>
> ---
> v2: it is a rework with 3 major changes
>    - automatically stop on error thanks to -e
>    - directory name starts with "build-"
>    - optionally load a config file to get some environment variables
> v3:
>    - remove forcing "cd": use current directory
>    - remove CROSS: use hard-written aarch64-linux-gnu-gcc
>    - remove config load in script start
> v4:
>    - remove config file loading (will be improved and sent later)
>    - the v4 is closer to what Bruce sent as v1
> v5:
>    - specify srcdir to build from anywhere
>    - use ccache for ARM
> ---
>  MAINTAINERS                   |  1 +
>  devtools/test-meson-builds.sh | 46
> +++++++++++++++++++++++++++++++++++++++++++
>  2 files changed, 47 insertions(+)
>  create mode 100755 devtools/test-meson-builds.sh

LGTM
  
Thomas Monjalon May 29, 2018, 3:37 p.m. UTC | #2
29/05/2018 16:58, Richardson, Bruce:
> 
> > -----Original Message-----
> > From: Thomas Monjalon [mailto:thomas@monjalon.net]
> > Sent: Tuesday, May 29, 2018 3:43 PM
> > To: dev@dpdk.org
> > Cc: Richardson, Bruce <bruce.richardson@intel.com>
> > Subject: [PATCH v5] devtools: add test script for meson builds
> > 
> > From: Bruce Richardson <bruce.richardson@intel.com>
> > 
> > To simplify testing with the meson and ninja builds, we can add a script
> > to set up and do multiple builds. Currently this script sets up:
> > 
> > * clang and gcc builds
> > * builds using static and shared linkage for binaries (libs are always
> >    built as both)
> > * a build using the lowest instruction-set level for x86 (-march=nehalem)
> > * cross-builds for each cross-file listed in config/arm
> > 
> > Each build is configured in a directory ending in *-build, and then for
> > the build stage, we just call ninja in each directory in turn. [i.e. we
> > assume every directory starting with "build-" is a meson build, which is
> > probably an ok assumption].
> > 
> > Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
> > Signed-off-by: Thomas Monjalon <thomas@monjalon.net>
> > ---
> > v2: it is a rework with 3 major changes
> >    - automatically stop on error thanks to -e
> >    - directory name starts with "build-"
> >    - optionally load a config file to get some environment variables
> > v3:
> >    - remove forcing "cd": use current directory
> >    - remove CROSS: use hard-written aarch64-linux-gnu-gcc
> >    - remove config load in script start
> > v4:
> >    - remove config file loading (will be improved and sent later)
> >    - the v4 is closer to what Bruce sent as v1
> > v5:
> >    - specify srcdir to build from anywhere
> >    - use ccache for ARM
> > ---
> >  MAINTAINERS                   |  1 +
> >  devtools/test-meson-builds.sh | 46
> > +++++++++++++++++++++++++++++++++++++++++++
> >  2 files changed, 47 insertions(+)
> >  create mode 100755 devtools/test-meson-builds.sh
> 
> LGTM

Applied, thanks
  

Patch

diff --git a/MAINTAINERS b/MAINTAINERS
index e56c72687..4d015fe53 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -86,6 +86,7 @@  F: devtools/get-maintainer.sh
 F: devtools/git-log-fixes.sh
 F: devtools/load-devel-config
 F: devtools/test-build.sh
+F: devtools/test-meson-builds.sh
 F: license/
 
 
diff --git a/devtools/test-meson-builds.sh b/devtools/test-meson-builds.sh
new file mode 100755
index 000000000..9868c325b
--- /dev/null
+++ b/devtools/test-meson-builds.sh
@@ -0,0 +1,46 @@ 
+#! /bin/sh -e
+# SPDX-License-Identifier: BSD-3-Clause
+# Copyright(c) 2018 Intel Corporation
+
+# Run meson to auto-configure the various builds.
+# * all builds get put in a directory whose name starts with "build-"
+# * if a build-directory already exists we assume it was properly configured
+# Run ninja after configuration is done.
+
+srcdir=$(dirname $(readlink -m $0))/..
+MESON=${MESON:-meson}
+
+build () # <directory> <meson options>
+{
+	builddir=$1
+	shift
+	if [ ! -d "$builddir" ] ; then
+		options="--werror -Dexamples=all $*"
+		echo "$MESON $options $srcdir $builddir"
+		$MESON $options $srcdir $builddir
+		unset CC
+	fi
+	echo "ninja -C $builddir"
+	ninja -C $builddir
+}
+
+# shared and static linked builds with gcc and clang
+for c in gcc clang ; do
+	for s in static shared ; do
+		export CC="ccache $c"
+		build build-$c-$s --default-library=$s
+	done
+done
+
+# test compilation with minimal x86 instruction set
+build build-x86-default -Dmachine=nehalem
+
+# enable cross compilation if gcc cross-compiler is found
+for f in config/arm/arm*gcc ; do
+	c=aarch64-linux-gnu-gcc
+	if ! command -v $c >/dev/null 2>&1 ; then
+		continue
+	fi
+	export CC="ccache $c"
+	build build-$(basename $f | tr '_' '-' | cut -d'-' -f-2) --cross-file $f
+done