[PATCH 2/3] maint: add script to generate decoders from definitions

Dmitry V. Levin ldv at altlinux.org
Mon Aug 30 10:18:05 UTC 2021


On Sat, Aug 21, 2021 at 09:51:58AM -0400, Srikavin Ramkumar wrote:
> * maint/gen/generate.in: New file.
> * maint/gen/generate.sh: Likewise.
> ---
> 
>  This works, but I'm not sure if this is the best place to place generated
>  source files.
> 
>  maint/gen/generate.in |  1 +
>  maint/gen/generate.sh | 10 ++++++++++
>  2 files changed, 11 insertions(+)
>  create mode 100644 maint/gen/generate.in
>  create mode 100755 maint/gen/generate.sh
> 
> diff --git a/maint/gen/generate.in b/maint/gen/generate.in
> new file mode 100644
> index 000000000..24700ed74
> --- /dev/null
> +++ b/maint/gen/generate.in
> @@ -0,0 +1 @@
> +defs/hdio.def	hdio.c
> diff --git a/maint/gen/generate.sh b/maint/gen/generate.sh
> new file mode 100755
> index 000000000..1325b26b7
> --- /dev/null
> +++ b/maint/gen/generate.sh
> @@ -0,0 +1,10 @@
> +#!/bin/sh -euf
> +
> +make
> +
> +mkdir -p ../../src/gen
> +
> +while IFS="$(printf '\t')" read in out; do
> +	echo "generating ../../src/gen/gen_$out"
> +	./gen "$in" "../../src/gen/gen_$out"
> +done < generate.in

Thanks, this definitely works, just a few comments.

Let's have a make target instead of invoking "make" in the script,
maybe even make it the default target.

../../src/gen is used several times in the script,
maybe introduce a variable?

I don't see why you use IFS= here, is it really needed?
At the same time, in other scripts of this nature we use "read -r",
maybe it should be used here as well.

In other scripts similar "generating diagnostics" is printed to stderr,
maybe this script should do the same.


-- 
ldv


More information about the Strace-devel mailing list