buildframework/helium/tools/compile/scanbuildlog.pl
changeset 1 be27ed110b50
equal deleted inserted replaced
0:044383f39525 1:be27ed110b50
       
     1 #!perl -w
       
     2 
       
     3 #============================================================================ 
       
     4 #Name        : scanbuildlog.pl 
       
     5 #Part of     : Helium 
       
     6 
       
     7 #Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
       
     8 #All rights reserved.
       
     9 #This component and the accompanying materials are made available
       
    10 #under the terms of the License "Eclipse Public License v1.0"
       
    11 #which accompanies this distribution, and is available
       
    12 #at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
    13 #
       
    14 #Initial Contributors:
       
    15 #Nokia Corporation - initial contribution.
       
    16 #
       
    17 #Contributors:
       
    18 #
       
    19 #Description: 
       
    20 #============================================================================
       
    21 
       
    22 # ==============================================================================
       
    23 #  %name:          scanbuildlog.pl %
       
    24 #  Part of:        juno_build
       
    25 #
       
    26 #  %version:	   1 %
       
    27 #  %date_modified: Mon Feb 06 17:21:13 2006 %
       
    28 #
       
    29 #  See POD text at the end of this file for usage details.
       
    30 # ==============================================================================
       
    31 
       
    32 use strict;
       
    33 use Getopt::Long;
       
    34 use Pod::Usage;
       
    35 use XML::Simple;
       
    36 use lib "$ENV{'BUILD_DRIVE'}\\epoc32\\tools";
       
    37 use Scanlog;
       
    38 use XML::Parser::Expat;
       
    39 
       
    40 my $help        = 0;
       
    41 my $man         = 0;
       
    42 my $unique      = 0;
       
    43 my $logfilename = '';
       
    44 
       
    45 GetOptions('unique' => \$unique,
       
    46            'log=s'  => \$logfilename,
       
    47            'man'    => \$man,
       
    48            'help|?' => \$help)
       
    49   or pod2usage(2);
       
    50 pod2usage(1) if $help;
       
    51 pod2usage(-exitstatus => 0, -verbose => 2) if $man;
       
    52 $logfilename = shift unless $logfilename;
       
    53 my $logfile;
       
    54 
       
    55 if ($logfilename)
       
    56 {
       
    57     open(LOGFILE, $logfilename) or die("Can't open '$logfilename': $!\n");
       
    58     $logfile = \*LOGFILE;
       
    59 }
       
    60 else
       
    61 {
       
    62     $logfile = \*STDIN;
       
    63 }
       
    64 
       
    65 #<!DOCTYPE logfile SYSTEM "logfile.dtd">
       
    66 #<?xml-stylesheet type="text/xsl" href="logfile.xsl"?>
       
    67 print <<EOT;
       
    68 <?xml version="1.0" encoding="ascii"?>
       
    69 EOT
       
    70 print("<logfile name=\"$logfilename\">\n");
       
    71 
       
    72 my %logentry  = ();
       
    73 my $phase     = '';
       
    74 my $component = '';
       
    75 my $parser = new XML::Parser::Expat;
       
    76 
       
    77 while (<$logfile>)
       
    78 {
       
    79     chomp;
       
    80     next if Scanlog::CheckForIgnore($_);
       
    81 
       
    82     ($phase = $1) =~ s/\\/\\\\/ and next
       
    83       if /^=== (.+) started ... ... .. (..):(..):(..)/;
       
    84     $phase = $1 and next if /^=== (.+) started ... ... .. (..):(..):(..)/;
       
    85     $component = $1 and next if $phase && /^=== $phase == (\S+)/;
       
    86     if ($phase && /^=== $phase finished ... ... .. (..):(..):(..)/)
       
    87     {
       
    88         $component = '';
       
    89         next;
       
    90     }
       
    91 
       
    92     my $logrec = {line    => $.,
       
    93                   content => $parser->xml_escape($_)};
       
    94 
       
    95     $logrec->{severity} = 'info'
       
    96       if Scanlog::CheckForMigrationNotes($_)
       
    97       or Scanlog::CheckForRemarks($_);
       
    98 
       
    99       if ( Scanlog::CheckForErrors($_)
       
   100       or Scanlog::CheckForNotBuilt($_)
       
   101       or Scanlog::CheckForMissing($_) )
       
   102     {
       
   103         $logrec->{severity} = 'error';
       
   104     }
       
   105     $logrec->{severity} = 'warn' if Scanlog::CheckForWarnings($_);
       
   106     next unless $logrec->{severity};
       
   107 
       
   108     print XMLout($logrec, rootname => 'logentry', noescape => 0);
       
   109 }
       
   110 
       
   111 print("</logfile>\n");
       
   112 
       
   113 __END__
       
   114 
       
   115 =head1 NAME
       
   116 
       
   117 scanbuildlog - Scan EBS build log for errors and warnings
       
   118 
       
   119 =head1 SYNOPSIS
       
   120 
       
   121 perl scanbuildlog.pl [-h] | -l <log file>
       
   122 
       
   123 =head1 OPTIONS
       
   124 
       
   125 =over 8
       
   126 
       
   127 =item B<-help>
       
   128 
       
   129 Print a brief help message and exits.
       
   130 
       
   131 =item B<-man>
       
   132 
       
   133 Prints the manual page and exits.
       
   134 
       
   135 =item B<-l>
       
   136 
       
   137 Specify the log file to parse.
       
   138 
       
   139 =back
       
   140 
       
   141 =head1 DESCRIPTION
       
   142 
       
   143 Prints out a summary of the errors, warnings and informational
       
   144 messages found in the log file in an XML format conforming to the
       
   145 following DTD:
       
   146 
       
   147  <!ELEMENT logfile (logentry*)>
       
   148  <!ELEMENT logentry (#PCDATA)>
       
   149  <!ATTLIST logentry
       
   150    severity (error|warn|info) #REQUIRED
       
   151    line     CDATA             #REQUIRED
       
   152    errfile  CDATA             #IMPLIED
       
   153    errline  CDATA             #IMPLIED>
       
   154 
       
   155 =head1 SEE ALSO
       
   156 
       
   157 =cut