File indexing completed on 2024-04-06 12:31:47
0001
0002 use File::Basename;
0003 use lib dirname($0);
0004 use SCRAMGenUtils;
0005 use Getopt::Long;
0006 $|=1;
0007
0008 if(&GetOptions(
0009 "--release=s",\$rel,
0010 "--out=s",\$output,
0011 "--json",\$json,
0012 "--help",\$help,
0013 ) eq ""){print STDERR "=====>ERROR: Wrong arguments.\n"; &usage_msg();}
0014
0015 if (defined $help){&usage_msg();}
0016 if (!defined $rel){&usage_msg();}
0017 if (defined $json){$json=1;}
0018 else{$json=0;}
0019
0020 if (!-f "${rel}/.SCRAM/Environment"){die "Invalid release base path provided: $rel\n";}
0021 my $ver=basename($rel);
0022
0023 my $pref=*STDOUT;
0024 if (defined $output){open($pref,">$output") || die "Can not open file for writing: $output\n";}
0025
0026 my %cache=();
0027 $cache{valid}{interface}{interface}=1;
0028 $cache{valid}{src}{interface}=1;
0029 $cache{valid}{plugins}{interface}=1;
0030 $cache{valid}{test}{interface}=1;
0031 $cache{valid}{bin}{interface}=1;
0032 $cache{exception}{'GeneratorInterface\/.+\.F'}='SimDataFormats\/GeneratorProducts\/data\/.+\.inc';
0033 $cache{exception}{'GeneratorInterface\/.+\.inc'}='SimDataFormats\/GeneratorProducts\/data\/.+\.inc';
0034 $cache{exception}{'SimDataFormats\/GeneratorProducts\/src\/HepEvt.F'}='SimDataFormats\/GeneratorProducts\/data\/.+\.inc';
0035 $cache{exception}{'Iguana\/GLBrowsers\/src\/.+\.cc'}='Iguana\/GLBrowsers\/pixmaps/.+\.xpm';
0036
0037 my $c=0;
0038 print STDERR "Processing files in ${rel}/src ...";
0039 foreach my $f (`find ${rel}/src -name "*" -type f`)
0040 {
0041 chomp $f;
0042 my $d=dirname($f);
0043 my $rf=$f; $rf=~s/^$rel\/src\/*//;
0044 my ($based,$type,$pk)=&getFileInfo($rf);
0045 if (($type eq "") || (!exists $cache{valid}{$type})){next;}
0046 foreach my $l (`cat $f`)
0047 {
0048 chomp $l;
0049 if ($l=~/^\s*#\s*include\s*["<]([^">]+)[">]/)
0050 {
0051 my $inc=$1;
0052 if ((-f "${d}/${inc}") || (!-f "${rel}/src/${inc}")){next;}
0053 my ($bd1,$t1,$pk1)=&getFileInfo($inc);
0054 if (($bd1 eq $based) || (exists $cache{valid}{$type}{$t1})){next;}
0055 my $skip=0;
0056 foreach my $exp (keys %{$cache{exception}})
0057 {
0058 if ($rf=~/^$exp$/)
0059 {
0060 my $xi=$cache{exception}{$exp};
0061 if ($inc=~/^$xi$/){$skip=1; last;}
0062 }
0063 }
0064 if ($skip){next;}
0065 $cache{ERRORS}{$ver}{$pk}{$rf}{$inc}=1;
0066 }
0067 }
0068 $c++;
0069 if ($c==2000){print STDERR ".";$c=0;last;}
0070 }
0071 print STDERR " Done\n";
0072
0073 if (!$json)
0074 {
0075 foreach my $pk (sort keys %{$cache{ERRORS}{$ver}})
0076 {
0077 foreach my $rf (sort keys %{$cache{ERRORS}{$ver}{$pk}})
0078 {
0079 foreach my $inc (sort keys %{$cache{ERRORS}{$ver}{$pk}{$rf}}){print $pref "$rf $inc\n";}
0080 }
0081 }
0082 }
0083 else
0084 {
0085 my $str=&SCRAMGenUtils::writeJson($cache{ERRORS},0); chomp ($str); $str=~s/, *$//;
0086 print $pref "$str\n";
0087 }
0088
0089 if (defined $out){close($pref);}
0090
0091 sub getFileInfo()
0092 {
0093 my $f=shift;
0094 if($f=~/^([A-Z][^\/]+)\/+([A-Za-z0-9][^\/]+)\/+([^\/]+)\/.+/){return ("$1/$2/$3",$3,"$1/$2");}
0095 return ("","","");
0096 }
0097
0098 sub usage_msg()
0099 {
0100 print STDERR "Usage: $0 --release <path> [--out <file>] [--json] [--help]\n",
0101 " --release <path> Release base path\n",
0102 " --out <file> File path to write the output\n",
0103 " --json JSON format output\n",
0104 " --help Show this help message\n";
0105 exit 0;
0106 }