Skip to contentSkip to conversation

tools: Check for already migrated symbols in a given file

DISCUSSION Tom Rini 1 participant 1 message Sep 8, 2021

lore
Share & tools
lore

Tom Rini

author
#0 lore raw

Hey all,

As I look over patchwork I see (as one would expect) platforms showing up that will come in either to -next, or once v2021.10 is out. Given the number of newly migrated symbols now in -next, along with my hope to get more done soon as well has having discovered lots of already migrated symbols showing up again in board config.h files, I want to pass along this bit of shell script. It's heavily borrowed from scripts/build-whitelist.sh and basically has comm providing a different column. It's also not fool-proof as I skipped handling CONFIG_SYS_EXTRA_OPTIONS as I just want to remove that symbol entirely. What you do with this is:

$ check-migrated-symbols.sh include/configs/am335x_evm.h
CONFIG_SYS_I2C_EEPROM_ADDR
CONFIG_SYS_I2C_EEPROM_ADDR_LEN
CONFIG_SYS_NAND_BLOCK_SIZE
CONFIG_SYS_NAND_OOBSIZE
CONFIG_SYS_NAND_PAGE_SIZE
CONFIG_SYS_NAND_U_BOOT_OFFS

And see that oh, those symbols need to be moved to the defconfig. I'm not posting this to complain about existing board files (but I'll be cleaning up stuff) but rather to note that when adding new boards, it's REALLY important to catch and fix those problems. And without a script of some sort, it's also a pain. So here's the script:

#!/bin/bash

if [ ! -f Kconfig ]; then
echo "ERROR: Must be run from root of U-Boot directory" exit 1
fi

# Cleanup when done.
trap "{ rm -rf ${KSYMLST} ${KUSEDLST}; }" EXIT

KSYMLST=mktemp
KUSEDLST=mktemp

# List of existing symbols

cat `find . -name "Kconfig*"` | sed -n \
	-e 's/^\s*config *\([A-Za-z0-9_]*\).*$/CONFIG_\1/p' \
	-e 's/^\s*menuconfig *\([A-Za-z0-9_]*\).*$/CONFIG_\1/p' \
	| sort -u > $KSYMLST

# Check each argument
while test $# -ne 0; do

	# Not a file
	[ ! -f "$1" ] && shift 1
	grep '#define[[:blank:]]CONFIG_' $1 | sed -n 's/#define.\(CONFIG_[A-Za-z0-9_]*\).*/\1/p' | sort -u > ${KUSEDLST}
	comm -12 ${KSYMLST} ${KUSEDLST}
	shift 1

done

rm -f ${KSYMLST} ${KUSEDLST}

Signature · 1 line
Tom