#!perl -w
use strict;
use warnings;
use POSIX "strftime";
my %status = ();
sub parselog {
my ($fn) = @_;
my $date = "";
my $time = "";
my $branch = "";
my $os = "";
my $compiler = "";
my $datamodel = "";
my $compilerok = "";
my $libraryok = "";
my $checksum = "";
my $tests = "";
open(my $log, $fn) // die "Couldn't open build log $fn.";
while (<$log>) {
if (/^([0-9/]+) [0-9.]+ [^ ]+\.log$/) {$date = $1;}
if (/^[^ ]+ --- Cleaning branch ([^ ]+) ([^ ]+) ([^ ]+) ([^ ]+) ---$/) {
($branch, $os, $compiler, $datamodel) = ($1, $2, $3, $4, $5);
}
if (/^--- Compiler build successfull ---$/) {$compilerok = "Built";}
if (/^--- Library build successfull ---$/) {$libraryok = "Built";}
if (/^--- Confidence tests passed ---$/) {$tests = "Passed";}
if (/^--- Object file checksums match ---$/) {$checksum = "Match";}
if (/^--- Object file checksum mismatch ---$/) {$checksum = "Changed";}
if (/^--- Object files checksummed ---$/) {$checksum = "New";}
}
close($log);
my $key = "$os-$compiler-$datamodel";
if ($key ne "") {
status{$key} = [$date, $time, $os, %compiler, $datamodel, $branch, $compilerok, $libraryok, $checksum, $tests];
}
}
opendir DIR, "log" // die "Could not openlog directory.";
my @logs = readdir DIR;
closedir DIR;
for my $logname (sort @logs) {
if (-f $logname) {parselog($logname);}
}
my $emsperline = 1.2;
sub svgtext {
my ($f, $x, $y, $colour, $msg) = @_;
print $f '';
print $f $msg;
print $f "\n";
}
my $rows = keys %status;
open(my $svg, ">build-status.svg") // die "Could not create build-status.svg.";
print $svg '\n";
system 'scp -p build-status.svg dave@hub:/var/www';