diff options
author | Denys Vlasenko <vda.linux@googlemail.com> | 2010-06-06 01:53:38 +0200 |
---|---|---|
committer | Denys Vlasenko <vda.linux@googlemail.com> | 2010-06-06 01:53:38 +0200 |
commit | f0f94700610eba964441ce4a112134e03c76eb89 (patch) | |
tree | 2823e4cd344df7f85f0cd94dc87f1133d05fcc19 /scripts/gen_build_files.sh | |
parent | 6c5bf0d347faded028e15d523c26a0d64c6d3920 (diff) | |
download | busybox-w32-f0f94700610eba964441ce4a112134e03c76eb89.tar.gz busybox-w32-f0f94700610eba964441ce4a112134e03c76eb89.tar.bz2 busybox-w32-f0f94700610eba964441ce4a112134e03c76eb89.zip |
make it possible to keep usage texts in .c files
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'scripts/gen_build_files.sh')
-rwxr-xr-x | scripts/gen_build_files.sh | 26 |
1 files changed, 25 insertions, 1 deletions
diff --git a/scripts/gen_build_files.sh b/scripts/gen_build_files.sh index 44e8c1744..647c7daf7 100755 --- a/scripts/gen_build_files.sh +++ b/scripts/gen_build_files.sh | |||
@@ -10,7 +10,7 @@ srctree="$1" | |||
10 | # (Re)generate include/applets.h | 10 | # (Re)generate include/applets.h |
11 | src="$srctree/include/applets.src.h" | 11 | src="$srctree/include/applets.src.h" |
12 | dst="include/applets.h" | 12 | dst="include/applets.h" |
13 | s=`sed -n 's@^//applet:@@p' -- */*.c */*/*.c` | 13 | s=`sed -n 's@^//applet:@@p' -- "$srctree"/*/*.c "$srctree"/*/*/*.c` |
14 | echo "/* DO NOT EDIT. This file is generated from applets.src.h */" >"$dst.$$.tmp" | 14 | echo "/* DO NOT EDIT. This file is generated from applets.src.h */" >"$dst.$$.tmp" |
15 | # Why "IFS='' read -r REPLY"?? | 15 | # Why "IFS='' read -r REPLY"?? |
16 | # This atrocity is needed to read lines without mangling. | 16 | # This atrocity is needed to read lines without mangling. |
@@ -27,6 +27,30 @@ else | |||
27 | mv -- "$dst.$$.tmp" "$dst" | 27 | mv -- "$dst.$$.tmp" "$dst" |
28 | fi | 28 | fi |
29 | 29 | ||
30 | # (Re)generate include/usage.h | ||
31 | src="$srctree/include/usage.src.h" | ||
32 | dst="include/usage.h" | ||
33 | # We add line continuation backslash after each line, | ||
34 | # and insert empty line before each line which doesn't start | ||
35 | # with space or tab | ||
36 | # (note: we need to use \\\\ because of ``) | ||
37 | s=`sed -n -e 's@^//usage:\([ \t].*\)$@\1 \\\\@p' -e 's@^//usage:\([^ \t].*\)$@\n\1 \\\\@p' -- "$srctree"/*/*.c "$srctree"/*/*/*.c` | ||
38 | echo "/* DO NOT EDIT. This file is generated from usage.src.h */" >"$dst.$$.tmp" | ||
39 | # Why "IFS='' read -r REPLY"?? | ||
40 | # This atrocity is needed to read lines without mangling. | ||
41 | # IFS='' prevents whitespace trimming, | ||
42 | # -r suppresses backslash handling. | ||
43 | while IFS='' read -r REPLY; do | ||
44 | test x"$REPLY" = x"INSERT" && REPLY="$s" | ||
45 | printf "%s\n" "$REPLY" | ||
46 | done <"$src" >>"$dst.$$.tmp" | ||
47 | if test -f "$dst" && cmp -s "$dst.$$.tmp" "$dst"; then | ||
48 | rm -- "$dst.$$.tmp" | ||
49 | else | ||
50 | echo " GEN $dst" | ||
51 | mv -- "$dst.$$.tmp" "$dst" | ||
52 | fi | ||
53 | |||
30 | # (Re)generate */Kbuild and */Config.in | 54 | # (Re)generate */Kbuild and */Config.in |
31 | find -type d | while read -r d; do | 55 | find -type d | while read -r d; do |
32 | d="${d#./}" | 56 | d="${d#./}" |