Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 14:32:01

0001 #!/usr/bin/env perl
0002 use Cwd;
0003 use File::Basename;
0004 use lib dirname($0);
0005 use SCRAMGenUtils;
0006 
0007 my $curdir=cwd();
0008 my $file=shift || die "Missing file path to check";
0009 if(!-f $file){die "No such file:$file";}
0010 
0011 if($file!~/^\//){$file="${curdir}/${file}";}
0012 $file=&SCRAMGenUtils::fixPath($file);
0013 my $rel=dirname($file);
0014 while(!-d "${rel}/.SCRAM"){$rel=dirname($rel);}
0015 if(!-d "${rel}/.SCRAM"){die "not a scram base dir";}
0016 my $tmpdir="${rel}/tmp/IncludeChecker/${arch}";
0017 
0018 $file=~s/^$rel\///;
0019 $file=~s/^src\///;
0020 my $arch=&SCRAMGenUtils::getScramArch();
0021 
0022 my $cache={};
0023 &getIncludes($file,$cache);
0024 foreach my $inc (@{$cache->{order}})
0025 {
0026   my $c=&readcachefile($inc);
0027   foreach my $i (keys %{$c->{ALL_INCLUDES_REMOVED}})
0028   {if(&wasremoved($inc,$i)){print "$inc => $i\n";}}
0029 }
0030 exit 0;
0031 
0032 sub getIncludes ()
0033 {
0034   my $f=shift;
0035   my $c=shift || {};
0036   if(exists $c->{all}{$f}){return;}
0037   my $cfile="${tmpdir}/cache/files/${f}";
0038   if(!-f $cfile){return;}
0039   $c->{all}{$f}=1;
0040   push @{$c->{order}},$f;
0041   my $c1=&readcachefile($f);
0042   foreach my $f (keys %{$c1->{INCLUDES}})
0043   {&getIncludes($f,$c);}
0044 }
0045 
0046 sub readcachefile()
0047 {
0048   my $file=shift;
0049   if(exists $cache->{data}{$file}){return $cache->{data}{$file};}
0050   my $cfile="${tmpdir}/cache/files/${file}";
0051   my $c={};
0052   if(-f $cfile){$c=&SCRAMGenUtils::readHashCache($cfile);}
0053   $cache->{data}{$file}=$c;
0054   return $c;
0055 }
0056 
0057 sub wasremoved ()
0058 {
0059   my $file=shift;
0060   my $inc=shift;
0061   my $cfile="${tmpdir}/includechecker/src/${file}.modified_by_incchk";
0062   if(!-f $cfile){$cfile="${tmpdir}/includechecker/src/${file}";}
0063   if(!-f $cfile){return 0;}
0064   foreach my $l (`cat $cfile`)
0065   {
0066     chomp $l;
0067     if($l=~/^\s*\/\/INCLUDECHECKER: Removed this line:\s+#\s*include\s*(<|")\s*$inc\s*(>|")/){return 1;}
0068   }
0069 }