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 
0006 $|=1;
0007 
0008 my $bf1=shift;
0009 my $bf2=shift;
0010 my $html=shift || 0;
0011 my @output=();
0012 
0013 if(!defined $bf1){die "Usage: $0 <buildfile1> <buildfile2>\n";}
0014 if(!defined $bf2){die "Usage: $0 <buildfile1> <buildfile2>\n";}
0015 
0016 if(!-f $bf1){die "No such file \"$bf1\".";}
0017 if(!-f $bf2){die "No such file \"$bf2\".";}
0018 
0019 my $rel=`/bin/pwd`; chomp $rel; $rel=&SCRAMGenUtils::fixPath($rel);
0020 if ($bf1!~/^\//){$bf1=&SCRAMGenUtils::fixPath("${rel}/${bf1}");}
0021 if ($bf2!~/^\//){$bf2=&SCRAMGenUtils::fixPath("${rel}/${bf2}");}
0022 
0023 my $buildfile=$bf2; $buildfile=~s/^$rel\/src\///;
0024 
0025 $rel=&SCRAMGenUtils::scramReleaseTop($rel);
0026 &SCRAMGenUtils::init($rel);
0027 my $refbf1=&SCRAMGenUtils::readBuildFile($bf1);
0028 my $refbf2=&SCRAMGenUtils::readBuildFile($bf2);
0029 &findDiff($refbf1,$refbf2);
0030 exit 0;
0031 
0032 sub FixToolName()
0033 {
0034   my $name=shift;
0035   my $tool=lc($name);
0036   if (-e "${rel}/.SCRAM/$ENV{SCRAM_ARCH}/timestamps/${tool}"){return $tool;}
0037   return $name;
0038 }
0039 
0040 sub printHead()
0041 {
0042   if ($html)
0043   {
0044     print "<html><body><center><h2>Difference for $buildfile</h2></center><pre>\n";
0045   }
0046 }
0047 
0048 sub printTail()
0049 {
0050   if ($html){print "</pre></body></html>\n";}
0051 }
0052 
0053 sub printLine ()
0054 {
0055   my $line=shift;
0056   if ($html)
0057   {
0058     my $tag=shift || "";
0059     if ($tag){print "<$tag>";}
0060     print "$line\n";
0061     if ($tag){print "</$tag>";}
0062   }
0063   else{print "$line\n";}
0064 }
0065 
0066 sub findDiff ()
0067 {
0068   my $bf1=shift;
0069   my $bf2=shift;
0070   my $u1={}; my $u2={};
0071   my $hasprod=0;
0072   for(my $i=1;$i<=2;$i++)
0073   {
0074     my $u={};
0075     my $bf=$bf1;
0076     if ($i==2){$bf=$bf2;}
0077     foreach my $type ("","bin", "library")
0078     {
0079       my $data={};    
0080       if ($type eq ""){&getAllUse($bf,$data,$u);}
0081       elsif(exists $bf->{$type})
0082       {
0083     foreach my $name (keys %{$bf->{$type}})
0084         {
0085           $hasprod=1;
0086       $data->{prodname}=$name;
0087       $data->{prodtype}=$type;
0088       &getAllUse($bf,$data,$u);
0089         }
0090       }
0091     }
0092     if ($i==1){$u1=$u;}
0093     else{$u2=$u;}
0094   }
0095   my $diff={};
0096   foreach my $t (keys %$u1)
0097   {
0098     foreach my $p (keys %{$u1->{$t}})
0099     {
0100       foreach my $u (keys %{$u1->{$t}{$p}})
0101       {
0102     if((exists $u2->{$t}) && (exists $u2->{$t}{$p}) && (exists $u2->{$t}{$p}{$u})){delete $u1->{$t}{$p}{$u}; delete $u2->{$t}{$p}{$u};}
0103     else{$diff->{$t}{$p}{"+"}{$u}=1;}
0104       }
0105     }
0106   }
0107   foreach my $t (keys %$u2)
0108   {
0109     foreach my $p (keys %{$u2->{$t}})
0110     {
0111       foreach my $u (keys %{$u2->{$t}{$p}}){$diff->{$t}{$p}{"-"}{$u}=1;}
0112     }
0113   }
0114   &printHead();
0115   foreach my $t (sort keys %$diff)
0116   {
0117     foreach my $p (sort keys %{$diff->{$t}})
0118     {
0119       if ($hasprod)
0120       {
0121         if ($t eq "common"){&printLine("* Common Non-Export Section:","b");}
0122         else{&printLine("* $p:","b");}
0123       }
0124       else{&printLine("* Non-Export Section:","b");}
0125       foreach my $a (sort keys %{$diff->{$t}{$p}})
0126       {
0127     foreach my $u (sort keys %{$diff->{$t}{$p}{$a}})
0128     {
0129       print "  $a $u\n";
0130     }
0131       }
0132       print "\n\n";
0133     }
0134   }
0135   &printTail();
0136 }
0137 
0138 sub getAllUse ()
0139 {
0140   my $bf=shift;
0141   my $data=shift;
0142   my $use=shift;
0143   my $f=&findTag($data,$bf,"use");
0144   my $type="common"; my $name="all";
0145   if (exists $data->{prodname}){$type="prods"; $name=$data->{prodname};}
0146   $use{$type}{$name}={};
0147   foreach my $c (@{$f})
0148   {
0149     foreach my $u (keys %{$c->{use}}){$use->{$type}{$name}{&FixToolName($u)}=1;}
0150   }
0151 }
0152 
0153 sub findTag ()
0154 {
0155   my $data=shift;
0156   my $bf=shift;
0157   my $tag=shift;
0158   my $d=shift || [];
0159   my $pt=$data->{prodtype};
0160   my $pn=$data->{prodname};
0161   if ($pt eq ""){if(exists $bf->{$tag}){push @{$d},$bf;}}
0162   elsif((exists $bf->{$pt}) && (exists $bf->{$pt}{$pn}) && (exists $bf->{$pt}{$pn}{deps}))
0163   {&findTag({},$bf->{$pt}{$pn}{deps},$tag,$d);}
0164   return $d;
0165 }