Subject: Re: [PATCH net-next 3/4] ynl: regenerate all headers

From: Jakub Kicinski <[email-masked]>
Date: Wed, 26 Jul 2023 17:22:47 -0700

On Wed, 26 Jul 2023 16:55:07 -0700 Stanislav Fomichev wrote:
> Oh, didn't know about this. Something like this maybe? Ugly?
> 
> diff --git a/tools/net/ynl/Makefile b/tools/net/ynl/Makefile
> index d664b36deb5b..c36380bf1536 100644
> --- a/tools/net/ynl/Makefile
> +++ b/tools/net/ynl/Makefile
> @@ -3,6 +3,7 @@
>  SUBDIRS = lib generated samples
> 
>  all: $(SUBDIRS)
> +       (cd ../../../ && ./tools/net/ynl/ynl-regen.sh -f)

Hm, I thought the script itself would handle this. I guess I did a
stupid. How about we extend the script to default to the full tree:

diff --git a/tools/net/ynl/ynl-regen.sh b/tools/net/ynl/ynl-regen.sh
index 8d4ca6a50582..bdba24066cf1 100755
--- a/tools/net/ynl/ynl-regen.sh
+++ b/tools/net/ynl/ynl-regen.sh
@@ -4,15 +4,18 @@
 TOOL=$(dirname $(realpath $0))/ynl-gen-c.py
 
 force=
+search=
 
 while [ ! -z "$1" ]; do
   case "$1" in
     -f ) force=yes; shift ;;
+    -p ) search=$2; shift 2 ;;
     * )  echo "Unrecognized option '$1'"; exit 1 ;;
   esac
 done
 
 KDIR=$(dirname $(dirname $(dirname $(dirname $(realpath $0)))))
+pushd ${search:-$KDIR} >>/dev/null
 
 files=$(git grep --files-with-matches '^/\* YNL-GEN \(kernel\|uapi\|user\)')
 for f in $files; do
@@ -30,3 +33,5 @@ for f in $files; do
     $TOOL --mode ${params[2]} --${params[3]} --spec $KDIR/${params[0]} \
 	  $args -o $f
 done
+
+popd >>/dev/null

>  $(SUBDIRS):
>         @if [ -f "$@/Makefile" ] ; then \
> 
> Or, now that I know about the script I can actually run it manually.
> But with a makefile imo a bit easier to discover..

Yea, agreed.