size_single_applets.sh 1.9 KB

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