/scripts/checkkconfigsymbols.sh
来源:互联网 发布:linux学了有什么用 编辑:程序博客网 时间:2024/05/16 19:24
#!/bin/sh
# Find Kconfig variables used in source code but never defined in Kconfig
# Copyright (C) 2007, Paolo 'Blaisorblade' Giarrusso <blaisorblade@yahoo.it>
# Tested with dash.
#与$*不同,$@指所有位置参数被分别表示为双引号中的N个字符串
paths="$@"
#如果没有指定路径,则默认为当前目录
[ -z "$paths" ] && paths=.
# Doing this once at the beginning saves a lot of time, on a cache-hot tree.
#在当前目录下查找所有名为Kconfig或以Kconfig开头的非备份文件
Kconfigs="`find . -name 'Kconfig' -o -name 'Kconfig*[^~]'`"
echo -e "File list /tundefined symbol used"
#在$paths目录下查找.c, .h, .S文件或Makefile以及以Makefile开头的非备份文件,将文件路径传递到while循环中
find $paths -name '*.[chS]' -o -name 'Makefile' -o -name 'Makefile*[^~]'| while read i
do
# Output the bare Kconfig variable and the filename; the _MODULE part at
# the end is not removed here (would need perl an not-hungry regexp for that).
#查找UML_CONFIG_xxx, 将其替换为xxx $i,其中xxx为变量名,$i为文件路径名
sed -ne 's!^.*/</(UML_/)/?CONFIG_/([0-9A-Z_]/+/).*!/2 '$i'!p' < $i
done | /
# Smart "sort|uniq" implemented in awk and tuned to collect the names of all
# files which use a given symbol
#创建数组map,记录变量名以及出现的次数等信息
awk '{map[$1, count[$1]++] = $2; }
END {
for (combIdx in map) {
#SUBSEP默认为逗号,所以会创建数组separate,其中separate[1]=$1
split(combIdx, separate, SUBSEP);
# The value may have been removed.
#确认该数组项是否已被删除
if (! ( (separate[1], separate[2]) in map ) )
continue;
#变量名
symb=separate[1];
#输出变量名
printf "%s ", symb;
#Use gawk extension to delete the names vector
delete names;
#Portably delete the names vector
#split("", names);
for (i=0; i < count[symb]; i++) {
names[map[symb, i]] = 1;#建立数组names,索引为变量名所在的文件路径
# Unfortunately, we may still encounter symb, i in the
# outside iteration.
delete map[symb, i];
}
i=0;
#输出文件路径名
for (name in names) {
if (i > 0)
printf ", %s", name;
else
printf "%s", name;
i++;
}
printf "/n";
}
}' |
while read symb files; do
# Remove the _MODULE suffix when checking the variable name. This should
# be done only on tristate symbols, actually, but Kconfig parsing is
# beyond the purpose of this script.
#删除后缀_MODULE
symb_bare=`echo $symb | sed -e 's/_MODULE//'`
#如果在$Kconfigs文件中没有找到变量名,就输出文件路径和变量名
if ! grep -q "/<$symb_bare/>" $Kconfigs; then
echo -e "$files: /t$symb"
fi
done|sort
- /scripts/checkkconfigsymbols.sh
- 驱动编译错误 /bin/sh: scripts/mod/modpost
- AutoConfig could not successfully execute the following scripts: afdbprf.sh and adcrobj.sh
- SCRIPTS
- scripts
- scripts
- HOSTCC scripts/basic/fixdep /bin/sh: line 1: gcc: command not found解决办法
- MODPOST 1 modules/bin/sh: scripts/mod/modpost: not found的解决
- busybox-1.17.3/scripts/gcc-version.sh: line 11: arm-linux-gcc: command not found
- Received value [sh: /etc/zabbix/scripts/mysql: Permission denied] is not suitable for value type
- 编译linux内核错误:./scripts/gen_initramfs_list.sh: Cannot open '/usr/share/v86d
- faster-rcnn 之 shell脚本开始训练:./experiments/scripts/faster_rcnn_alt_opt.sh 0 ZF pascal_voc
- sh
- WINHEX Scripts
- shell scripts
- PSACCESSLOG scripts
- Free Scripts
- shell scripts
- jsp数据操作代码集
- 6天6夜 老婆产经 老公陪产 虎虎出世全纪录【2】
- 拒绝平庸。
- 发送邮件资料累积
- jsp与数据库连接
- /scripts/checkkconfigsymbols.sh
- JSP2.0 EL语言
- 蚁群算法
- tomcat中manager配置
- 邮件发送程序V1.0
- 在Linux下安装JDK及环境设置
- 各种JAVA开发框架
- JDK安装及环境配置
- j2me的socket通讯问题