[v2,3/4] devtools: build all examples externally

Message ID 20230613140635.975187-4-david.marchand@redhat.com (mailing list archive)
State Superseded, archived
Delegated to: Thomas Monjalon
Headers
Series Test examples compilation externally |

Checks

Context Check Description
ci/checkpatch success coding style OK

Commit Message

David Marchand June 13, 2023, 2:06 p.m. UTC
  So far, users of test-meson-builds.sh had to define their own set of
examples to build externally. This is not that great because users need
to maintain this list when examples are removed/added.

Rework the script so that the 'all' value triggers an automatic
discovery based on what was configured/compiled with meson/ninja.

Signed-off-by: David Marchand <david.marchand@redhat.com>
Acked-by: Bruce Richardson <bruce.richardson@intel.com>
---
Changes since v1:
- reworked built examples discovery,
- added comment for people who are not sed fluent,

---
 devtools/test-meson-builds.sh | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)
  

Comments

Thomas Monjalon June 20, 2023, 9:45 a.m. UTC | #1
13/06/2023 16:06, David Marchand:
> +		sed -ne "s,$srcdir/examples/\([^/]*\)\(/.*\|\)/$target/Makefile,\1,p"

I think -e is not needed.
If you use -r, you can avoid backslashing the parentheses.
  
David Marchand June 20, 2023, 9:52 a.m. UTC | #2
On Tue, Jun 20, 2023 at 11:45 AM Thomas Monjalon <thomas@monjalon.net> wrote:
>
> 13/06/2023 16:06, David Marchand:
> > +             sed -ne "s,$srcdir/examples/\([^/]*\)\(/.*\|\)/$target/Makefile,\1,p"
>
> I think -e is not needed.

Indeed.

> If you use -r, you can avoid backslashing the parentheses.

-r is not a posix option.
  

Patch

diff --git a/devtools/test-meson-builds.sh b/devtools/test-meson-builds.sh
index 9131088c9d..05bc15e280 100755
--- a/devtools/test-meson-builds.sh
+++ b/devtools/test-meson-builds.sh
@@ -299,6 +299,22 @@  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 [ "$examples" = 'all' ]; then
+	examples=$(find $build_path/examples -maxdepth 1 -type f -name "dpdk-*" |
+	while read target; do
+		target=${target%%:*}
+		target=${target#$build_path/examples/dpdk-}
+		if [ -e $srcdir/examples/$target/Makefile ]; then
+			echo $target
+			continue
+		fi
+		# Some examples binaries are built from an example sub
+		# directory, discover the "top level" example name.
+		find $srcdir/examples -name Makefile |
+		sed -ne "s,$srcdir/examples/\([^/]*\)\(/.*\|\)/$target/Makefile,\1,p"
+	done | sort -u |
+	tr '\n' ' ')
+fi
 # 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"