make it possible to keep usage texts in .c files
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
This commit is contained in:
parent
6c5bf0d347
commit
f0f9470061
@ -118,7 +118,7 @@ disp_doc = $($(quiet)cmd_doc)
|
||||
# sed adds newlines after "Options:" etc,
|
||||
# this is needed in order to get good BusyBox.{1,txt,html}
|
||||
docs/busybox.pod: $(srctree)/docs/busybox_header.pod \
|
||||
$(srctree)/include/usage.h \
|
||||
include/usage.h \
|
||||
$(srctree)/docs/busybox_footer.pod \
|
||||
applets/usage_pod
|
||||
$(disp_doc)
|
||||
|
@ -304,6 +304,17 @@ int gunzip_main(int argc UNUSED_PARAM, char **argv)
|
||||
*
|
||||
* Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
|
||||
*/
|
||||
//usage:#define bunzip2_trivial_usage
|
||||
//usage: "[OPTIONS] [FILE]..."
|
||||
//usage:#define bunzip2_full_usage "\n\n"
|
||||
//usage: "Decompress FILEs (or stdin)\n"
|
||||
//usage: "\nOptions:"
|
||||
//usage: "\n -c Write to stdout"
|
||||
//usage: "\n -f Force"
|
||||
//usage:#define bzcat_trivial_usage
|
||||
//usage: "FILE"
|
||||
//usage:#define bzcat_full_usage "\n\n"
|
||||
//usage: "Decompress to stdout"
|
||||
//applet:IF_BUNZIP2(APPLET(bunzip2, _BB_DIR_USR_BIN, _BB_SUID_DROP))
|
||||
//applet:IF_BUNZIP2(APPLET_ODDNAME(bzcat, bunzip2, _BB_DIR_USR_BIN, _BB_SUID_DROP, bzcat))
|
||||
#if ENABLE_BUNZIP2
|
||||
|
@ -15,6 +15,8 @@
|
||||
|
||||
#define NOUSAGE_STR "\b"
|
||||
|
||||
INSERT
|
||||
|
||||
#define acpid_trivial_usage \
|
||||
"[-d] [-c CONFDIR] [-l LOGFILE] [-e PROC_EVENT_FILE] [EVDEV_EVENT_FILE]..."
|
||||
#define acpid_full_usage "\n\n" \
|
||||
@ -234,19 +236,6 @@
|
||||
"\n -v Verbose" \
|
||||
"\n -F Don't store or verify checksum" \
|
||||
|
||||
#define bunzip2_trivial_usage \
|
||||
"[OPTIONS] [FILE]..."
|
||||
#define bunzip2_full_usage "\n\n" \
|
||||
"Decompress FILEs (or stdin)\n" \
|
||||
"\nOptions:" \
|
||||
"\n -c Write to stdout" \
|
||||
"\n -f Force" \
|
||||
|
||||
#define bzcat_trivial_usage \
|
||||
"FILE"
|
||||
#define bzcat_full_usage "\n\n" \
|
||||
"Decompress to stdout"
|
||||
|
||||
#define unlzma_trivial_usage \
|
||||
"[OPTIONS] [FILE]..."
|
||||
#define unlzma_full_usage "\n\n" \
|
@ -200,7 +200,7 @@ applets/usage: include/autoconf.h
|
||||
applets/applet_tables: include/autoconf.h
|
||||
$(HOSTCC) -Wall -Wstrict-prototypes -O2 -fomit-frame-pointer -I$(srctree)/include -o applets/applet_tables applets/applet_tables.c
|
||||
|
||||
include/usage_compressed.h: $(srctree)/include/usage.h applets/usage
|
||||
include/usage_compressed.h: include/usage.h applets/usage
|
||||
$(srctree)/applets/usage_compressed include/usage_compressed.h applets
|
||||
|
||||
include/applet_tables.h: include/applets.h
|
||||
|
@ -10,7 +10,7 @@ srctree="$1"
|
||||
# (Re)generate include/applets.h
|
||||
src="$srctree/include/applets.src.h"
|
||||
dst="include/applets.h"
|
||||
s=`sed -n 's@^//applet:@@p' -- */*.c */*/*.c`
|
||||
s=`sed -n 's@^//applet:@@p' -- "$srctree"/*/*.c "$srctree"/*/*/*.c`
|
||||
echo "/* DO NOT EDIT. This file is generated from applets.src.h */" >"$dst.$$.tmp"
|
||||
# Why "IFS='' read -r REPLY"??
|
||||
# This atrocity is needed to read lines without mangling.
|
||||
@ -27,6 +27,30 @@ else
|
||||
mv -- "$dst.$$.tmp" "$dst"
|
||||
fi
|
||||
|
||||
# (Re)generate include/usage.h
|
||||
src="$srctree/include/usage.src.h"
|
||||
dst="include/usage.h"
|
||||
# We add line continuation backslash after each line,
|
||||
# and insert empty line before each line which doesn't start
|
||||
# with space or tab
|
||||
# (note: we need to use \\\\ because of ``)
|
||||
s=`sed -n -e 's@^//usage:\([ \t].*\)$@\1 \\\\@p' -e 's@^//usage:\([^ \t].*\)$@\n\1 \\\\@p' -- "$srctree"/*/*.c "$srctree"/*/*/*.c`
|
||||
echo "/* DO NOT EDIT. This file is generated from usage.src.h */" >"$dst.$$.tmp"
|
||||
# Why "IFS='' read -r REPLY"??
|
||||
# This atrocity is needed to read lines without mangling.
|
||||
# IFS='' prevents whitespace trimming,
|
||||
# -r suppresses backslash handling.
|
||||
while IFS='' read -r REPLY; do
|
||||
test x"$REPLY" = x"INSERT" && REPLY="$s"
|
||||
printf "%s\n" "$REPLY"
|
||||
done <"$src" >>"$dst.$$.tmp"
|
||||
if test -f "$dst" && cmp -s "$dst.$$.tmp" "$dst"; then
|
||||
rm -- "$dst.$$.tmp"
|
||||
else
|
||||
echo " GEN $dst"
|
||||
mv -- "$dst.$$.tmp" "$dst"
|
||||
fi
|
||||
|
||||
# (Re)generate */Kbuild and */Config.in
|
||||
find -type d | while read -r d; do
|
||||
d="${d#./}"
|
||||
|
Loading…
Reference in New Issue
Block a user