Back to home page

Project CMSSW displayed by LXR

 
 

    


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

0001 #!/usr/bin/env perl
0002 use File::Basename;
0003 use lib dirname($0);
0004 use SCRAMGenUtils;
0005 use Getopt::Long;
0006 $|=1;
0007 
0008 my $pwd=`/bin/pwd`; chomp $pwd; $pwd=&SCRAMGenUtils::fixPath($pwd);
0009 
0010 if(&GetOptions(
0011            "--release=s",\$release,
0012            "--product=s",\$product,
0013            "--help",\$help,
0014               ) eq ""){print STDERR "#Wrong arguments.\n"; &usage_msg();}
0015 
0016 
0017 if (defined $help){&usage_msg();}
0018 if (!defined $product){&usage_msg();}
0019 
0020 my $pname=$product;
0021 if ($product=~/\.so$/)
0022 {
0023   if($product=~/^lib(.+)\.so$/){$pname=$1;}
0024   elsif($product=~/^plugin(.+)(Capabilities|)\.so$/){$pname=$1;}
0025 }
0026 elsif($product=~/^(.+)\.iglet$/){$pname=$1;}
0027 
0028 if (!defined $release){$release=$pwd;}
0029 $release=&SCRAMGenUtils::scramReleaseTop($release);
0030 if($release eq ""){print STDERR "ERROR: Please run this script from a SCRAM-based area or use --release <path> option.\n"; exit 1;}
0031 
0032 &SCRAMGenUtils::init ($release);
0033 my $arch=&SCRAMGenUtils::getScramArch();
0034 
0035 my $cache={};
0036 $cache=&initCache($release,$arch);
0037 
0038 if (exists $cache->{PRODS}{$pname}){print "$product => ",$cache->{PRODS}{$pname},"\n";}
0039 else{die "ERROR: No product found with name $pname ($product)\n";}
0040 
0041 exit 0;
0042 
0043 sub usage_msg()
0044 {
0045   my $s=basename($0);
0046   print "Usage: $s --product <product> [--release <path>] [--help]\n\n",
0047         "e.g.\n",
0048         "  $s --release <path> --product libCore.so\n",
0049         "  $s --release <path> --product libFWCoreFramework.so\n",
0050         "  $s --release <path> --product lcg_EnvironmentAuthenticationService\n",
0051         "  $s --release <path> --product cmsRun\n";
0052         "  $s --release <path> -p FWCoreUtilities\n";
0053   exit 0;
0054 }
0055 
0056 ##########################################################################
0057 # Read Tools and Project cache of all externals and SCRAM-based projects #
0058 ##########################################################################
0059 sub initCache()
0060 {
0061   my ($release,$arch)=@_;
0062   my $cache={};
0063   $cache->{Caches}{TOOLS}=&SCRAMGenUtils::readCache("${release}/.SCRAM/${arch}/ToolCache.db.gz");
0064   foreach my $t (keys %{$cache->{Caches}{TOOLS}{SETUP}})
0065   {
0066     my $sbase="";
0067     if ($cache->{Caches}{TOOLS}{SETUP}{$t}{SCRAM_PROJECT} == 1)
0068     {
0069       my $bv=uc($t)."_BASE";
0070       $sbase=$cache->{Caches}{TOOLS}{SETUP}{$t}{$bv};
0071     }
0072     elsif ($t eq "self"){$sbase=$release;}
0073     if ($sbase ne "")
0074     {
0075       $cache->{Caches}{$t}=&SCRAMGenUtils::readCache("${sbase}/.SCRAM/${arch}/ProjectCache.db.gz");
0076       foreach my $d (keys %{$cache->{Caches}{$t}{BUILDTREE}}){&readPkgInfo($d,$t,$cache);}
0077       if ($t eq "self")
0078       {
0079         my $releaseTop=&SCRAMGenUtils::getFromEnvironmentFile("RELEASETOP",$release);
0080     if ($releaseTop ne "")
0081     {
0082       $cache->{Caches}{$t}=&SCRAMGenUtils::readCache("${releaseTop}/.SCRAM/${arch}/ProjectCache.db.gz");
0083       foreach my $d (keys %{$cache->{Caches}{$t}{BUILDTREE}}){&readPkgInfo($d,$t,$cache);}
0084     }
0085       }
0086       delete $cache->{Caches}{$t};
0087     }
0088     else{&readToolsInfo(lc($t),$cache);}
0089   }
0090   delete $cache->{Caches};
0091   return $cache;
0092 }
0093 
0094 sub readPkgInfo ()
0095 {
0096   my ($d,$t,$cache)=@_;
0097   my $c=$cache->{Caches}{$t}{BUILDTREE}{$d};
0098   my $suffix=$c->{SUFFIX};
0099   if($suffix ne ""){return;}
0100   my $class=$c->{CLASS};
0101   my $name=$c->{NAME};
0102   my $c1=$c->{RAWDATA}{content};
0103   if($class=~/^(LIBRARY|CLASSLIB|SEAL_PLATFORM)$/o){$cache->{PRODS}{$name}=dirname($d);}
0104   elsif($class=~/^(TEST|BIN|PLUGINS|BINARY)$/o){&addProds($c1,$d,$cache);}
0105   elsif($class=~/^(PYTHON|SUBSYSTEM|DATA_INSTALL|SCRIPTS|PROJECT|IVS|PACKAGE)$/o){return;}
0106   else{print STDERR "WARNING: UNKNOW TYPE $class in $t/$d\n";}
0107 }
0108 
0109 sub addProds()
0110 {
0111   my ($c,$pack,$cache)=@_;
0112   if (!defined $c){return;}
0113   if (exists $c->{BUILDPRODUCTS})
0114   {
0115     foreach my $t (keys %{$c->{BUILDPRODUCTS}})
0116     {
0117       foreach my $p (keys %{$c->{BUILDPRODUCTS}{$t}}){$cache->{PRODS}{$p}=$pack;}
0118     }
0119   }
0120 }
0121 
0122 sub readToolsInfo()
0123 {
0124   my ($t,$cache)=@_;
0125   if (exists $cache->{Caches}{TOOLS}{SETUP}{$t}{LIB})
0126   {
0127     foreach my $l (@{$cache->{Caches}{TOOLS}{SETUP}{$t}{LIB}}){$cache->{PRODS}{$l}=$t;}
0128   }
0129 }