changeset 487:fbd5bc3c2a48

At long last, applying patch supplied by Xavier Duret for #207. Closes #207. Thanks for the patch.
author wbell
date Sun, 13 Apr 2008 19:45:17 +0000
parents ab4f39c2fae5
children 9b3d97297201
files bitten/build/ctools.py doc/commands.txt
diffstat 2 files changed, 39 insertions(+), 9 deletions(-) [+]
line wrap: on
line diff
--- a/bitten/build/ctools.py
+++ b/bitten/build/ctools.py
@@ -14,6 +14,7 @@
 import re
 import os
 import posixpath
+import shlex
 
 from bitten.build import CommandLine, FileSet
 from bitten.util import xmlio
@@ -94,7 +95,7 @@
     if returncode != 0:
         ctxt.error('autoreconf failed (%s)' % returncode)
 
-def make(ctxt, target=None, file_=None, keep_going=False):
+def make(ctxt, target=None, file_=None, keep_going=False, directory=None, jobs=None, args=None):
     """Execute a Makefile target.
     
     :param ctxt: the build context
@@ -102,19 +103,32 @@
     :param file\_: name of the Makefile
     :param keep_going: whether make should keep going when errors are
                        encountered
+    :param directory: directory in which to build; defaults to project source directory
+    :param jobs: number of concurrent jobs to run
+    :param args: command-line arguments to pass to the script
     """
     executable = ctxt.config.get_filepath('make.path') or 'make'
 
-    args = ['--directory', ctxt.basedir]
+    if directory is None:
+        directory = ctxt.basedir
+
+    margs = ['--directory', directory]
+
     if file_:
-        args += ['--file', ctxt.resolve(file_)]
+        margs += ['--file', ctxt.resolve(file_)]
     if keep_going:
-        args.append('--keep-going')
+        margs.append('--keep-going')
     if target:
-        args.append(target)
+        margs.append(target)
+    if jobs:
+        margs += ['--jobs', jobs]
+
+    if args:
+        if isinstance(args, basestring):
+            margs += shlex.split(args)
 
     from bitten.build import shtools
-    returncode = shtools.execute(ctxt, executable=executable, args=args)
+    returncode = shtools.execute(ctxt, executable=executable, args=margs)
     if returncode != 0:
         ctxt.error('make failed (%s)' % returncode)
 
--- a/doc/commands.txt
+++ b/doc/commands.txt
@@ -127,9 +127,9 @@
 :Common prefix: ``c``
 
 
------------------
+------------------
 ``<c:autoreconf>``
------------------
+------------------
 
 Executes ths autotool autoreconf.
 
@@ -153,7 +153,8 @@
 +--------------+-------------------------------------------------------------+
 | ``symlink``  | Install symbolic links instead of copies                    |
 +--------------+-------------------------------------------------------------+
-| ``warnings`` | Report the warnings related to category (which can actually be a comma separated list)           |
+| ``warnings`` | Report the warnings related to category                     |
+|              | (which can actually be a comma separated list)              |
 +--------------+-------------------------------------------------------------+
 | ``prepend_include``  | Prepend directories to search path                  |
 +--------------+-------------------------------------------------------------+
@@ -259,6 +260,15 @@
 | ``keep-going`` | Whether `make` should try to continue even after          |
 |                | encountering errors.                                      |
 +----------------+-----------------------------------------------------------+
+| ``jobs``       | Number of parallel jobs used by make.                     |
++----------------+-----------------------------------------------------------+
+| ``directory``  | Path of the directory in which make should be called.     |
++----------------+-----------------------------------------------------------+
+| ``args``       | Any space separated arguments to pass to the makefile.    | 
+|                | Usually in the form:                                      |
+|                | ``"parameter1=value1 parameter2=value2"``.                |
++----------------+-----------------------------------------------------------+
+
 
 Examples
 --------
@@ -270,6 +280,12 @@
 Runs the target "compile" of the ``Makefile`` located in the sub-directory
 ``build``.
 
+.. code-block:: xml
+
+  <c:make target="compile" file="build/Makefile" directory="work" args="coverage=1" />
+
+Same as previous but execute the command in the ``work`` directory and call
+the makefile with the command line argument ``coverage=1``.
 
 ---------------
 ``<c:cppunit>``
Copyright (C) 2012-2017 Edgewall Software