Nokia Networks Home

Nokia nmake Product Builder

Quick Links

Related Products

Tool Repository

[ tool index ]

makefiles.py

Reports information in HTML format about each makefile built.

Download makefiles.py

Description

makefiles.py is a Python 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 Python implementation of the makefiles example from the Build Log Overview.

Requirements

Python 2.6 (exptools users can use /opt/exp/python/python2.6/bin/python)

Usage

python targets.py filename.xml

Example Command Line

python makefiles.py makelog.xml

Example Output

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

<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>16:11:44.65</td><td>16:11:49.21</td></tr><tr><td>1</td><td>src/cmd</td><td>16:11:45.12</td><td>16:11:48.87</td></tr><tr><td>2</td><td>src/cmd/hw</td><td>16:11:45.67</td><td>16:11:48.55</td></tr></table>
    </body>
</html>

Script

This Python script uses ElementTree structures for both the input XML and the output XHTML. The XML input is parsed and stored in variable buildlog. 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 ElementTree write method.

#! /usr/bin/env python
import sys
import re
import xml.etree.cElementTree as ET
root = "ex1/"
pat = re.compile("^.*" + root)
buildlog = ET.parse(sys.argv[1])
html = ET.XML("""<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>""")
table = html.find("./body/table")
for ml in buildlog.findall("//makelog"):
    tr = ET.SubElement(table, "tr")
    ET.SubElement(tr, "td").text = ml.findtext("makeinfo/makelevel")
    ET.SubElement(tr, "td").text = pat.sub("", ml.findtext("makeinfo/pwd"))
    ET.SubElement(tr, "td").text = ml.findtext("makeinfo/stime")[11:22]
    ET.SubElement(tr, "td").text = ml.findtext("makeinfo/etime")[11:22]
ET.ElementTree(html).write("makefiles.html")
Last Update: Friday,12-Aug-2016 12:16:44 EDT