Nokia Networks Home

Nokia nmake Product Builder

Quick Links

Related Products

Tool Repository

[ tool index ]

makefiles.groovy

Reports information in HTML format about each makefile built.

Download makefiles.groovy

Description

makefiles.groovy is a Groovy 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 an example Groovy script from the Build Log Overview.

Requirements

groovy. Groovy is a general purpose dynamic scripting language for the JVM that provides strong support for processing XML. Since Groovy runs on the JVM, scripts may be run on platforms supporting the JVM including Linux, Solaris, and Windows.

Usage

groovy targets.groovy filename.xml

Example Command Line

groovy makefiles.groovy 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>17:11:21.14</td>
        <td>17:11:21.58</td>
      </tr>
      <tr>
        <td>1</td>
        <td>src/cmd</td>
        <td>17:11:21.20</td>
        <td>17:11:21.55</td>
      </tr>
      <tr>
        <td>2</td>
        <td>src/cmd/hw</td>
        <td>17:11:21.25</td>
        <td>17:11:21.51</td>
      </tr>
    </table>
  </body>

Script

The XML parsing and filtering steps are similar to those in targets.groovy. The HTML is generated using a Groovy MarkupBuilder. The Groovy builder mechanism provides an easy and elegant way to build nested structures without need for complex APIs. For example, the expression head() { title('Triggered makefiles') } creates an HTML head element containing a title element containing the textual content "Triggered makefiles". Since builder expressions are standard Groovy syntax, Groovy filtering and iteration constructs such as bl.'**'.grep{it.name() == 'makelog'}.each { ... } may appear intermixed with literal HTML tag generation. This allows looping over input data structures to generate variable parts of the HTML document. See also the Build Log Overview.

def root = 'ex1/'
def bl = new XmlSlurper().parse(args[0])
def bldr = new groovy.xml.MarkupBuilder()
bldr.html {
	head() { title('Triggered makefiles') }
	body() {
		h1('Triggered makefiles')
		table() {
			tr() {
				th('makelevel')
				th('pwd')
				th('start time')
				th('end time')
			}
			bl.'**'.grep{it.name() == 'makelog'}.each { ml ->
				tr() {
					td(ml.makeinfo.makelevel)
					td(ml.makeinfo.pwd.text().replaceFirst(~/.*$root/, ''))
					td(ml.makeinfo.stime.text()[11..21])
					td(ml.makeinfo.etime.text()[11..21])
				}
			}
		}
	}
}
Last Update: Friday,12-Aug-2016 12:16:39 EDT