Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:31:48

0001 #!/usr/bin/env perl
0002 use File::Basename;
0003 use lib dirname($0);
0004 use SCRAMGenUtils;
0005 
0006 my $pwd=`/bin/pwd`; chomp $pwd; $pwd=&SCRAMGenUtils::fixPath($pwd);
0007 my $dir=shift || $pwd;
0008 if ($dir!~/^\//){$dir=&SCRAMGenUtils::fixPath("${pwd}/${dir}");}
0009 
0010 my $release=&SCRAMGenUtils::scramReleaseTop($dir);
0011 if($release eq ""){print STDERR "ERROR: Please run this script from a SCRAM-based area.\n"; exit 1;}
0012 &SCRAMGenUtils::init ($release);
0013 
0014 my $cachefile=&SCRAMGenUtils::fixCacheFileName(${release}."/.SCRAM/".$ENV{SCRAM_ARCH}."/ProjectCache.db");
0015 my $projcache=&SCRAMGenUtils::readCache($cachefile);
0016 
0017 my $data={};
0018 foreach my $dir (reverse sort keys %{$projcache->{BUILDTREE}}){&updateProd($dir);}
0019 
0020 foreach my $pack (sort keys %$data)
0021 {
0022   my $str="";
0023   foreach my $p (sort keys %{$data->{$pack}{LIBRARY}}){$str.="lib$p.so,";}
0024   foreach my $p (sort keys %{$data->{$pack}{PLUGIN}}){$str.="plugin$p.so,";}
0025   foreach my $p (sort keys %{$data->{$pack}{IGLET}}){$str.="$p.iglet,";}
0026   $str=~s/,$//; $str.="|";
0027   foreach my $p (sort keys %{$data->{$pack}{BIN}}){$str.="$p,";}
0028   $str=~s/,$//; $str.="|";
0029   foreach my $p (sort keys %{$data->{$pack}{TEST}}){$str.="$p,";}
0030   $str=~s/,$//; $str.="|";
0031   foreach my $p (sort keys %{$data->{$pack}{SCRIPTS}}){$str.="$p,";}
0032   $str=~s/,$//;
0033   print "$pack:$str\n"; 
0034 }
0035 exit 0;
0036 
0037 sub doSearch()
0038 {
0039   foreach my $pack (sort keys %$data)
0040   {
0041     foreach my $p (sort keys %{$data->{$pack}{LIBRARY}})
0042     {
0043       if (!-e "${release}/lib/".$ENV{SCRAM_ARCH}."/lib${p}.so"){print "Missing LIBRARY: lib${p}.so\n";}
0044     }
0045     foreach my $p (sort keys %{$data->{$pack}{PLUGIN}})
0046     {
0047       if (!-e "${release}/lib/".$ENV{SCRAM_ARCH}."/plugin${p}.so"){print "Missing PLUGIN: plugin${p}.so\n";}
0048     }
0049     foreach my $p (sort keys %{$data->{$pack}{IGLET}})
0050     {
0051       if (!-e "${release}/lib/".$ENV{SCRAM_ARCH}."/${p}.iglet"){print "Missing IGLET: ${p}.iglet\n";}
0052     }
0053     foreach my $p (sort keys %{$data->{$pack}{BIN}})
0054     {
0055       if (!-e "${release}/bin/".$ENV{SCRAM_ARCH}."/${p}"){print "Missing BIN: $p\n";}
0056     }
0057     foreach my $p (sort keys %{$data->{$pack}{TEST}})
0058     {
0059       if (!-e "${release}/test/".$ENV{SCRAM_ARCH}."/${p}"){print "Missing TEST: $p\n";}
0060     }
0061     foreach my $p (sort keys %{$data->{$pack}{SCRIPTS}})
0062     {
0063       if (!-e "${release}/bin/".$ENV{SCRAM_ARCH}."/${p}"){print "Missing SCRIPTS: $p\n";}
0064     }
0065   }
0066 }
0067 
0068 sub doSearchRev()
0069 {
0070   foreach my $file (`find ${release}/lib/$ENV{SCRAM_ARCH} -name "*" -type f | sed 's|${release}/lib/$ENV{SCRAM_ARCH}/||'`)
0071   {
0072     chomp $file;
0073     my $t="";
0074     my $n="";
0075     if ($file=~/^(plugin|lib)([^\.]+)\.so$/)
0076     {
0077       my $t="LIBRARY";
0078       my $n=$2;
0079       if ($1 eq "plugin"){$t="PLUGIN";}
0080     }
0081     elsif ($file=~/^([^\.]+)\.iglet$/)
0082     {
0083       $t="IGLET";
0084       $n=$1;
0085     }
0086     if ($n ne "")
0087     {
0088       my $found=0;
0089       foreach my $pack (sort keys %$data)
0090       {
0091         if (exists $data->{$pack}{$t}{$n}){$found=1; last;}
0092       }
0093       if (!$found){print "RMissing $t: $n ($file)\n";}
0094     }
0095   }
0096   foreach my $file (`find ${release}/test/$ENV{SCRAM_ARCH} -name "*" -type f | sed 's|${release}/test/$ENV{SCRAM_ARCH}/||'`)
0097   {
0098     chomp $file;
0099     my $found=0;
0100     foreach my $pack (sort keys %$data)
0101     {
0102       if (exists $data->{$pack}{TEST}{$file}){$found=1; last;}
0103     }
0104     if (!$found){print "Missing TEST: $file\n";}
0105   }
0106   foreach my $file (`find ${release}/bin/$ENV{SCRAM_ARCH} -maxdepth 1 -name "*" -type f | sed 's|${release}/bin/$ENV{SCRAM_ARCH}/||'`)
0107   {
0108     chomp $file;
0109     my $found=0;
0110     foreach my $pack (sort keys %$data)
0111     {
0112       if (exists $data->{$pack}{BIN}{$file}){$found=1; last;}
0113       if (exists $data->{$pack}{SCRIPTS}{$file}){$found=1; last;}
0114     }
0115     if (!$found){print "RMissing BIN: $file\n";}
0116   }
0117 }
0118 
0119 sub updateProd ()
0120 {
0121   my $p=shift;
0122   if(exists $projcache->{BUILDTREE}{$p}{CLASS})
0123   {
0124     my $suffix=$projcache->{BUILDTREE}{$p}{SUFFIX};
0125     if($suffix ne ""){return 0;}
0126     my $class=$projcache->{BUILDTREE}{$p}{CLASS};
0127     my $pack=dirname($p);
0128     if (exists $projcache->{BUILDTREE}{$p}{RAWDATA}{content})
0129     {
0130       my $c=$projcache->{BUILDTREE}{$p}{RAWDATA}{content};
0131       if($class=~/^(LIBRARY|CLASSLIB|SEAL_PLATFORM)$/)
0132       {
0133         my $type="LIBRARY";
0134         if (&isPlugin($class,$c)){$type="PLUGIN";}
0135         my $name=$projcache->{BUILDTREE}{$p}{NAME};
0136         if (-f "${release}/src/${p}/iglet.cc"){$data->{$pack}{IGLET}{$name}=1;$type="LIBRARY";}
0137         elsif (($type eq "LIBRARY") && (-f "${release}/src/${p}/classes.h")  && (-f "${release}/src/${p}/classes_def.xml"))
0138         {$data->{$pack}{PLUGIN}{"${name}Capabilities"}=1;}
0139     $data->{$pack}{$type}{$name}=1;
0140         if ((exists $c->{FLAGS}) && (exists $c->{FLAGS}{INSTALL_SCRIPTS}))
0141         {
0142           foreach my $file (@{$c->{FLAGS}{INSTALL_SCRIPTS}}){$data->{$pack}{SCRIPTS}{$file}=1;}
0143         }
0144       }
0145       elsif ($class=~/^(TEST|BIN|PLUGINS|BINARY)$/){&updateProds($pack,$c,$class);}
0146     }
0147     elsif ($class=~/^SCRIPTS$/){&updateScripts($pack,$p);}
0148   }
0149 }
0150 
0151 sub updateScripts()
0152 {
0153   my $pack=shift;
0154   my $dir=shift;
0155   foreach my $f (`ls ${release}/src/$dir`)
0156   {
0157     chomp $f;
0158     $data->{$pack}{SCRIPTS}{$f}=1;
0159   }
0160 }
0161 
0162 sub updateProds()
0163 {
0164   my $pack=shift;
0165   my $c=shift;
0166   my $ptype=shift;
0167   foreach my $t (keys %{$c->{BUILDPRODUCTS}})
0168   {
0169     foreach my $prod (keys %{$c->{BUILDPRODUCTS}{$t}})
0170     {
0171       my $type=&getType($ptype,$t,$c->{BUILDPRODUCTS}{$t}{$prod}{content},$c);
0172       $data->{$pack}{$type}{$prod}=1;
0173       my $c1=$c->{BUILDPRODUCTS}{$t}{$prod}{content};
0174       if ((exists $c1->{FLAGS}) && (exists $c1->{FLAGS}{INSTALL_SCRIPTS}))
0175       {
0176         foreach my $file (@{$c1->{FLAGS}{INSTALL_SCRIPTS}}){$data->{$pack}{SCRIPTS}{$file}=1;}
0177       }
0178     }
0179   }
0180 }
0181 
0182 sub getType()
0183 {
0184   my $ptype=shift;
0185   my $stype=shift;
0186   my $c=shift;
0187   my $c1=shift;
0188   my $type=$stype;
0189   if ($stype eq "BIN")
0190   {
0191     if ($ptype eq "TEST"){$type=$ptype;}
0192   }
0193   elsif($stype eq "LIBRARY")
0194   {
0195     if (&isPlugin($ptype,$c,$c1)==1){$type="PLUGIN";}
0196   }
0197   else{die "ERROR: Unknown type: $stype\n";}
0198   return $type;
0199 }
0200 
0201 sub isPlugin()
0202 {
0203   my $ptype=shift;
0204   my $c=shift;
0205   my $c1 = shift || undef;
0206   my $ok=0;
0207   if($ptype eq "PLUGINS"){$ok=1;}
0208   if ((exists $c->{FLAGS}) && (exists $c->{FLAGS}{EDM_PLUGIN})){$ok=$c->{FLAGS}{EDM_PLUGIN}[0];}
0209   elsif ((defined $c1) && (exists $c1->{FLAGS}) && (exists $c1->{FLAGS}{EDM_PLUGIN})){$ok=$c1->{FLAGS}{EDM_PLUGIN}[0];}
0210   return $ok;
0211 }