[U-Boot] [PATCH 2/2] add tool to check patch and file for CFG_ presence

Jean-Christophe PLAGNIOL-VILLARD plagnioj at jcrosoft.com
Thu Oct 16 18:02:19 CEST 2008


add same check on all board at MAKEALL start
it can be disable by CHECK=no as
$ CHECK=no ./MAKEALL

Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj at jcrosoft.com>
---
 MAKEALL                  |    5 +++
 Makefile                 |    4 ++
 tools/find_config_errors |   87 ++++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 96 insertions(+), 0 deletions(-)
 create mode 100755 tools/find_config_errors

diff --git a/MAKEALL b/MAKEALL
index 9ccb9ac..a4ce135 100755
--- a/MAKEALL
+++ b/MAKEALL
@@ -22,6 +22,11 @@ fi
 
 LIST=""
 
+if [ "${CHECK}" != "no" ] ; then
+#find config errors as incorrectly used old variable names
+make find_config_errors
+fi
+
 #########################################################################
 ## MPC5xx Systems
 #########################################################################
diff --git a/Makefile b/Makefile
index c711df6..e91cb18 100644
--- a/Makefile
+++ b/Makefile
@@ -3236,4 +3236,8 @@ backup:
 	F=`basename $(TOPDIR)` ; cd .. ; \
 	gtar --force-local -zcvf `date "+$$F-%Y-%m-%d-%T.tar.gz"` $$F
 
+find_config_errors:
+	@echo "Search for config errors"
+	@git-grep CFG_ | cut -d: -f1 | sort -u | xargs -I {} tools/find_config_errors -f {}
+
 #########################################################################
diff --git a/tools/find_config_errors b/tools/find_config_errors
new file mode 100755
index 0000000..168e7e1
--- /dev/null
+++ b/tools/find_config_errors
@@ -0,0 +1,87 @@
+#!/usr/bin/perl
+#
+# (C) Copyright 2008
+# Jean-Christophe PLAGNIOL-VILLARD <plagnioj at jcrosoft.com>
+#
+# See file CREDITS for list of people who contributed to this
+# project.
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License as
+# published by the Free Software Foundation; either version 2 of
+# the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+# MA 02111-1307 USA
+#
+use Getopt::Std;
+my $num = 1;
+my $mode_patch = 0;
+my $opt_string = 'hpf:';
+
+getopts( "$opt_string", \%opt ) or usage();
+usage() if $opt{h};
+
+if ($opt{p}) {
+	$mode_patch = 1;
+}
+
+sub usage()
+{
+	print STDERR << "EOF";
+This program does...
+usage: $0 [-hp] [-f file] <or STDIN>
+ -h        : this (help) message
+ -p        : mode patch
+ -f file   : file to work on
+EOF
+exit;
+}
+
+my $file = $opt{f};
+
+if ($file =~ m/\.patch$/) {
+	$mode_patch = 1;
+}
+
+if ($file =~ m/(config_deprecated\.h$|^CHANGELOG)/) {
+	exit 0
+}
+
+if ($file) {
+	open FILE, $file or die $!;
+} else {
+	open FILE, "<&STDIN" or die $!;
+}
+
+while (chomp($line = <FILE>))
+{
+	if ((( $mode_patch == 1 ) && ( $line =~ m/^\+/)) || $mode_patch == 0) {
+
+		my @matches = $line =~ m/[\s\(\)+-\/\*{}<>=,;&~#\!'"\[](CFG_[A-Z0-9_a-z]+)/;
+
+		push (@matches, $line =~ m/^(CFG_[A-Z0-9_a-z]+)/);
+
+		push (@matches, $line =~ m/-D(CFG_[A-Z0-9_a-z]+)/);
+
+		my $sz = scalar(@matches);
+
+		for (my $i=0; $i < $sz; $i++) {
+			$cfg = $matches[$i];
+			print $file.":".$num." ";
+			print "#error \"".$cfg." renamed! Use ";
+			$cfg =~ s/CFG_/CONFIG_SYS_/g;
+			print $cfg." or new config instead!\"\n";
+			print $line."\n";
+		}
+	}
+	$num++;
+}
+close FILE;
-- 
1.5.6.5



More information about the U-Boot mailing list