Sleds/masterbuild/updateSLOCpage.pl

121 lines
3.0 KiB
Perl

#!/usr/bin/perl
# Update SLOCcount page...
my $outputFilename = "";
my @gitRemoteBranches = ();
my $avgSalary = 120000;
for ($i = 0; $i < @ARGV; ++$i)
{
if ($ARGV[$i] eq "-restricted")
{
$outputFilename = "slocCountFR.html";
@gitRemoteBranches = `git ls-remote --heads ssh://git.sl.int/git-restricted`;
}
elsif (($ARGV[$i] eq "-salary") && (($i + 1) < @ARGV))
{
++$i;
$avgSalary = $ARGV[$i];
}
}
if ($outputFilename eq "")
{
$outputFilename = "slocCount.html";
@gitRemoteBranches = `git ls-remote --heads ssh://git.sl.int/git`;
}
my @remoteBranches = ();
#my @remoteResBranches = ();
foreach my $remoteBranch (@gitRemoteBranches)
{
chomp $remoteBranch;
$remoteBranch =~ s/^.*refs\/heads\///g;
if (($remoteBranch =~ /^develop/) ||
($remoteBranch =~ /^master/) ||
($remoteBranch =~ /^release/))
{
push @remoteBranches, $remoteBranch;
}
}
#foreach my $remoteResBranch (@gitRemoteRestrictedBranches)
#{
# chomp $remoteResBranch;
# $remoteResBranch =~ s/^.*refs\/heads\///g;
#
# if (($remoteResBranch =~ /^develop/) ||
# ($remoteResBranch =~ /^master/) ||
# ($remoteResBranch =~ /^release/))
# {
# push @remoteResBranches, $remoteResBranch;
# }
#}
my $contentsBlock = "";
my $linkBlock = "";
if (open(SLOC_FILE, ">$outputFilename"))
{
print SLOC_FILE <<ENDOFHEADER;
<html>
<head>
<title>Sequence Logic Source Lines of Code</title>
</head>
<body>
ENDOFHEADER
print SLOC_FILE "<h3>Date generated: ";
print SLOC_FILE `date`;
print SLOC_FILE "</h3>\n";
foreach my $remoteBranch (@remoteBranches)
{
$contentsBlock .= " <li><a href=\"#$remoteBranch\">$remoteBranch</a></li>";
$linkBlock .= " <a name=\"$remoteBranch\"><h2>Branch: $remoteBranch</h2></a>\n";
`git checkout $remoteBranch`;
`git pull`;
my @projectList = `ls -1`;
my $projects = "";
foreach $project (@projectList)
{
chomp $project;
if (($project ne "cppboost") &&
($project ne "SLSync") &&
($project ne "thirdparty"))
{
$projects .= " $project";
}
}
print "Found projects: $projects\n";
my @slocOutput = `sloccount --personcost $avgSalary $projects`;
my $startOutput = 0;
#print SLOC_FILE "<pre>\n";
$linkBlock .= "<pre>\n";
foreach $slocOutLine (@slocOutput)
{
chomp $slocOutLine;
if (($startOutput == 0) && ($slocOutLine ne "Computing results."))
{
next;
}
$startOutput = 1;
#print SLOC_FILE "$slocOutLine\n";
$linkBlock .= "$slocOutLine\n";
}
#print SLOC_FILE "</pre>\n";
$linkBlock .= "</pre>\n<p>\n";
}
print SLOC_FILE $contentsBlock;
print SLOC_FILE $linkBlock;
print SLOC_FILE <<ENDOFFOOTER;
</body>
</html>
ENDOFFOOTER
close SLOC_FILE;
}