[dpdk-dev] [PATCH v2 11/11] devtools: compile all buildable examples with pkg-config

David Marchand david.marchand at redhat.com
Fri Nov 13 13:24:30 CET 2020


Rather than just installing all examples, we can use the build checks to
filter out any examples that are missing dependencies or are otherwise
unbuildable on the current system.
Introduce a new "buildable" special value for the -Dexamples= meson
option, this way existing behavior on installing all examples is
preserved.

Select only buildable examples and test their compilation for the
x86-default target.

Note for maintainers/users of the script: for existing environments,
the x86-default target might get broken by this patch since the script
now tries to build all "installed" examples and dependencies for some
might be unfulfilled.
To fix this temporary situation, you can either delete the whole
directory or reconfigure it:
$ meson configure $DPDK_BUILD_TEST_DIR/build-x86-default \
  -Dexamples=buildable

Suggested-by: Bruce Richardson <bruce.richardson at intel.com>
Signed-off-by: David Marchand <david.marchand at redhat.com>
---
Changelog since v1:
- rebased on main,
- introduced a new "buildable" special value for the -Dexamples option,
- installation of the "multi-level" examples has been fixed, so
  corresponding exceptions have been removed,
- a fix for the vhost is waiting in next-virtio, I assume it will get
  pulled before this series,
- the only remaining exception is for vm_power_manager which is broken,

---
 devtools/test-meson-builds.sh | 11 +++++++++--
 examples/meson.build          | 24 ++++++++++++++++++++++--
 meson.build                   |  2 ++
 3 files changed, 33 insertions(+), 4 deletions(-)

diff --git a/devtools/test-meson-builds.sh b/devtools/test-meson-builds.sh
index 3ce49368cf..a04f3eb7ff 100755
--- a/devtools/test-meson-builds.sh
+++ b/devtools/test-meson-builds.sh
@@ -213,7 +213,8 @@ default_machine='nehalem'
 if ! check_cc_flags "-march=$default_machine" ; then
 	default_machine='corei7'
 fi
-build build-x86-default cc -Dlibdir=lib -Dmachine=$default_machine $use_shared
+build build-x86-default cc -Dlibdir=lib -Dmachine=$default_machine \
+	-Dexamples=buildable $use_shared
 
 # 32-bit with default compiler
 if check_cc_flags '-m32' ; then
@@ -266,10 +267,16 @@ pc_file=$(find $DESTDIR -name libdpdk.pc)
 export PKG_CONFIG_PATH=$(dirname $pc_file):$PKG_CONFIG_PATH
 libdir=$(dirname $(find $DESTDIR -name librte_eal.so))
 export LD_LIBRARY_PATH=$libdir:$LD_LIBRARY_PATH
-examples=${DPDK_BUILD_TEST_EXAMPLES:-"cmdline helloworld l2fwd l3fwd skeleton timer"}
 # if pkg-config defines the necessary flags, test building some examples
 if pkg-config --define-prefix libdpdk >/dev/null 2>&1; then
 	export PKGCONF="pkg-config --define-prefix"
+	examples=${DPDK_BUILD_TEST_EXAMPLES:-}
+	if [ -z "$examples" ]; then
+		for mk in $DESTDIR/usr/local/share/dpdk/examples/*/Makefile; do
+			name=$(basename $(dirname $mk))
+			examples="$examples $name"
+		done
+	fi
 	for example in $examples; do
 		echo "## Building $example"
 		$MAKE -C $DESTDIR/usr/local/share/dpdk/examples/$example \
diff --git a/examples/meson.build b/examples/meson.build
index 46ec80919e..a23ab79e8c 100644
--- a/examples/meson.build
+++ b/examples/meson.build
@@ -55,9 +55,18 @@ endif
 if get_option('examples').to_lower() == 'all'
 	examples = all_examples
 	allow_skips = true # don't flag an error if we can't build an app
+	install_buildable = false
+elif get_option('examples').to_lower() == 'buildable'
+	examples = all_examples
+	allow_skips = true
+	install_buildable = true # only install examples that can be built
+	# FIXME: vm_power_manager relies on an internal header and can't build
+	# outside dpdk tree.
+	dpdk_examples_exclude += ['vm_power_manager']
 else
 	examples = get_option('examples').split(',')
 	allow_skips = false # error out if we can't build a requested app
+	install_buildable = false
 endif
 default_cflags = machine_args
 if cc.has_argument('-Wno-format-truncation')
@@ -81,10 +90,15 @@ foreach example: examples
 		foreach d:deps
 			var_name = get_option('default_library') + '_rte_' + d
 			if not is_variable(var_name)
-				error('Missing dependency "@0@" for example "@1@"'.format(d, name))
+				message('Missing dependency "@0@" for example "@1@"'.format(d, name))
+				build = false
+			else
+				dep_objs += [get_variable(var_name)]
 			endif
-			dep_objs += [get_variable(var_name)]
 		endforeach
+	endif
+
+	if build
 		if allow_experimental_apis
 			cflags += '-DALLOW_EXPERIMENTAL_API'
 		endif
@@ -98,5 +112,11 @@ foreach example: examples
 		error('Cannot build requested example "' + name + '"')
 	else
 		message('Skipping example "' + name + '"')
+		if install_buildable
+			# exclude based on top-level directory only
+			dir = example.split('/')[0]
+			dpdk_examples_exclude += dir
+			message('Excluding example directory "@0@" from install'.format(dir))
+		endif
 	endif
 endforeach
diff --git a/meson.build b/meson.build
index 45d974cd2c..559a9d2f1b 100644
--- a/meson.build
+++ b/meson.build
@@ -58,9 +58,11 @@ subdir('doc')
 
 # build any examples explicitly requested - useful for developers - and
 # install any example code into the appropriate install path
+dpdk_examples_exclude = []
 subdir('examples')
 install_subdir('examples',
 	install_dir: get_option('datadir') + '/dpdk',
+	exclude_directories: dpdk_examples_exclude,
 	exclude_files: 'meson.build')
 
 # build kernel modules if enabled
-- 
2.23.0



More information about the dev mailing list