annotate bitten/build/ctools.py @ 163:634be6cbb808

Flip the switch: Bitten is now BSD-licensed.
author cmlenz
date Sat, 27 Aug 2005 07:58:12 +0000
parents 553784dccf97
children 60af98d66f11
rev   line source
5
738a0ae251f6 Added GPL boilerplate.
cmlenz
parents: 4
diff changeset
1 # -*- coding: iso8859-1 -*-
738a0ae251f6 Added GPL boilerplate.
cmlenz
parents: 4
diff changeset
2 #
738a0ae251f6 Added GPL boilerplate.
cmlenz
parents: 4
diff changeset
3 # Copyright (C) 2005 Christopher Lenz <cmlenz@gmx.de>
163
634be6cbb808 Flip the switch: Bitten is now BSD-licensed.
cmlenz
parents: 150
diff changeset
4 # All rights reserved.
5
738a0ae251f6 Added GPL boilerplate.
cmlenz
parents: 4
diff changeset
5 #
163
634be6cbb808 Flip the switch: Bitten is now BSD-licensed.
cmlenz
parents: 150
diff changeset
6 # This software is licensed as described in the file COPYING, which
634be6cbb808 Flip the switch: Bitten is now BSD-licensed.
cmlenz
parents: 150
diff changeset
7 # you should have received as part of this distribution. The terms
634be6cbb808 Flip the switch: Bitten is now BSD-licensed.
cmlenz
parents: 150
diff changeset
8 # are also available at http://bitten.cmlenz.net/wiki/License.
5
738a0ae251f6 Added GPL boilerplate.
cmlenz
parents: 4
diff changeset
9
109
5bf22bb87915 Transmit build log and generated data back to the build master in XML format. Closes #23.
cmlenz
parents: 105
diff changeset
10 import logging
5bf22bb87915 Transmit build log and generated data back to the build master in XML format. Closes #23.
cmlenz
parents: 105
diff changeset
11
5bf22bb87915 Transmit build log and generated data back to the build master in XML format. Closes #23.
cmlenz
parents: 105
diff changeset
12 from bitten.util import xmlio
57
ef78d71667ad Added simple helper class for executing commandline programs.
cmlenz
parents: 21
diff changeset
13 from bitten.util.cmdline import Commandline
4
196009657e5e Simplify the recipe commands interface:
cmlenz
parents:
diff changeset
14
109
5bf22bb87915 Transmit build log and generated data back to the build master in XML format. Closes #23.
cmlenz
parents: 105
diff changeset
15 log = logging.getLogger('bitten.build.ctools')
5bf22bb87915 Transmit build log and generated data back to the build master in XML format. Closes #23.
cmlenz
parents: 105
diff changeset
16
146
affd91b4c6fb Add a `<python:exec>` recipe command so that things like Pylint can be executed without using a Makefile.
cmlenz
parents: 131
diff changeset
17 def make(ctxt, target=None, file_=None, jobs=None, keep_going=False):
4
196009657e5e Simplify the recipe commands interface:
cmlenz
parents:
diff changeset
18 """Execute a Makefile target."""
109
5bf22bb87915 Transmit build log and generated data back to the build master in XML format. Closes #23.
cmlenz
parents: 105
diff changeset
19 args = ['--directory', ctxt.basedir]
146
affd91b4c6fb Add a `<python:exec>` recipe command so that things like Pylint can be executed without using a Makefile.
cmlenz
parents: 131
diff changeset
20 if file_:
affd91b4c6fb Add a `<python:exec>` recipe command so that things like Pylint can be executed without using a Makefile.
cmlenz
parents: 131
diff changeset
21 args += ['--file', ctxt.resolve(file_)]
60
055a6c666fa8 * Pass a {{{Context}}} object to recipe commands as the first argument. Currently this only has the basedir, but will be extended to also provide output recording etc.
cmlenz
parents: 57
diff changeset
22 if jobs:
109
5bf22bb87915 Transmit build log and generated data back to the build master in XML format. Closes #23.
cmlenz
parents: 105
diff changeset
23 args += ['--jobs', int(jobs)]
60
055a6c666fa8 * Pass a {{{Context}}} object to recipe commands as the first argument. Currently this only has the basedir, but will be extended to also provide output recording etc.
cmlenz
parents: 57
diff changeset
24 if keep_going:
109
5bf22bb87915 Transmit build log and generated data back to the build master in XML format. Closes #23.
cmlenz
parents: 105
diff changeset
25 args.append('--keep-going')
5bf22bb87915 Transmit build log and generated data back to the build master in XML format. Closes #23.
cmlenz
parents: 105
diff changeset
26 if target:
5bf22bb87915 Transmit build log and generated data back to the build master in XML format. Closes #23.
cmlenz
parents: 105
diff changeset
27 args.append(target)
5bf22bb87915 Transmit build log and generated data back to the build master in XML format. Closes #23.
cmlenz
parents: 105
diff changeset
28
115
16d69eb6e047 Add support for XML fragments to the {{{xmlio}}} module, so that build output and reports don't need to be nested in a meaningless element (such as {{{<log type="distutils"><messages><message ...>}}}).
cmlenz
parents: 109
diff changeset
29 log_elem = xmlio.Fragment()
60
055a6c666fa8 * Pass a {{{Context}}} object to recipe commands as the first argument. Currently this only has the basedir, but will be extended to also provide output recording etc.
cmlenz
parents: 57
diff changeset
30 cmdline = Commandline('make', args)
146
affd91b4c6fb Add a `<python:exec>` recipe command so that things like Pylint can be executed without using a Makefile.
cmlenz
parents: 131
diff changeset
31 for out, err in cmdline.execute():
affd91b4c6fb Add a `<python:exec>` recipe command so that things like Pylint can be executed without using a Makefile.
cmlenz
parents: 131
diff changeset
32 if out is not None:
109
5bf22bb87915 Transmit build log and generated data back to the build master in XML format. Closes #23.
cmlenz
parents: 105
diff changeset
33 log.info(out)
150
553784dccf97 Factored out common program execution logic into <sh:exec> command, which is used by <python:exec>.
cmlenz
parents: 146
diff changeset
34 xmlio.SubElement(log_elem, 'message', level='info')[out]
146
affd91b4c6fb Add a `<python:exec>` recipe command so that things like Pylint can be executed without using a Makefile.
cmlenz
parents: 131
diff changeset
35 if err is not None:
109
5bf22bb87915 Transmit build log and generated data back to the build master in XML format. Closes #23.
cmlenz
parents: 105
diff changeset
36 log.error(err)
150
553784dccf97 Factored out common program execution logic into <sh:exec> command, which is used by <python:exec>.
cmlenz
parents: 146
diff changeset
37 xmlio.SubElement(log_elem, 'message', level='error')[err]
109
5bf22bb87915 Transmit build log and generated data back to the build master in XML format. Closes #23.
cmlenz
parents: 105
diff changeset
38 ctxt.log(log_elem)
150
553784dccf97 Factored out common program execution logic into <sh:exec> command, which is used by <python:exec>.
cmlenz
parents: 146
diff changeset
39
57
ef78d71667ad Added simple helper class for executing commandline programs.
cmlenz
parents: 21
diff changeset
40 if cmdline.returncode != 0:
131
3ed8f568f60a Fix error handling so that reports are still generated even if a command has failed.
cmlenz
parents: 115
diff changeset
41 ctxt.error('make failed (%s)' % cmdline.returncode)
Copyright (C) 2012-2017 Edgewall Software