public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
From: Tom Rini <trini@konsulko.com>
To: u-boot@lists.denx.de
Subject: tools: Check for already migrated symbols in a given file
Date: Wed, 8 Sep 2021 09:50:28 -0400	[thread overview]
Message-ID: <20210908135028.GC12964@bill-the-cat> (raw)

[-- Attachment #1: Type: text/plain, Size: 1973 bytes --]

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}

-- 
Tom

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 659 bytes --]

                 reply	other threads:[~2021-09-08 13:50 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210908135028.GC12964@bill-the-cat \
    --to=trini@konsulko.com \
    --cc=u-boot@lists.denx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox