summaryrefslogtreecommitdiffstats
path: root/scripts
diff options
context:
space:
mode:
authorJosh Boyer <jwboyer@fedoraproject.org>2014-11-11 09:57:11 -0500
committerJosh Boyer <jwboyer@fedoraproject.org>2014-11-11 09:57:11 -0500
commit8985cfb689e8e0a9f43c031d3ef4e6751cf78481 (patch)
treeba24674850033e439bad4f569254c23a78c27ecb /scripts
parent81c4dc55f83517f99282c822fa0def3e308414b5 (diff)
downloadkernel-8985cfb689e8e0a9f43c031d3ef4e6751cf78481.tar.gz
kernel-8985cfb689e8e0a9f43c031d3ef4e6751cf78481.tar.xz
kernel-8985cfb689e8e0a9f43c031d3ef4e6751cf78481.zip
Add check-configs.pl script from Paul Bolle
We can run this once per RC (or somewhat frequently) to keep the split config-* files clean of dead Kconfig options
Diffstat (limited to 'scripts')
-rw-r--r--scripts/check-configs.pl83
1 files changed, 83 insertions, 0 deletions
diff --git a/scripts/check-configs.pl b/scripts/check-configs.pl
new file mode 100644
index 000000000..10282aa74
--- /dev/null
+++ b/scripts/check-configs.pl
@@ -0,0 +1,83 @@
+# By Paul Bolle October 2014.
+#
+# Contributed to the public domain by its author.
+
+use 5.016;
+use warnings;
+use autodie;
+
+use File::Find;
+
+my @Kconfigs;
+
+my $Kconfigre = qr/Kconfig.*/;
+my $configre = qr/^\s*(menu)?config\s+(?<config>(\w+))$/;
+my $CONFIG_re = qr/\bCONFIG_(?<CONFIG_>(\w+))/;
+
+sub match {
+ push( @Kconfigs, $File::Find::name ) if ($_ =~ $Kconfigre);
+}
+
+sub parse_kconfig {
+ my ($path) = @_;
+
+ my @ret;
+
+ open( my $kconfig, "<", $path );
+ my $slurp = do { local $/ = undef; <$kconfig> };
+ close( $kconfig );
+ my @lines = split ( /\n/, $slurp );
+ foreach my $line (@lines) {
+ if ($line =~ /$configre/) {
+ push( @ret, $+{config} );
+ }
+ }
+
+ @ret;
+}
+
+sub parse_shipped {
+ my ($path) = @_;
+
+ my @ret;
+
+ open( my $shipped, "<", $path );
+ my $slurp = do { local $/ = undef; <$shipped> };
+ close( $shipped );
+ my @lines = split ( /\n/, $slurp );
+ my $i = 1;
+ foreach my $line (@lines) {
+ if ($line =~ /$CONFIG_re/) {
+ push( @ret, [$i, $+{CONFIG_}] );
+ }
+ $i++;
+ }
+
+ @ret;
+}
+
+exit main ( @ARGV );
+
+sub main {
+ my %configs;
+
+ find( \&match, @_ );
+
+ foreach my $Kconfig (@Kconfigs) {
+ my (@tmp) = parse_kconfig( $Kconfig );
+ foreach my $config ( @tmp ) {
+ $configs{ $config }++;
+ }
+ }
+
+ foreach my $shipped (glob("config-*")) {
+ my (@tmp) = parse_shipped( $shipped );
+ foreach my $ref ( @tmp ) {
+ say( STDERR "$shipped:$ref->[0]: No Kconfig symbol matches 'CONFIG_$ref->[1]'" )
+ unless (grep( /$ref->[1]/, keys( %configs )));
+ }
+ }
+
+ 0;
+}
+