|
1 <?xml version="1.0" encoding="UTF-8"?> |
|
2 <!-- |
|
3 ============================================================================ |
|
4 Name : common.ant.xml |
|
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 <project name="common" xmlns:hlm="http://www.nokia.com/helium" xmlns:cs="antlib:com.puppycrawl.tools.checkstyle"> |
|
24 <description> |
|
25 Common targets for all helium tools. |
|
26 </description> |
|
27 |
|
28 <import file="logging.ant.xml"/> |
|
29 |
|
30 <!--======================================================================= |
|
31 Preset definitions --> |
|
32 <presetdef name="preset.exec"> |
|
33 <exec> |
|
34 <!-- Note the extra ':' required at the start of the value. This |
|
35 is required for the Symbian tools to match the env variable. --> |
|
36 <env key="ARMV5VER" value=":${arm.compiler.version}"/> |
|
37 |
|
38 <!-- Tools configuration --> |
|
39 <env key="LOGONSERVER" value="${logon.server}"/> |
|
40 </exec> |
|
41 </presetdef> |
|
42 |
|
43 |
|
44 <presetdef name="preset.mail"> |
|
45 <mail from="${email.from}" messagemimetype="text/html" mailhost="${email.smtp.server}" failonerror="false"/> |
|
46 </presetdef> |
|
47 |
|
48 |
|
49 <!-- Outputs diagnostics information for the Helium configuration. |
|
50 |
|
51 This contains: |
|
52 * The current configuration of properties. |
|
53 * The Ant diagnostics information. |
|
54 --> |
|
55 <target name="diagnostics" description="Print diagnostics about Helium"> |
|
56 <echo> |
|
57 -------- Helium diagnostics report -------- |
|
58 Helium version ${helium.version} |
|
59 |
|
60 ------------------------------------------- |
|
61 Helium configuration |
|
62 ------------------------------------------- |
|
63 </echo> |
|
64 <runtarget target="config"/> |
|
65 <diagnostics/> |
|
66 <hlm:database/> |
|
67 </target> |
|
68 |
|
69 <!-- Sets the properties that are dependent on build.number -property. |
|
70 |
|
71 The properties are: |
|
72 * build.version |
|
73 * build.id |
|
74 * prep.build.dir |
|
75 * publish.dir |
|
76 * publish.release.dir |
|
77 --> |
|
78 <target name="build-number"> |
|
79 <fail unless="build.number" message="build.number property not defined" /> |
|
80 <property name="build.version" value="${core.build.version}.${build.number}"/> |
|
81 <property name="build.id" value="${build.name}_${build.version}"/> |
|
82 <property name="prep.build.dir" location="${prep.root.dir}/${build.id}"/> |
|
83 <property name="publish.dir" location="${publish.root.dir}/${build.name}/builds/${core.build.version}/${build.id}"/> |
|
84 <property name="publish.release.dir" location="${publish.root.dir}/${build.name}/releases/${core.build.version}/${build.id}"/> |
|
85 </target> |
|
86 |
|
87 <!-- Variable set to configuration tool. |
|
88 Currently supported configuration tool arguments are |
|
89 argument : ant variable name |
|
90 |
|
91 -master_conf : master_conf |
|
92 -confml : confml |
|
93 -impl : impl |
|
94 -iby : iby |
|
95 -ignore_errors : keepgoing(true - uses -ignore_errors, otherwise not, setting |
|
96 true generates cenrep incase of errors, and signals has to be configured to stop the build |
|
97 in case of errors). |
|
98 --> |
|
99 <hlm:argSet id="cnftool.refid"> |
|
100 <hlm:arg name="path" value="${build.drive}/s60/tools/toolsextensions/configurationtool" /> |
|
101 <hlm:arg name="master_conf" value="s60.confml" /> |
|
102 <hlm:arg name="confml" value="\epoc32\rom\config\confml_data\s60" /> |
|
103 <hlm:arg name="impl" value="\epoc32\rom\config\confml_data\s60" /> |
|
104 <hlm:arg name="iby" value="\epoc32\rom\include\" /> |
|
105 <hlm:arg name="keepgoing" value="false" /> |
|
106 </hlm:argSet> |
|
107 |
|
108 <!-- Target to run configtool. See cnftool.refid for config tool parameters--> |
|
109 <target name="configtool" description="target to run configtool, refid is for mcl, overridden by changing cnftool.refid"> |
|
110 <hlm:toolMacro name="configuration"> |
|
111 <hlm:toolvarset refid="cnftool.refid"/> |
|
112 </hlm:toolMacro> |
|
113 </target> |
|
114 |
|
115 <!-- Finds the build manager's (current user) email address from their username. --> |
|
116 <target name="lookup-email" if="email.ldap.server"> |
|
117 <if> |
|
118 <not> |
|
119 <isset property="email.from"/> |
|
120 </not> |
|
121 <then> |
|
122 <hlm:ldap url="${email.ldap.server}" rootdn="${email.ldap.rootdn}" filter="uid=${env.USERNAME}" outputproperty="email.from" key="mail"/> |
|
123 </then> |
|
124 </if> |
|
125 </target> |
|
126 |
|
127 <!-- To authenticate the noe password (read from .netrc file) for ${env.USERNAME}. --> |
|
128 <target name="authenticate-user" if="authenticate.noe.user"> |
|
129 <runtarget target="noe-password"/> |
|
130 |
|
131 <hlm:ldapauthenticate url="${email.ldap.server}" |
|
132 rootdn="${email.ldap.rootdn}" |
|
133 searchdn="${ldap.organization.unit.rootdn}, ${ldap.people.rootdn}" |
|
134 filter="uid=${env.USERNAME}" |
|
135 outputproperty="is.authentication.sucess" |
|
136 key="employeeNumber" |
|
137 password="${noe.password}" |
|
138 /> |
|
139 <if> |
|
140 <istrue value="${is.authentication.sucess}" /> |
|
141 <then> |
|
142 <echo>noe authentication for user ${env.USERNAME} is success.</echo> |
|
143 </then> |
|
144 <else> |
|
145 <fail message="noe authentication for user ${env.USERNAME} is failed."/> |
|
146 </else> |
|
147 </if> |
|
148 </target> |
|
149 |
|
150 <!-- Utility target to test mail sending from Helium. --> |
|
151 <target name="check-mail" depends="lookup-email"> |
|
152 <preset.mail tolist="${email.from}" subject="mail-test"/> |
|
153 </target> |
|
154 |
|
155 <!-- A simple test target that prints a simple message --> |
|
156 <target name="hello"> |
|
157 <echo message="Hello!"/> |
|
158 <if> |
|
159 <isset property="build.number"/> |
|
160 <then> |
|
161 <echo message="Ant libs found OK"/> |
|
162 </then> |
|
163 </if> |
|
164 </target> |
|
165 |
|
166 |
|
167 <!-- A simple test target that prints a simple message and is dependant upon another target to show how ANT works--> |
|
168 <target name="hi" depends="hello"/> |
|
169 |
|
170 |
|
171 <!-- A simple test target that prints a simple message --> |
|
172 <target name="fail"> |
|
173 <fail message="Test build failure."/> |
|
174 </target> |
|
175 |
|
176 |
|
177 <!-- Print out the build properties --> |
|
178 <target name="config" description="Print out the build properties"> |
|
179 <echoproperties> |
|
180 <propertyset negate="true"> |
|
181 <propertyref prefix="java."/> |
|
182 <propertyref prefix="sun."/> |
|
183 <propertyref prefix="awt."/> |
|
184 <propertyset refid="password.list.ref"/> |
|
185 </propertyset> |
|
186 </echoproperties> |
|
187 </target> |
|
188 |
|
189 <!-- Prints out target dependencies. |
|
190 |
|
191 A <tt>target</tt> property should be defined on the command line to specify which target's dependencies to analyse. |
|
192 |
|
193 Example: <tt>hlm -Dtarget=compile-main deps</tt> |
|
194 --> |
|
195 <target name="deps"> |
|
196 <fail unless="target" message="target property not defined" /> |
|
197 <hlm:dependencies target="${target}" format="nested"/> |
|
198 </target> |
|
199 |
|
200 |
|
201 <!-- Displays target dependencies in a text box. |
|
202 |
|
203 A <tt>target</tt> property should be defined on the command line to specify which target's dependencies to analyse. --> |
|
204 <target name="execlist"> |
|
205 <fail unless="target" message="target property not defined" /> |
|
206 <record name="execlist.txt" action="start" emacsmode="true"/> |
|
207 <hlm:dependencies target="${target}" format="executable"/> |
|
208 <record name="execlist.txt" action="stop"/> |
|
209 <exec executable="notepad.exe"> |
|
210 <arg value="execlist.txt"/> |
|
211 </exec> |
|
212 <delete file="execlist.txt"/> |
|
213 </target> |
|
214 |
|
215 |
|
216 <!-- Prints out Helium help dialog --> |
|
217 <target name="help"> |
|
218 <if> |
|
219 <not> |
|
220 <available file="${database.file}"/> |
|
221 </not> |
|
222 <then> |
|
223 <antcall target="database"/> |
|
224 </then> |
|
225 </if> |
|
226 <if> |
|
227 <isset property="help.target"/> |
|
228 <then> |
|
229 <fmpp sourcefile="${helium.dir}/tools/common/templates/help_text.txt.ftl" outputfile="build/help_text.txt" quiet="true"> |
|
230 <data expandProperties="yes"> |
|
231 xml: xml(${database.file}) |
|
232 helpTarget: ${help.target} |
|
233 </data> |
|
234 </fmpp> |
|
235 <loadfile srcfile="build/help_text.txt" property="help.text"/> |
|
236 <echo>${help.text}</echo> |
|
237 </then> |
|
238 <else> |
|
239 <echo> |
|
240 Usage: |
|
241 hlm [target] [-D<property>=<value>] [-f <ant_build_file>] [-h] [-p -v] |
|
242 |
|
243 [target] Run Ant target |
|
244 [-D<property>=<value>] Set an Ant property |
|
245 [-f <ant_build_file>] Use another Ant build file |
|
246 [-h] Print Ant help text |
|
247 [-p -v] List all Ant targets |
|
248 |
|
249 Variable properties for helium: |
|
250 -Dsysdef.configuration=default set build configuration, default value is 'default' |
|
251 -Dbuild.system=ebs set build system, default value is 'ebs' |
|
252 - possible values are 'ebs' and 'ec' |
|
253 |
|
254 Usage examples: |
|
255 hlm build the default build target |
|
256 hlm -Dbuild.system=ec-helium use electric cloud build system |
|
257 </echo> |
|
258 </else> |
|
259 </if> |
|
260 </target> |
|
261 |
|
262 |
|
263 <!-- Automates deletion of old work areas. |
|
264 |
|
265 <tt>prep.root.dir</tt> is the path where work areas are typically stored. This command |
|
266 scans that directory for sub-directories that match a pattern based on the build name. |
|
267 A dialog is displayed listing the directories as checkboxes. Check each build area |
|
268 directory to delete it. |
|
269 --> |
|
270 <target name="clean-pc"> |
|
271 <dirset id="prep.build.dirs" dir="${prep.root.dir}"> |
|
272 <include name="*_*"/> |
|
273 <include name="subcon_*_*"/> |
|
274 </dirset> |
|
275 <pathconvert pathsep="," property="prep.build.dirs.path"> |
|
276 <dirset refid="prep.build.dirs"/> |
|
277 </pathconvert> |
|
278 <fmpp sourceFile="${helium.dir}/tools/common/templates/clean_pc.ant.ftl" |
|
279 outputFile="${cache.dir}/clean_pc.ant.xml"> |
|
280 <data expandProperties="yes"> |
|
281 prepRootDir: ${prep.root.dir} |
|
282 buildAreaDirs: [${prep.build.dirs.path}] |
|
283 </data> |
|
284 </fmpp> |
|
285 <ant antfile="${cache.dir}/clean_pc.ant.xml"/> |
|
286 <delete file="${cache.dir}/clean_pc.ant.xml"/> |
|
287 </target> |
|
288 |
|
289 |
|
290 <!-- Displays the current version of Helium --> |
|
291 <target name="version" description="Displays the current version of Helium"> |
|
292 <echo message="Helium version: ${helium.version}" /> |
|
293 </target> |
|
294 |
|
295 |
|
296 <!-- Creates a database of the current configuration. --> |
|
297 <target name="create-data-model-db"> |
|
298 <echoproperties format="text" destfile="${build.cache.dir}/database.txt"> |
|
299 <propertyset negate="true"> |
|
300 <propertyref prefix="ant."/> |
|
301 <propertyref prefix="os."/> |
|
302 <propertyref prefix="file."/> |
|
303 <propertyref prefix="java."/> |
|
304 <propertyref prefix="sun."/> |
|
305 <propertyref prefix="awt."/> |
|
306 <propertyref prefix="env."/> |
|
307 <propertyref prefix="user."/> |
|
308 <propertyref prefix="line."/> |
|
309 <propertyref prefix="path."/> |
|
310 <propertyref prefix="python."/> |
|
311 <propertyref prefix="TODAY"/> |
|
312 <propertyref prefix="DSTAMP"/> |
|
313 <propertyref prefix="TSTAMP"/> |
|
314 <propertyref prefix="sig"/> |
|
315 <propertyref name="basedir"/> |
|
316 <propertyset refid="password.list.ref"/> |
|
317 </propertyset> |
|
318 </echoproperties> |
|
319 </target> |
|
320 |
|
321 <!--Macro to Assert Ant configuration against a Helium data model.--> |
|
322 <macrodef name="checkDataModelMacro" uri="http://www.nokia.com/helium"> |
|
323 <attribute name="datamodel"/> |
|
324 <attribute name="config"/> |
|
325 <attribute name="assert" default="false"/> |
|
326 <sequential> |
|
327 <hlm:python> |
|
328 import logging |
|
329 import ant |
|
330 import configuration |
|
331 import configuration_model |
|
332 |
|
333 datamodel_file = ant.get_property(r'@{datamodel}') |
|
334 config_file = ant.get_property(r'@{config}') |
|
335 model = configuration_model.DataModel(str(datamodel_file)) |
|
336 db_file = open(str(config_file), 'r') |
|
337 config = configuration.PropertiesConfiguration(db_file) |
|
338 |
|
339 items = model.validate_config(config) |
|
340 |
|
341 logging.basicConfig(level=logging.INFO, format='%(levelname)s: %(message)s') |
|
342 for item in items: |
|
343 item.log(logging.getLogger()) |
|
344 |
|
345 assert_attr = ant.get_property(r'@{assert}') |
|
346 if assert_attr != None and str(assert_attr) == 'true': |
|
347 for item in items: |
|
348 if isinstance(item, configuration_model.MissingFromDataModelItem): |
|
349 raise Exception(str(item)) |
|
350 </hlm:python> |
|
351 </sequential> |
|
352 </macrodef> |
|
353 |
|
354 |
|
355 <!-- Checks the Ant configuration against a Helium data model. --> |
|
356 <target name="check" depends="create-data-model-db"> |
|
357 <xslt in="${data.model.file}" out="${data.model.parsed}" style="${data.model.xsl}"/> |
|
358 <hlm:checkDataModelMacro datamodel="${data.model.parsed}" config="${build.cache.dir}/database.txt"/> |
|
359 </target> |
|
360 |
|
361 <!--Assert Ant configuration against a Helium data model.--> |
|
362 <target name="assert-datamodel-correct" depends="create-data-model-db"> |
|
363 <xslt in="${data.model.file}" out="${data.model.parsed}" style="${data.model.xsl}"/> |
|
364 <hlm:checkDataModelMacro datamodel="${data.model.parsed}" config="${build.cache.dir}/database.txt" assert="true"/> |
|
365 </target> |
|
366 |
|
367 |
|
368 <!-- Generates an Ant XML database file. |
|
369 |
|
370 This lists all the targets and information about them. --> |
|
371 <target name="database"> |
|
372 <!-- Projects with no targets or non project files --> |
|
373 <fileset id="database.extra.files" dir="${helium.dir}"> |
|
374 <include name="tools/**/*.antlib.xml"/> |
|
375 <include name="tools/**/*.ant.xml"/> |
|
376 <include name="extensions/nokia/tools/**/*.antlib.xml"/> |
|
377 <include name="extensions/nokia/tools/**/*.ant.xml"/> |
|
378 <include name="extensions/nokia/*.ant.xml"/> |
|
379 <include name="config/signaling_config_default.ant.xml"/> |
|
380 </fileset> |
|
381 |
|
382 <mkdir dir="${helium.build.dir}"/> |
|
383 <property name="home.files.only" value="false"/> |
|
384 <hlm:database output="${database.file}" refid="database.extra.files" homeFilesOnly="${home.files.only}"/> |
|
385 </target> |
|
386 |
|
387 |
|
388 <!-- Looks for lint-style issues with the Ant files in Helium, using the antlint task. --> |
|
389 <target name="antlint" depends="check"> |
|
390 <delete dir="${helium.build.dir}/jep"/> |
|
391 <delete dir="${helium.build.dir}/python"/> |
|
392 <delete dir="${helium.build.dir}/beanshell"/> |
|
393 <delete file="${helium.build.dir}/test_jython.xml"/> |
|
394 <hlm:antlint configfile="${helium.dir}/config/antlint_config.xml"> |
|
395 <fileset id="antlint.files" dir="${helium.dir}"> |
|
396 <include name="*.ant.xml"/> |
|
397 <include name="tools/**/*.ant.xml"/> |
|
398 <include name="tools/**/build.xml"/> |
|
399 <include name="tools/**/*.antlib.xml"/> |
|
400 <include name="config/**/*.ant.xml"/> |
|
401 <include name="config/**/build.xml"/> |
|
402 <include name="config/**/*.antlib.xml"/> |
|
403 <include name="external/helium-antlib/**/*.ant.xml"/> |
|
404 <include name="external/helium-antlib/**/build.xml"/> |
|
405 <include name="external/helium-antlib/**/*.antlib.xml"/> |
|
406 <include name="extensions/nokia/**/build.xml"/> |
|
407 <include name="extensions/nokia/**/*.antlib.xml"/> |
|
408 <include name="extensions/nokia/**/*.ant.xml"/> |
|
409 </fileset> |
|
410 </hlm:antlint> |
|
411 |
|
412 <fileset id="jep.files" dir="${helium.build.dir}"> |
|
413 <include name="jep/**/*.py"/> |
|
414 <include name="python/**/*.py"/> |
|
415 </fileset> |
|
416 <antcall target="pylint" inheritRefs="true"> |
|
417 <reference refid="jep.files" torefid="python.files" /> |
|
418 </antcall> |
|
419 <cs:checkstyle config="config/java_checkstyle_config.xml"> |
|
420 <fileset dir="${helium.build.dir}/beanshell" includes="**/*.java"/> |
|
421 <formatter type="plain"/> |
|
422 </cs:checkstyle> |
|
423 |
|
424 <for param="file"> |
|
425 <path> |
|
426 <fileset dir="${helium.dir}"> |
|
427 <include name="**/*.ftl"/> |
|
428 <include name="**/*.rst"/> |
|
429 <exclude name="**/*.mk.ftl"/> |
|
430 <exclude name="build/**/*"/> |
|
431 </fileset> |
|
432 </path> |
|
433 <sequential> |
|
434 <loadfile srcfile="@{file}" property="tabs.in.ftl"> |
|
435 <filterchain> |
|
436 <linecontainsregexp> |
|
437 <regexp pattern="\t"/> |
|
438 </linecontainsregexp> |
|
439 </filterchain> |
|
440 </loadfile> |
|
441 <fail if="tabs.in.ftl" message="@{file} has tabs" /> |
|
442 </sequential> |
|
443 </for> |
|
444 </target> |
|
445 |
|
446 |
|
447 <!-- This target can be use to clean up after a build finished or failed. |
|
448 |
|
449 This contains: |
|
450 * Unsubst build drive if the build finished. |
|
451 * Can be used to do other cleanup stuff too. |
|
452 --> |
|
453 <target name="cleanup-all"> |
|
454 <!-- unsubst build drive after build finished if the property "unsubst.after.build" defined as "yes" --> |
|
455 <if> |
|
456 <and> |
|
457 <isset property="unsubst.after.build"/> |
|
458 <istrue value="${unsubst.after.build}" /> |
|
459 </and> |
|
460 <then> |
|
461 <echo> Removing build drive: ${build.drive} </echo> |
|
462 <hlm:unsubst drive="${build.drive}"/> |
|
463 </then> |
|
464 </if> |
|
465 </target> |
|
466 |
|
467 |
|
468 <!-- validate only requires properties at startup --> |
|
469 <target name="validate-at-startup" depends="create-data-model-db"> |
|
470 <hlm:python> |
|
471 import logging |
|
472 import configuration |
|
473 import configuration_model |
|
474 |
|
475 model = configuration_model.DataModel(r'${data.model.file}') |
|
476 db_file = open(r'${build.cache.dir}/database.txt', 'r') |
|
477 config = configuration.PropertiesConfiguration(db_file) |
|
478 |
|
479 items = model.validate_config_at_startup(config) |
|
480 |
|
481 _checks_logger = logging.getLogger('config_check') |
|
482 _handler = logging.StreamHandler() |
|
483 _handler.setFormatter(logging.Formatter('%(levelname)s: %(message)s')) |
|
484 _checks_logger.addHandler(_handler) |
|
485 _checks_logger.setLevel(logging.INFO) |
|
486 for item in items: |
|
487 item.log(_checks_logger) |
|
488 </hlm:python> |
|
489 </target> |
|
490 |
|
491 |
|
492 <!-- Macro test target. --> |
|
493 <target name="macro-test"> |
|
494 <hlm:fooMacro/> |
|
495 </target> |
|
496 |
|
497 </project> |
|
498 |
|
499 |
|
500 |
|
501 |