2017-07-18 23:47:51 +05:30
|
|
|
#!/bin/bash
|
2018-12-28 07:50:17 +05:30
|
|
|
# Which config to use when updating the sizes in "official"
|
|
|
|
# source tree? I am using x86 glibc toolchain of some typical distro,
|
|
|
|
# not-static build, 32-bit defconfig build:
|
|
|
|
# # CONFIG_STATIC is not set
|
|
|
|
# CONFIG_CROSS_COMPILER_PREFIX=""
|
|
|
|
# CONFIG_EXTRA_CFLAGS="-m32"
|
|
|
|
# CONFIG_EXTRA_LDFLAGS="-m32"
|
|
|
|
|
2017-07-18 23:47:51 +05:30
|
|
|
# The list of all applet config symbols
|
|
|
|
test -f include/applets.h || { echo "No include/applets.h file"; exit 1; }
|
|
|
|
apps="`
|
|
|
|
grep ^IF_ include/applets.h \
|
|
|
|
| grep -v ^IF_FEATURE_ \
|
|
|
|
| sed 's/IF_\([A-Z0-9._-]*\)(.*/\1/' \
|
|
|
|
| sort | uniq
|
|
|
|
`"
|
|
|
|
|
|
|
|
test $# = 0 && set -- $apps
|
|
|
|
|
|
|
|
mintext=999999999
|
|
|
|
for app; do
|
|
|
|
b="busybox_${app}"
|
|
|
|
test -f "$b" || continue
|
|
|
|
text=`size "$b" | tail -1 | sed -e's/\t/ /g' -e's/^ *//' -e's/ .*//'`
|
|
|
|
#echo "text from $app: $text"
|
|
|
|
test x"${text//[0123456789]/}" = x"" || {
|
|
|
|
echo "Can't get: size $b"
|
|
|
|
exit 1
|
|
|
|
}
|
|
|
|
test $mintext -gt $text && {
|
|
|
|
mintext=$text
|
2018-01-14 16:43:16 +05:30
|
|
|
echo "# New mintext from $app: $mintext"
|
2017-07-18 23:47:51 +05:30
|
|
|
}
|
|
|
|
eval "text_${app}=$text"
|
|
|
|
done
|
|
|
|
|
|
|
|
for app; do
|
|
|
|
b="busybox_${app}"
|
|
|
|
test -f "$b" || continue
|
|
|
|
eval "text=\$text_${app}"
|
2018-01-14 16:43:16 +05:30
|
|
|
echo "# $app adds $((text-mintext))"
|
2017-07-18 23:47:51 +05:30
|
|
|
done
|
2017-07-19 01:31:24 +05:30
|
|
|
|
|
|
|
grep ^IF_ include/applets.h \
|
|
|
|
| grep -v ^IF_FEATURE_ \
|
|
|
|
| sed 's/, .*//' \
|
|
|
|
| sed 's/\t//g' \
|
|
|
|
| sed 's/ //g' \
|
|
|
|
| sed 's/(APPLET(/(/' \
|
|
|
|
| sed 's/(APPLET_[A-Z]*(/(/' \
|
|
|
|
| sed 's/(IF_[A-Z_]*(/(/' \
|
|
|
|
| sed 's/IF_\([A-Z0-9._-]*\)(\(.*\)/\1 \2/' \
|
|
|
|
| sort | uniq \
|
|
|
|
| while read app name; do
|
|
|
|
b="busybox_${app}"
|
|
|
|
test -f "$b" || continue
|
|
|
|
|
2018-12-28 18:07:44 +05:30
|
|
|
file=`grep -l "bool \"$name[\" ]" $(find -name '*.c') | xargs`
|
2018-12-28 17:33:48 +05:30
|
|
|
# A few applets have their CONFIG items in Config.* files, not .c files:
|
2018-12-28 18:07:44 +05:30
|
|
|
test "$file" || file=`grep -l "bool \"$name[\" ]" $(find -name 'Config.*') | xargs`
|
2017-07-19 01:31:24 +05:30
|
|
|
test "$file" || continue
|
|
|
|
#echo "FILE:'$file'"
|
|
|
|
|
|
|
|
eval "text=\$text_${app}"
|
|
|
|
sz=$((text-mintext))
|
|
|
|
sz_kb=$((sz/1000))
|
|
|
|
sz_frac=$(( (sz - sz_kb*1000) ))
|
|
|
|
sz_f=$((sz_frac / 100))
|
|
|
|
|
2018-01-14 16:43:16 +05:30
|
|
|
echo -n "sed 's/bool \"$name"'[" ](*[0-9tinykbytes .]*)*"*$/'
|
2017-07-19 01:31:24 +05:30
|
|
|
if test "$sz_kb" -ge 10; then
|
|
|
|
echo -n "bool \"$name (${sz_kb} kb)\""
|
|
|
|
elif test "$sz_kb" -gt 0 -a "$sz_f" = 0; then
|
|
|
|
echo -n "bool \"$name (${sz_kb} kb)\""
|
|
|
|
elif test "$sz_kb" -gt 0; then
|
|
|
|
echo -n "bool \"$name ($sz_kb.${sz_f} kb)\""
|
|
|
|
elif test "$sz" -ge 200; then
|
|
|
|
echo -n "bool \"$name ($sz bytes)\""
|
|
|
|
else
|
|
|
|
echo -n "bool \"$name (tiny)\""
|
|
|
|
fi
|
|
|
|
echo "/' -i $file"
|
|
|
|
done
|