Denys Vlasenko | 483405a | 2017-07-18 20:17:51 +0200 | [diff] [blame] | 1 | #!/bin/bash |
| 2 | # The list of all applet config symbols |
| 3 | test -f include/applets.h || { echo "No include/applets.h file"; exit 1; } |
| 4 | apps="` |
| 5 | grep ^IF_ include/applets.h \ |
| 6 | | grep -v ^IF_FEATURE_ \ |
| 7 | | sed 's/IF_\([A-Z0-9._-]*\)(.*/\1/' \ |
| 8 | | sort | uniq |
| 9 | `" |
| 10 | |
Denys Vlasenko | 483405a | 2017-07-18 20:17:51 +0200 | [diff] [blame] | 11 | test $# = 0 && set -- $apps |
| 12 | |
| 13 | mintext=999999999 |
| 14 | for app; do |
| 15 | b="busybox_${app}" |
| 16 | test -f "$b" || continue |
| 17 | text=`size "$b" | tail -1 | sed -e's/\t/ /g' -e's/^ *//' -e's/ .*//'` |
| 18 | #echo "text from $app: $text" |
| 19 | test x"${text//[0123456789]/}" = x"" || { |
| 20 | echo "Can't get: size $b" |
| 21 | exit 1 |
| 22 | } |
| 23 | test $mintext -gt $text && { |
| 24 | mintext=$text |
Denys Vlasenko | 36495af | 2018-01-14 12:13:16 +0100 | [diff] [blame] | 25 | echo "# New mintext from $app: $mintext" |
Denys Vlasenko | 483405a | 2017-07-18 20:17:51 +0200 | [diff] [blame] | 26 | } |
| 27 | eval "text_${app}=$text" |
| 28 | done |
| 29 | |
| 30 | for app; do |
| 31 | b="busybox_${app}" |
| 32 | test -f "$b" || continue |
| 33 | eval "text=\$text_${app}" |
Denys Vlasenko | 36495af | 2018-01-14 12:13:16 +0100 | [diff] [blame] | 34 | echo "# $app adds $((text-mintext))" |
Denys Vlasenko | 483405a | 2017-07-18 20:17:51 +0200 | [diff] [blame] | 35 | done |
Denys Vlasenko | 4eed2c6 | 2017-07-18 22:01:24 +0200 | [diff] [blame] | 36 | |
| 37 | grep ^IF_ include/applets.h \ |
| 38 | | grep -v ^IF_FEATURE_ \ |
| 39 | | sed 's/, .*//' \ |
| 40 | | sed 's/\t//g' \ |
| 41 | | sed 's/ //g' \ |
| 42 | | sed 's/(APPLET(/(/' \ |
| 43 | | sed 's/(APPLET_[A-Z]*(/(/' \ |
| 44 | | sed 's/(IF_[A-Z_]*(/(/' \ |
| 45 | | sed 's/IF_\([A-Z0-9._-]*\)(\(.*\)/\1 \2/' \ |
| 46 | | sort | uniq \ |
| 47 | | while read app name; do |
| 48 | b="busybox_${app}" |
| 49 | test -f "$b" || continue |
| 50 | |
| 51 | file=`grep -lF "bool \"$name" $(find -name '*.c') | xargs` |
| 52 | # so far all such items are in .c files; if need to check Config.* files: |
| 53 | #test "$file" || file=`grep -lF "bool \"$name" $(find -name 'Config.*') | xargs` |
| 54 | test "$file" || continue |
| 55 | #echo "FILE:'$file'" |
| 56 | |
| 57 | eval "text=\$text_${app}" |
| 58 | sz=$((text-mintext)) |
| 59 | sz_kb=$((sz/1000)) |
| 60 | sz_frac=$(( (sz - sz_kb*1000) )) |
| 61 | sz_f=$((sz_frac / 100)) |
| 62 | |
Denys Vlasenko | 36495af | 2018-01-14 12:13:16 +0100 | [diff] [blame] | 63 | echo -n "sed 's/bool \"$name"'[" ](*[0-9tinykbytes .]*)*"*$/' |
Denys Vlasenko | 4eed2c6 | 2017-07-18 22:01:24 +0200 | [diff] [blame] | 64 | if test "$sz_kb" -ge 10; then |
| 65 | echo -n "bool \"$name (${sz_kb} kb)\"" |
| 66 | elif test "$sz_kb" -gt 0 -a "$sz_f" = 0; then |
| 67 | echo -n "bool \"$name (${sz_kb} kb)\"" |
| 68 | elif test "$sz_kb" -gt 0; then |
| 69 | echo -n "bool \"$name ($sz_kb.${sz_f} kb)\"" |
| 70 | elif test "$sz" -ge 200; then |
| 71 | echo -n "bool \"$name ($sz bytes)\"" |
| 72 | else |
| 73 | echo -n "bool \"$name (tiny)\"" |
| 74 | fi |
| 75 | echo "/' -i $file" |
| 76 | done |