Nokia Networks Home

Nokia nmake Product Builder

Quick Links

Related Products

Tool Repository

[ tool index ]

makefiles.pl

Reports information in HTML format about each makefile built.

Download makefiles.pl

Description

makefiles.pl is a Perl script that outputs an HTML document containing a table having a row for each makefile run during the build. The fields displayed in each row are make recursion level, directory relative to a specified root, and makefile execution start and end times. This is a Perl implementation of the makefiles example from the Build Log Overview.

Also see makefiles2.pl below for a simplified version.

Requirements

Perl 5.6 and the XML::LibXML module (exptools users can use /opt/exp/bin/perl).
On RHEL 6.4, install the Perl module by running: yum install perl-XML-LibXML

Usage

perl makefiles.pl filename.xml

Example Command Line

perl makefiles.pl makelog.xml

Example Output

See the Extended Example in the Build Log Overview for details and structure of the example build used.

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd">
<html>
  <head>
    <title>Triggered makefiles</title>
  </head>
  <body>
  <h1>Triggered makefiles</h1>
  <table><tr><th>makelevel</th>
      <th>pwd</th>
      <th>start time</th>
      <th>end time</th>
    </tr><tr><td>0</td><td>src</td><td>09:50:08.42</td><td>09:50:11.58</td></tr><tr><td>1</td><td>src/cmd</td><td>09:50:08.88</td><td>09:50:11.25</td></tr><tr><td>2</td><td>src/cmd/hw</td><td>09:50:09.38</td><td>09:50:10.91</td></tr></table></body>
</html>

Script

This Perl script uses XML::LibXML structures for both the input XML and the output XHTML. The XML input is parsed and stored in variable $doc. The output is built up in variable $html. $html is first initialized to the constant parts of the final document. Then we find the html table element and append a new tr for each makelog element found in the input. For each appended tr we then add four td elements where the text content of each td is set to data extracted from children of the current makelog. The complete html tree is then written to makefiles.html using the XML::LibXML toFile() function.

On RHEL 6.4, access the reference documentation by running "man XML::LibXML".

#! /usr/bin/env perl
use strict;
use warnings;
use XML::LibXML;

# input xml document
my $parser = XML::LibXML->new;
my $doc = $parser->parse_file($ARGV[0]);

# build root - strip directories up to here to show offsets
my $root = "ex1/";

# html output document
$parser = XML::LibXML->new;
my $html = $parser->parse_html_string("<html>
<head>
  <title>Triggered makefiles</title>
</head>
<body>
  <h1>Triggered makefiles</h1>
  <table>
    <tr>
      <th>makelevel</th>
      <th>pwd</th>
      <th>start time</th>
      <th>end time</th>
    </tr>
  </table>
</body>
</html>");
$html->setEncoding("UTF-8");
my $table = ($html->findnodes("/html/body/table"))[0];

# for each makelog section in the input xml add a table row to the output
# containing makelevel, pwd, stime and etime
foreach my $ml ($doc->findnodes("//makelog")) {
    my $tr = $table->addNewChild('','tr');
    $tr->appendTextChild('td', $ml->findvalue("makeinfo/makelevel"));
    (my $dir = $ml->findvalue("makeinfo/pwd")) =~ s/^.*$root//;
    $tr->appendTextChild('td', $dir);
    $tr->appendTextChild('td', substr($ml->findvalue("makeinfo/stime"),11,11));
    $tr->appendTextChild('td', substr($ml->findvalue("makeinfo/etime"),11,11));
}

# write html to a file
$html->toFile('makefiles.html', 1);

makefiles2.pl

A simplified version of makefiles.pl that prints the html document rather than building the structure with XML::LibXML. The usage and requirements are the same as makefiles.pl.

Download makefiles2.pl

Script

This Perl script uses XML::LibXML structures for the input XML. The XML input is parsed and stored in variable $doc. The output is printed as a set of here documents. For each makelog element found in the input we add a table row with a new tr element and then add four td elements where the text content of each td is set to data extracted from children of the current makelog.

On RHEL 6.4, access the reference documentation by running "man XML::LibXML".

#! /usr/bin/env perl
use strict;
use warnings;
use XML::LibXML;

my $parser = XML::LibXML->new;
my $doc = $parser->parse_file($ARGV[0]);
my $root = "ex1/";

print <<END;
<html>
<head>
  <title>Triggered makefiles</title>
</head>
<body>
  <h1>Triggered makefiles</h1>
  <table>
    <tr>
      <th>makelevel</th>
      <th>pwd</th>
      <th>start time</th>
      <th>end time</th>
    </tr>
END

foreach my $ml ($doc->findnodes("//makelog")) {
    (my $dir = $ml->findvalue("makeinfo/pwd")) =~ s/^.*$root//;
    print <<END
    <tr>
      <td>@{[ $ml->findvalue("makeinfo/makelevel") ]}</td>
      <td>$dir</td>
      <td>@{[ substr($ml->findvalue("makeinfo/stime"),11,11) ]}</td>
      <td>@{[ substr($ml->findvalue("makeinfo/etime"),11,11) ]}</td>
    </tr>
END
}

print <<END;
  </table>
</body>
</html>
END
Last Update: Friday,12-Aug-2016 12:16:41 EDT