Add a warning header to the generated help-*.h files.

This commit is contained in:
Wayne Davison
2020-06-14 18:49:38 -07:00
parent 660274bfb7
commit 775f64f4b8
2 changed files with 34 additions and 8 deletions

View File

@@ -104,14 +104,7 @@ options.o: latest-year.h help-rsync.h help-rsyncd.h
flist.o: rounding.h
help-rsync.h help-rsyncd.h: rsync.1.md
@sed -e '1,/^\[comment\].*$@/d' \
-e '1,/^```/d' \
-e '/^```/,$$d' \
-e 's/"/\\"/g' \
-e 's/^/ rprintf(F,"/' \
-e 's/$$/\\n");/' \
<"$(srcdir)/$<" >$@
@if ! test -s $@; then rm -f $@ ; echo "The Makefile generated an empty file: $@" ; exit 1 ; fi
./help-from-md "$(srcdir)/$<" $@
rounding.h: rounding.c rsync.h proto.h
@for r in 0 1 3; do \

33
help-from-md Executable file
View File

@@ -0,0 +1,33 @@
#!/bin/bash
if [[ "$#" != 2 ]]; then
echo "Usage: $0 MD_FILE HELP_FILE.h"
exit 1
fi
mdfile="$1"
helpfile="$2"
newfile="$helpfile.new"
findfile="${helpfile/./\\.}"
sed -e '1,/^\[comment\].*'"$findfile"'/d' \
-e '1,/^```/d' \
-e '/^```/,$d' \
-e 's/"/\\"/g' \
-e 's/^/ rprintf(F,"/' \
-e 's/$/\\n");/' \
<"$mdfile" >"$newfile"
if [[ ! -s "$newfile" ]]; then
rm "$newfile"
echo "Discarding empty output for $helpfile file from $mdfile"
exit 1
fi
(cat <<EOT
/* DO NOT EDIT THIS FILE! It is auto-generated from the option list in $mdfile! */
EOT
cat "$newfile"
) >"$helpfile"
rm "$newfile"