annotate scripts/build.py @ 72:b2d371dac270

Allow individual steps of a recipe to be marked as optional, i.e. that an error in such a step should not mean that the build failed.
author cmlenz
date Fri, 01 Jul 2005 11:09:12 +0000
parents 47ab019508dd
children f1baf05a49dd
rev   line source
0
0b2a3581c48d Import initial ''bitten'' source.
cmlenz
parents:
diff changeset
1 #!/usr/bin/env python
5
738a0ae251f6 Added GPL boilerplate.
cmlenz
parents: 4
diff changeset
2 # -*- coding: iso8859-1 -*-
738a0ae251f6 Added GPL boilerplate.
cmlenz
parents: 4
diff changeset
3 #
738a0ae251f6 Added GPL boilerplate.
cmlenz
parents: 4
diff changeset
4 # Copyright (C) 2005 Christopher Lenz <cmlenz@gmx.de>
738a0ae251f6 Added GPL boilerplate.
cmlenz
parents: 4
diff changeset
5 #
738a0ae251f6 Added GPL boilerplate.
cmlenz
parents: 4
diff changeset
6 # Bitten is free software; you can redistribute it and/or
738a0ae251f6 Added GPL boilerplate.
cmlenz
parents: 4
diff changeset
7 # modify it under the terms of the GNU General Public License as
738a0ae251f6 Added GPL boilerplate.
cmlenz
parents: 4
diff changeset
8 # published by the Free Software Foundation; either version 2 of the
738a0ae251f6 Added GPL boilerplate.
cmlenz
parents: 4
diff changeset
9 # License, or (at your option) any later version.
738a0ae251f6 Added GPL boilerplate.
cmlenz
parents: 4
diff changeset
10 #
738a0ae251f6 Added GPL boilerplate.
cmlenz
parents: 4
diff changeset
11 # Trac is distributed in the hope that it will be useful,
738a0ae251f6 Added GPL boilerplate.
cmlenz
parents: 4
diff changeset
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
738a0ae251f6 Added GPL boilerplate.
cmlenz
parents: 4
diff changeset
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
738a0ae251f6 Added GPL boilerplate.
cmlenz
parents: 4
diff changeset
14 # General Public License for more details.
738a0ae251f6 Added GPL boilerplate.
cmlenz
parents: 4
diff changeset
15 #
738a0ae251f6 Added GPL boilerplate.
cmlenz
parents: 4
diff changeset
16 # You should have received a copy of the GNU General Public License
738a0ae251f6 Added GPL boilerplate.
cmlenz
parents: 4
diff changeset
17 # along with this program; if not, write to the Free Software
738a0ae251f6 Added GPL boilerplate.
cmlenz
parents: 4
diff changeset
18 # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
738a0ae251f6 Added GPL boilerplate.
cmlenz
parents: 4
diff changeset
19 #
738a0ae251f6 Added GPL boilerplate.
cmlenz
parents: 4
diff changeset
20 # Author: Christopher Lenz <cmlenz@gmx.de>
0
0b2a3581c48d Import initial ''bitten'' source.
cmlenz
parents:
diff changeset
21
4
196009657e5e Simplify the recipe commands interface:
cmlenz
parents: 3
diff changeset
22 import sys
0
0b2a3581c48d Import initial ''bitten'' source.
cmlenz
parents:
diff changeset
23
61
47ab019508dd Moved {{{BuildError}}} class into package {{{bitten.build}}}.
cmlenz
parents: 60
diff changeset
24 from bitten.build import BuildError
4
196009657e5e Simplify the recipe commands interface:
cmlenz
parents: 3
diff changeset
25 from bitten.recipe import Recipe
196009657e5e Simplify the recipe commands interface:
cmlenz
parents: 3
diff changeset
26
196009657e5e Simplify the recipe commands interface:
cmlenz
parents: 3
diff changeset
27 def build():
196009657e5e Simplify the recipe commands interface:
cmlenz
parents: 3
diff changeset
28 step_id = None
196009657e5e Simplify the recipe commands interface:
cmlenz
parents: 3
diff changeset
29 if len(sys.argv) > 1:
196009657e5e Simplify the recipe commands interface:
cmlenz
parents: 3
diff changeset
30 step_id = sys.argv[1]
196009657e5e Simplify the recipe commands interface:
cmlenz
parents: 3
diff changeset
31
196009657e5e Simplify the recipe commands interface:
cmlenz
parents: 3
diff changeset
32 recipe = Recipe()
196009657e5e Simplify the recipe commands interface:
cmlenz
parents: 3
diff changeset
33 steps_run = []
196009657e5e Simplify the recipe commands interface:
cmlenz
parents: 3
diff changeset
34 for step in recipe:
196009657e5e Simplify the recipe commands interface:
cmlenz
parents: 3
diff changeset
35 if not step_id or step.id == step_id:
196009657e5e Simplify the recipe commands interface:
cmlenz
parents: 3
diff changeset
36 print '-->', step.description or step.id
72
b2d371dac270 Allow individual steps of a recipe to be marked as optional, i.e. that an error in such a step should not mean that the build failed.
cmlenz
parents: 61
diff changeset
37 step.execute(recipe.ctxt)
4
196009657e5e Simplify the recipe commands interface:
cmlenz
parents: 3
diff changeset
38 print
196009657e5e Simplify the recipe commands interface:
cmlenz
parents: 3
diff changeset
39 steps_run.append(step.id)
196009657e5e Simplify the recipe commands interface:
cmlenz
parents: 3
diff changeset
40
196009657e5e Simplify the recipe commands interface:
cmlenz
parents: 3
diff changeset
41 if step_id and not step_id in steps_run:
8
45d7bfe64d00 Slightly improved implementation of the python tools.
cmlenz
parents: 5
diff changeset
42 raise BuildError, 'Recipe has no step named "%s"' % step_id
0
0b2a3581c48d Import initial ''bitten'' source.
cmlenz
parents:
diff changeset
43
0b2a3581c48d Import initial ''bitten'' source.
cmlenz
parents:
diff changeset
44 if __name__ == '__main__':
4
196009657e5e Simplify the recipe commands interface:
cmlenz
parents: 3
diff changeset
45 try:
196009657e5e Simplify the recipe commands interface:
cmlenz
parents: 3
diff changeset
46 build()
196009657e5e Simplify the recipe commands interface:
cmlenz
parents: 3
diff changeset
47 except BuildError, e:
8
45d7bfe64d00 Slightly improved implementation of the python tools.
cmlenz
parents: 5
diff changeset
48 print>>sys.stderr, 'FAILED: %s' % e
4
196009657e5e Simplify the recipe commands interface:
cmlenz
parents: 3
diff changeset
49 sys.exit(-1)
8
45d7bfe64d00 Slightly improved implementation of the python tools.
cmlenz
parents: 5
diff changeset
50 print 'SUCCESS'
Copyright (C) 2012-2017 Edgewall Software