blob: 4b70e761fc24357cdbf8dca30cc870d649a9d6c0 [file] [log] [blame]
Denys Vlasenko483405a2017-07-18 20:17:51 +02001#!/bin/bash
Denys Vlasenkob097a842018-12-28 03:20:17 +01002# 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
Denys Vlasenko483405a2017-07-18 20:17:51 +020010# The list of all applet config symbols
11test -f include/applets.h || { echo "No include/applets.h file"; exit 1; }
12apps="`
13grep ^IF_ include/applets.h \
14| grep -v ^IF_FEATURE_ \
15| sed 's/IF_\([A-Z0-9._-]*\)(.*/\1/' \
16| sort | uniq
17`"
18
Denys Vlasenko483405a2017-07-18 20:17:51 +020019test $# = 0 && set -- $apps
20
21mintext=999999999
22for app; do
23 b="busybox_${app}"
24 test -f "$b" || continue
25 text=`size "$b" | tail -1 | sed -e's/\t/ /g' -e's/^ *//' -e's/ .*//'`
26 #echo "text from $app: $text"
27 test x"${text//[0123456789]/}" = x"" || {
28 echo "Can't get: size $b"
29 exit 1
30 }
31 test $mintext -gt $text && {
32 mintext=$text
Denys Vlasenko36495af2018-01-14 12:13:16 +010033 echo "# New mintext from $app: $mintext"
Denys Vlasenko483405a2017-07-18 20:17:51 +020034 }
35 eval "text_${app}=$text"
36done
37
38for app; do
39 b="busybox_${app}"
40 test -f "$b" || continue
41 eval "text=\$text_${app}"
Denys Vlasenko36495af2018-01-14 12:13:16 +010042 echo "# $app adds $((text-mintext))"
Denys Vlasenko483405a2017-07-18 20:17:51 +020043done
Denys Vlasenko4eed2c62017-07-18 22:01:24 +020044
45grep ^IF_ include/applets.h \
46| grep -v ^IF_FEATURE_ \
47| sed 's/, .*//' \
48| sed 's/\t//g' \
49| sed 's/ //g' \
50| sed 's/(APPLET(/(/' \
51| sed 's/(APPLET_[A-Z]*(/(/' \
52| sed 's/(IF_[A-Z_]*(/(/' \
53| sed 's/IF_\([A-Z0-9._-]*\)(\(.*\)/\1 \2/' \
54| sort | uniq \
55| while read app name; do
56 b="busybox_${app}"
57 test -f "$b" || continue
58
Denys Vlasenkodf1ff102018-12-28 13:37:44 +010059 file=`grep -l "bool \"$name[\" ]" $(find -name '*.c') | xargs`
Denys Vlasenko83e7e132018-12-28 13:03:48 +010060 # A few applets have their CONFIG items in Config.* files, not .c files:
Denys Vlasenkodf1ff102018-12-28 13:37:44 +010061 test "$file" || file=`grep -l "bool \"$name[\" ]" $(find -name 'Config.*') | xargs`
Denys Vlasenko4eed2c62017-07-18 22:01:24 +020062 test "$file" || continue
63 #echo "FILE:'$file'"
64
65 eval "text=\$text_${app}"
66 sz=$((text-mintext))
67 sz_kb=$((sz/1000))
68 sz_frac=$(( (sz - sz_kb*1000) ))
69 sz_f=$((sz_frac / 100))
70
Denys Vlasenko36495af2018-01-14 12:13:16 +010071 echo -n "sed 's/bool \"$name"'[" ](*[0-9tinykbytes .]*)*"*$/'
Denys Vlasenko4eed2c62017-07-18 22:01:24 +020072 if test "$sz_kb" -ge 10; then
73 echo -n "bool \"$name (${sz_kb} kb)\""
74 elif test "$sz_kb" -gt 0 -a "$sz_f" = 0; then
75 echo -n "bool \"$name (${sz_kb} kb)\""
76 elif test "$sz_kb" -gt 0; then
77 echo -n "bool \"$name ($sz_kb.${sz_f} kb)\""
78 elif test "$sz" -ge 200; then
79 echo -n "bool \"$name ($sz bytes)\""
80 else
81 echo -n "bool \"$name (tiny)\""
82 fi
83 echo "/' -i $file"
84done