3
0

size_single_applets.sh 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. #!/bin/bash
  2. # Which config to use when updating the sizes in "official"
  3. # source tree? I am using x86 glibc toolchain of some typical distro,
  4. # not-static build, 32-bit defconfig build:
  5. # # CONFIG_STATIC is not set
  6. # CONFIG_CROSS_COMPILER_PREFIX=""
  7. # CONFIG_EXTRA_CFLAGS="-m32"
  8. # CONFIG_EXTRA_LDFLAGS="-m32"
  9. # The list of all applet config symbols
  10. test -f include/applets.h || { echo "No include/applets.h file"; exit 1; }
  11. apps="`
  12. grep ^IF_ include/applets.h \
  13. | grep -v ^IF_FEATURE_ \
  14. | sed 's/IF_\([A-Z0-9._-]*\)(.*/\1/' \
  15. | sort | uniq
  16. `"
  17. test $# = 0 && set -- $apps
  18. mintext=999999999
  19. for app; do
  20. b="busybox_${app}"
  21. test -f "$b" || continue
  22. text=`size "$b" | tail -1 | sed -e's/\t/ /g' -e's/^ *//' -e's/ .*//'`
  23. #echo "text from $app: $text"
  24. test x"${text//[0123456789]/}" = x"" || {
  25. echo "Can't get: size $b"
  26. exit 1
  27. }
  28. test $mintext -gt $text && {
  29. mintext=$text
  30. echo "# New mintext from $app: $mintext"
  31. }
  32. eval "text_${app}=$text"
  33. done
  34. for app; do
  35. b="busybox_${app}"
  36. test -f "$b" || continue
  37. eval "text=\$text_${app}"
  38. echo "# $app adds $((text-mintext))"
  39. done
  40. grep ^IF_ include/applets.h \
  41. | grep -v ^IF_FEATURE_ \
  42. | sed 's/, .*//' \
  43. | sed 's/\t//g' \
  44. | sed 's/ //g' \
  45. | sed 's/(APPLET(/(/' \
  46. | sed 's/(APPLET_[A-Z]*(/(/' \
  47. | sed 's/(IF_[A-Z_]*(/(/' \
  48. | sed 's/IF_\([A-Z0-9._-]*\)(\(.*\)/\1 \2/' \
  49. | sort | uniq \
  50. | while read app name; do
  51. b="busybox_${app}"
  52. test -f "$b" || continue
  53. file=`grep -l "bool \"$name[\" ]" $(find -name '*.c') | xargs`
  54. # A few applets have their CONFIG items in Config.* files, not .c files:
  55. test "$file" || file=`grep -l "bool \"$name[\" ]" $(find -name 'Config.*') | xargs`
  56. test "$file" || continue
  57. #echo "FILE:'$file'"
  58. eval "text=\$text_${app}"
  59. sz=$((text-mintext))
  60. sz_kb=$((sz/1000))
  61. sz_frac=$(( (sz - sz_kb*1000) ))
  62. sz_f=$((sz_frac / 100))
  63. echo -n "sed 's/bool \"$name"'[" ](*[0-9tinykbytes .]*)*"*$/'
  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