Skip to contentSkip to conversation

tools: ynl-gen: add "spec" arg to regen allowing to use only selected spec

PATCH In review Jiri Pirko 2 participants 3 messages Aug 22, 2023

Subsystems (3)
lore
Share & tools
lore

Jiri Pirko

author
#0 lore raw

PATCH 1/1 tools: ynl-gen: add "spec" arg to regen allowing to use only selected spec

From: Jiri Pirko <[email protected]>

ynl-regen git greps and re-generates all generated files. Introduce a command line argument "spec" allowing the user to specify only one yaml spec file to use as a source of re-generation.

Example:

$ tools/net/ynl/ynl-regen.sh -s Documentation/netlink/specs/devlink.yaml -f
	GEN kernel	net/devlink/netlink_gen.c
	GEN kernel	net/devlink/netlink_gen.h
	GEN user	tools/net/ynl/generated/devlink-user.c
	GEN user	tools/net/ynl/generated/devlink-user.h

This is handy while working on a specific spec.

---
 tools/net/ynl/ynl-regen.sh | 6 ++++++
 1 file changed, 6 insertions(+)
tools/net/ynl/ynl-regen.sh +6 -0
index bdba24066cf1..ee77f6fcad60 100755
@@ -5,11 +5,13 @@ TOOL=$(dirname $(realpath $0))/ynl-gen-c.py
 
 force=
 search=
+spec=
 
 while [ ! -z "$1" ]; do
   case "$1" in
     -f ) force=yes; shift ;;
     -p ) search=$2; shift 2 ;;
+    -s ) spec=$2; shift 2 ;;
     * )  echo "Unrecognized option '$1'"; exit 1 ;;
   esac
 done
@@ -24,6 +26,10 @@ for f in $files; do
     params=( $(git grep -B1 -h '/\* YNL-GEN' $f | sed 's@/\*\(.*\)\*/@\1@') )
     args=$(sed -n 's@/\* YNL-ARG \(.*\) \*/@\1@p' $f)
 
+    if [ ! -z "$spec" -a "$spec" != "${params[0]}" ]; then
+	continue
+    fi
+
     if [ $f -nt ${params[0]} -a -z "$force" ]; then
 	echo -e "\tSKIP $f"
 	continue
Signature · 1 line
2.41.0
maintainer
#1 lore raw
Quoted 1 line · On Tue, 22 Aug 2023 13:50:00 +0200 Jiri Pirko wrote:
$ tools/net/ynl/ynl-regen.sh -s Documentation/netlink/specs/devlink.yaml -f

touch Documentation/netlink/specs/devlink.yaml && ./tools/net/ynl/ynl-regen.sh

?

author
#2 lore raw
Quoted 4 lines · Tue, Aug 22, 2023 at 07:09:40PM CEST, [email protected] wrote:
Quoted 1 line · On Tue, 22 Aug 2023 13:50:00 +0200 Jiri Pirko wrote:
$ tools/net/ynl/ynl-regen.sh -s Documentation/netlink/specs/devlink.yaml -f

touch Documentation/netlink/specs/devlink.yaml && ./tools/net/ynl/ynl-regen.sh

Ah, leveraging the skip. Okay, makes sense.

Quoted 2 lines

?