Mercurial > bitten > bitten-test
annotate scripts/build.py @ 194:8dbddcd0ef00
Fix target platform matching when a rule references a property not provided by the build slave. Closes #45.
author | cmlenz |
---|---|
date | Mon, 12 Sep 2005 16:01:08 +0000 |
parents | 634be6cbb808 |
children | e6ddca1e5712 |
rev | line source |
---|---|
0 | 1 #!/usr/bin/env python |
5 | 2 # -*- coding: iso8859-1 -*- |
3 # | |
4 # Copyright (C) 2005 Christopher Lenz <cmlenz@gmx.de> | |
163 | 5 # All rights reserved. |
5 | 6 # |
163 | 7 # This software is licensed as described in the file COPYING, which |
8 # you should have received as part of this distribution. The terms | |
9 # are also available at http://bitten.cmlenz.net/wiki/License. | |
0 | 10 |
103
f1baf05a49dd
* Strip extra line separators from recipe command output on windows. Closes #25.
cmlenz
parents:
72
diff
changeset
|
11 import itertools |
f1baf05a49dd
* Strip extra line separators from recipe command output on windows. Closes #25.
cmlenz
parents:
72
diff
changeset
|
12 import logging |
4 | 13 import sys |
0 | 14 |
61
47ab019508dd
Moved {{{BuildError}}} class into package {{{bitten.build}}}.
cmlenz
parents:
60
diff
changeset
|
15 from bitten.build import BuildError |
4 | 16 from bitten.recipe import Recipe |
148
f3f5895e373c
Fixes to problems in recipe handling introduced in [155].
cmlenz
parents:
144
diff
changeset
|
17 from bitten.util import xmlio |
4 | 18 |
103
f1baf05a49dd
* Strip extra line separators from recipe command output on windows. Closes #25.
cmlenz
parents:
72
diff
changeset
|
19 def main(): |
f1baf05a49dd
* Strip extra line separators from recipe command output on windows. Closes #25.
cmlenz
parents:
72
diff
changeset
|
20 from bitten import __version__ as VERSION |
f1baf05a49dd
* Strip extra line separators from recipe command output on windows. Closes #25.
cmlenz
parents:
72
diff
changeset
|
21 from optparse import OptionParser |
4 | 22 |
103
f1baf05a49dd
* Strip extra line separators from recipe command output on windows. Closes #25.
cmlenz
parents:
72
diff
changeset
|
23 parser = OptionParser(usage='usage: %prog [options] [step1] [step2] ...', |
f1baf05a49dd
* Strip extra line separators from recipe command output on windows. Closes #25.
cmlenz
parents:
72
diff
changeset
|
24 version='%%prog %s' % VERSION) |
148
f3f5895e373c
Fixes to problems in recipe handling introduced in [155].
cmlenz
parents:
144
diff
changeset
|
25 parser.add_option('-f', '--recipe-file', action='store', dest='recipe_file', |
f3f5895e373c
Fixes to problems in recipe handling introduced in [155].
cmlenz
parents:
144
diff
changeset
|
26 metavar='FILE', help='read build recipe from FILE') |
144
76dea27af878
* Make the `<python:unittest>` command strip the base dir from file names in the report. Fixes #42.
cmlenz
parents:
131
diff
changeset
|
27 parser.add_option('--print-reports', action='store_const', |
76dea27af878
* Make the `<python:unittest>` command strip the base dir from file names in the report. Fixes #42.
cmlenz
parents:
131
diff
changeset
|
28 dest='print_reports', const=True, |
76dea27af878
* Make the `<python:unittest>` command strip the base dir from file names in the report. Fixes #42.
cmlenz
parents:
131
diff
changeset
|
29 help='print generated reports') |
103
f1baf05a49dd
* Strip extra line separators from recipe command output on windows. Closes #25.
cmlenz
parents:
72
diff
changeset
|
30 parser.add_option('-v', '--verbose', action='store_const', dest='loglevel', |
f1baf05a49dd
* Strip extra line separators from recipe command output on windows. Closes #25.
cmlenz
parents:
72
diff
changeset
|
31 const=logging.DEBUG, help='print as much as possible') |
f1baf05a49dd
* Strip extra line separators from recipe command output on windows. Closes #25.
cmlenz
parents:
72
diff
changeset
|
32 parser.add_option('-q', '--quiet', action='store_const', dest='loglevel', |
f1baf05a49dd
* Strip extra line separators from recipe command output on windows. Closes #25.
cmlenz
parents:
72
diff
changeset
|
33 const=logging.ERROR, help='print as little as possible') |
148
f3f5895e373c
Fixes to problems in recipe handling introduced in [155].
cmlenz
parents:
144
diff
changeset
|
34 parser.set_defaults(loglevel=logging.INFO, recipe_file='recipe.xml') |
103
f1baf05a49dd
* Strip extra line separators from recipe command output on windows. Closes #25.
cmlenz
parents:
72
diff
changeset
|
35 options, args = parser.parse_args() |
f1baf05a49dd
* Strip extra line separators from recipe command output on windows. Closes #25.
cmlenz
parents:
72
diff
changeset
|
36 |
f1baf05a49dd
* Strip extra line separators from recipe command output on windows. Closes #25.
cmlenz
parents:
72
diff
changeset
|
37 log = logging.getLogger('bitten') |
f1baf05a49dd
* Strip extra line separators from recipe command output on windows. Closes #25.
cmlenz
parents:
72
diff
changeset
|
38 log.setLevel(options.loglevel) |
f1baf05a49dd
* Strip extra line separators from recipe command output on windows. Closes #25.
cmlenz
parents:
72
diff
changeset
|
39 handler = logging.StreamHandler() |
f1baf05a49dd
* Strip extra line separators from recipe command output on windows. Closes #25.
cmlenz
parents:
72
diff
changeset
|
40 handler.setLevel(options.loglevel) |
109
5bf22bb87915
Transmit build log and generated data back to the build master in XML format. Closes #23.
cmlenz
parents:
103
diff
changeset
|
41 formatter = logging.Formatter('%(message)s') |
103
f1baf05a49dd
* Strip extra line separators from recipe command output on windows. Closes #25.
cmlenz
parents:
72
diff
changeset
|
42 handler.setFormatter(formatter) |
f1baf05a49dd
* Strip extra line separators from recipe command output on windows. Closes #25.
cmlenz
parents:
72
diff
changeset
|
43 log.addHandler(handler) |
f1baf05a49dd
* Strip extra line separators from recipe command output on windows. Closes #25.
cmlenz
parents:
72
diff
changeset
|
44 |
f1baf05a49dd
* Strip extra line separators from recipe command output on windows. Closes #25.
cmlenz
parents:
72
diff
changeset
|
45 steps_to_run = dict([(step, False) for step in args]) |
148
f3f5895e373c
Fixes to problems in recipe handling introduced in [155].
cmlenz
parents:
144
diff
changeset
|
46 |
f3f5895e373c
Fixes to problems in recipe handling introduced in [155].
cmlenz
parents:
144
diff
changeset
|
47 recipe_file = file(options.recipe_file, 'r') |
f3f5895e373c
Fixes to problems in recipe handling introduced in [155].
cmlenz
parents:
144
diff
changeset
|
48 try: |
f3f5895e373c
Fixes to problems in recipe handling introduced in [155].
cmlenz
parents:
144
diff
changeset
|
49 recipe = Recipe(xmlio.parse(recipe_file)) |
f3f5895e373c
Fixes to problems in recipe handling introduced in [155].
cmlenz
parents:
144
diff
changeset
|
50 for step in recipe: |
f3f5895e373c
Fixes to problems in recipe handling introduced in [155].
cmlenz
parents:
144
diff
changeset
|
51 if not steps_to_run or step.id in steps_to_run: |
f3f5895e373c
Fixes to problems in recipe handling introduced in [155].
cmlenz
parents:
144
diff
changeset
|
52 print |
153 | 53 print '-->', step.id |
148
f3f5895e373c
Fixes to problems in recipe handling introduced in [155].
cmlenz
parents:
144
diff
changeset
|
54 for type, function, output in step.execute(recipe.ctxt): |
f3f5895e373c
Fixes to problems in recipe handling introduced in [155].
cmlenz
parents:
144
diff
changeset
|
55 if type == Recipe.ERROR: |
f3f5895e373c
Fixes to problems in recipe handling introduced in [155].
cmlenz
parents:
144
diff
changeset
|
56 log.error('Failure in step "%s": %s', step.id, output) |
f3f5895e373c
Fixes to problems in recipe handling introduced in [155].
cmlenz
parents:
144
diff
changeset
|
57 elif type == Recipe.REPORT and options.print_reports: |
f3f5895e373c
Fixes to problems in recipe handling introduced in [155].
cmlenz
parents:
144
diff
changeset
|
58 output.write(sys.stdout, newlines=True) |
f3f5895e373c
Fixes to problems in recipe handling introduced in [155].
cmlenz
parents:
144
diff
changeset
|
59 if step.id in steps_to_run: |
f3f5895e373c
Fixes to problems in recipe handling introduced in [155].
cmlenz
parents:
144
diff
changeset
|
60 steps_to_run[step.id] = True |
f3f5895e373c
Fixes to problems in recipe handling introduced in [155].
cmlenz
parents:
144
diff
changeset
|
61 finally: |
f3f5895e373c
Fixes to problems in recipe handling introduced in [155].
cmlenz
parents:
144
diff
changeset
|
62 recipe_file.close() |
0 | 63 |
64 if __name__ == '__main__': | |
4 | 65 try: |
103
f1baf05a49dd
* Strip extra line separators from recipe command output on windows. Closes #25.
cmlenz
parents:
72
diff
changeset
|
66 main() |
4 | 67 except BuildError, e: |
153 | 68 print |
8 | 69 print>>sys.stderr, 'FAILED: %s' % e |
4 | 70 sys.exit(-1) |
153 | 71 print |
8 | 72 print 'SUCCESS' |