def autoreconf( ctxt, file_="configure", force=None, install=None, symlink=None, warnings=None, prepend_include=None, include=None ): """Run the autotoll ``autoreconf``. :param ctxt: the build context :type ctxt: `Context` :param force: consider all files obsolete :param install: copy missing auxiliary files :param symlink: install symbolic links instead of copies :param warnings: report the warnings falling in CATEGORY :prepend_include: prepend directories to search path :include: append directories to search path """ args = [] if install: args.append("--install") if symlink: args.append("--symlink") if force: args.append("--force") if warnings: args.append("--warnings=%s" % warnings) if include: args += ["--include=%s" % inc for inc in include.split()] if prepend_include: args += ["--prepend-include=%s" % pinc for pinc in prepend_include.split()] from bitten.build import shtools returncode = shtools.execute(ctxt, "autoreconf", args=args) if returncode != 0: ctxt.error("autoreconf failed (%s)" % returncode)
def update(ctxt, revision=None, dir_='.', username=None, password=None, no_auth_cache='false'): """Update the local working copy from the Subversion repository. :param ctxt: the build context :type ctxt: `Context` :param revision: the revision to check out :param dir\_: the name of a local subdirectory containing the working copy :param username: a username of the repository :param password: a password of the repository :param no\_auth\_cache: do not cache authentication tokens """ args = ['update'] if revision: args += ['-r', revision] if username is not None: args += ['--username', username] if password is not None: args += ['--password', password] if no_auth_cache.lower() == 'true': args += ['--no-auth-cache'] args += [dir_] from bitten.build import shtools returncode = shtools.execute(ctxt, file_='svn', args=args) if returncode != 0: ctxt.error('svn update failed (%s)' % returncode)
def update(ctxt, revision=None, dir_='.', username=None, password=None, no_auth_cache='false'): """Update the local working copy from the Subversion repository. :param ctxt: the build context :type ctxt: `Context` :param revision: the revision to check out :param dir\_: the name of a local subdirectory containing the working copy :param username: a username of the repository :param password: a password of the repository :param no\_auth\_cache: do not cache authentication tokens """ args = ['update'] if revision: args += ['-r', revision] if username: args += ['--username', username] if password: args += ['--password', password] if no_auth_cache.lower() == 'true': args += ['--no-auth-cache'] args += [dir_] from bitten.build import shtools returncode = shtools.execute(ctxt, file_='svn', args=args) if returncode != 0: ctxt.error('svn update failed (%s)' % returncode)
def export(ctxt, url, path=None, revision=None, dir_='.', username=None, password=None, no_auth_cache='false'): """Perform an export from a Subversion repository. :param ctxt: the build context :type ctxt: `Context` :param url: the URL of the repository :param path: the path inside the repository :param revision: the revision to check out :param dir\_: the name of a local subdirectory to export out into :param username: a username of the repository :param password: a password of the repository :param no\_auth\_cache: do not cache authentication tokens """ args = ['export', '--force'] if revision: args += ['-r', revision] if path: url = posixpath.join(url, path) if username is not None: args += ['--username', username] if password is not None: args += ['--password', password] if no_auth_cache.lower() == 'true': args += ['--no-auth-cache'] args += [url, dir_] from bitten.build import shtools returncode = shtools.execute(ctxt, file_='svn', args=args) if returncode != 0: ctxt.error('svn export failed (%s)' % returncode)
def export(ctxt, url, path=None, revision=None, dir_='.', username=None, password=None): """Perform an export from a Subversion repository. :param ctxt: the build context :type ctxt: `Context` :param url: the URL of the repository :param path: the path inside the repository :param revision: the revision to check out :param dir\_: the name of a local subdirectory to export out into :param username: a username of the repository :param password: a password of the repository """ args = ['export', '--force'] if revision: args += ['-r', revision] if path: url = posixpath.join(url, path) if username: args += ['--username', username] if password: args += ['--password', password] args += [url, dir_] from bitten.build import shtools returncode = shtools.execute(ctxt, file_='svn', args=args) if returncode != 0: ctxt.error('svn export failed (%s)' % returncode)
def autoreconf(ctxt, file_='configure', force=None, install=None, symlink=None, warnings=None, prepend_include=None, include =None): """Run the autotoll ``autoreconf``. :param ctxt: the build context :type ctxt: `Context` :param force: consider all files obsolete :param install: copy missing auxiliary files :param symlink: install symbolic links instead of copies :param warnings: report the warnings falling in CATEGORY :param prepend_include: prepend directories to search path :param include: append directories to search path """ args = [] if install: args.append('--install') if symlink: args.append('--symlink') if force: args.append('--force') if warnings: args.append('--warnings=%s' % warnings) if include: args += ['--include=%s' % inc for inc in include.split()] if prepend_include: args += ['--prepend-include=%s' % pinc for pinc in prepend_include.split()] from bitten.build import shtools returncode = shtools.execute(ctxt, 'autoreconf', args=args) if returncode != 0: ctxt.error('autoreconf failed (%s)' % returncode)
def ant(ctxt, file_=None, target=None, keep_going=False, args=None): """Run an Ant build. :param ctxt: the build context :type ctxt: `Context` :param file\_: name of the Ant build file :param target: name of the target that should be executed (optional) :param keep_going: whether Ant should keep going when errors are encountered :param args: additional arguments to pass to Ant """ executable = 'ant' ant_home = os.environ.get('ANT_HOME') if ant_home: executable = os.path.join(ant_home, 'bin', 'ant') if not args: args = [] args += ['-noinput'] if file_: args += ['-buildfile', ctxt.resolve(file_)] if keep_going: args += ['-keep-going'] if target: args += [target] returncode = shtools.execute(ctxt, file_=executable, args=args) if returncode != 0: ctxt.error('Ant failed (%s)' % returncode)
def configure( ctxt, file_="configure", enable=None, disable=None, with_=None, without=None, cflags=None, cxxflags=None, prefix=None, **kw ): """Run a ``configure`` script. :param ctxt: the build context :type ctxt: `Context` :param file\_: name of the configure script :param enable: names of the features to enable, seperated by spaces :param disable: names of the features to disable, separated by spaces :param with_: names of external packages to include :param without: names of external packages to exclude :param cflags: ``CFLAGS`` to pass to the configure script :param cxxflags: ``CXXFLAGS`` to pass to the configure script :param prefix: install prefix to pass to the configure script, will be postfixed by the machine name from the build """ args = [] if enable: args += ["--enable-%s" % feature for feature in enable.split()] if disable: args += ["--disable-%s" % feature for feature in disable.split()] # since 'with' is a reserved word in python, we need to handle the argument carefully with_ = kw.pop("with", with_) for key in kw: raise TypeError("configure() got an unexpected keyword argument '%s'" % key) if with_: for pkg in with_.split(): pkg_path = pkg + ".path" if pkg_path in ctxt.config: args.append("--with-%s=%s" % (pkg, ctxt.config[pkg_path])) else: args.append("--with-%s" % pkg) if without: args += ["--without-%s" % pkg for pkg in without.split()] if cflags: args.append("CFLAGS=%s" % cflags) if cxxflags: args.append("CXXFLAGS=%s" % cxxflags) if prefix: args.append("--prefix=%ss" % prefix) from bitten.build import shtools returncode = shtools.execute(ctxt, file_=file_, args=args) if returncode != 0: ctxt.error("configure failed (%s)" % returncode)
def configure(ctxt, file_='configure', enable=None, disable=None, with_=None, without=None, cflags=None, cxxflags=None, prefix=None, **kw): """Run a ``configure`` script. :param ctxt: the build context :type ctxt: `Context` :param file\_: name of the configure script :param enable: names of the features to enable, seperated by spaces :param disable: names of the features to disable, separated by spaces :param with\_: names of external packages to include :param without: names of external packages to exclude :param cflags: ``CFLAGS`` to pass to the configure script :param cxxflags: ``CXXFLAGS`` to pass to the configure script :param prefix: install prefix to pass to the configure script, will be postfixed by the machine name from the build """ args = [] if enable: args += ['--enable-%s' % feature for feature in enable.split()] if disable: args += ['--disable-%s' % feature for feature in disable.split()] # since 'with' is a reserved word in python, we need to handle the argument carefully with_ = kw.pop('with', with_) for key in kw: raise TypeError("configure() got an unexpected keyword argument '%s'" % key) if with_: for pkg in with_.split(): pkg_path = pkg + '.path' if pkg_path in ctxt.config: args.append('--with-%s=%s' % (pkg, ctxt.config[pkg_path])) else: args.append('--with-%s' % pkg) if without: args += ['--without-%s' % pkg for pkg in without.split()] if cflags: args.append('CFLAGS=%s' % cflags) if cxxflags: args.append('CXXFLAGS=%s' % cxxflags) if prefix: args.append('--prefix=%s' % prefix) from bitten.build import shtools returncode = shtools.execute(ctxt, file_=file_, args=args) if returncode != 0: ctxt.error('configure failed (%s)' % returncode)
def phing(ctxt, file_=None, target=None, executable=None, args=None): """Run a phing build""" if args: args = shlex.split(args) else: args = [] args += ['-logger', 'phing.listener.DefaultLogger', '-buildfile', ctxt.resolve(file_ or 'build.xml')] if target: args.append(target) returncode = shtools.execute(ctxt, file_=executable or 'phing', args=args) if returncode != 0: ctxt.error('Phing failed (%s)' % returncode)
def phing(ctxt, file_=None, target=None, executable=None, args=None): """Run a phing build""" if args: args = shlex.split(args) else: args = [] args += [ '-logger', 'phing.listener.DefaultLogger', '-buildfile', ctxt.resolve(file_ or 'build.xml') ] if target: args.append(target) returncode = shtools.execute(ctxt, file_=executable or 'phing', args=args) if returncode != 0: ctxt.error('Phing failed (%s)' % returncode)
def pull(ctxt, revision=None, dir_='.'): """pull and update the local working copy from the Mercurial repository. :param ctxt: the build context :type ctxt: `Context` :param revision: the revision to check out :param dir\_: the name of a local subdirectory containing the working copy """ args = ['pull', '-u'] if revision: args += ['-r', revision.split(':')[-1]] from bitten.build import shtools returncode = shtools.execute(ctxt, file_='hg', args=args, dir_=dir_) if returncode != 0: ctxt.error('hg pull -u failed (%s)' % returncode)
def update(ctxt, revision=None, dir_='.'): """Update the local working copy from the Subversion repository. :param ctxt: the build context :type ctxt: `Context` :param revision: the revision to check out :param dir\_: the name of a local subdirectory containing the working copy """ args = ['update'] if revision: args += ['-r', revision] args += [dir_] from bitten.build import shtools returncode = shtools.execute(ctxt, file_='svn', args=args) if returncode != 0: ctxt.error('svn update failed (%s)' % returncode)
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 :type ctxt: `Context` :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' if directory is None: directory = ctxt.basedir margs = ['--directory', directory] if file_: margs += ['--file', ctxt.resolve(file_)] if keep_going: margs.append('--keep-going') if 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=margs) if returncode != 0: ctxt.error('make failed (%s)' % returncode)
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 :type ctxt: `Context` :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" if directory is None: directory = ctxt.basedir margs = ["--directory", directory] if file_: margs += ["--file", ctxt.resolve(file_)] if keep_going: margs.append("--keep-going") if 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=margs) if returncode != 0: ctxt.error("make failed (%s)" % returncode)
if function: args = '-c "import sys; from %s import %s; %s(sys.argv)" %s' % ( module, function, function, args) else: try: mod = __import__(module, globals(), locals(), []) components = module.split('.') for comp in components[1:]: mod = getattr(mod, comp) file_ = mod.__file__.replace('\\', '/') except ImportError, e: ctxt.error('Cannot execute Python module %s: %s' % (module, e)) return from bitten.build import shtools returncode = shtools.execute(ctxt, executable=_python_path(ctxt), file_=file_, output=output, args=args) if returncode != 0: ctxt.error('Executing %s failed (error code %s)' % (file_, returncode)) def pylint(ctxt, file_=None): """Extract data from a ``pylint`` run written to a file. :param ctxt: the build context :type ctxt: `Context` :param file\_: name of the file containing the Pylint output """ assert file_, 'Missing required attribute "file"' msg_re = re.compile(r'^(?P<file>.+):(?P<line>\d+): ' r'\[(?P<type>[A-Z]\d*)(?:, (?P<tag>[\w\.]+))?\] ' r'(?P<msg>.*)$') msg_categories = dict(W='warning', E='error', C='convention', R='refactor')
args += [final_url, dir_] cofilter = None if verbose.lower() == 'false': cre = re.compile(r'^[AU]\s.*$') cofilter = lambda s: cre.sub('', s) if shared_path is not None: # run checkout on shared_path, then copy shared_path = ctxt.resolve(shared_path) checkout(ctxt, url, path, revision, dir_=shared_path, verbose=verbose) try: copytree(shared_path, ctxt.resolve(dir_)) except Exception, e: ctxt.log('error copying shared tree (%s)' % e) from bitten.build import shtools returncode = shtools.execute(ctxt, file_='svn', args=args, filter_=cofilter) if returncode != 0: ctxt.error('svn checkout failed (%s)' % returncode) def export(ctxt, url, path=None, revision=None, dir_='.', username=None, password=None, no_auth_cache='false'): """Perform an export from a Subversion repository. :param ctxt: the build context :type ctxt: `Context` :param url: the URL of the repository :param path: the path inside the repository :param revision: the revision to check out :param dir\_: the name of a local subdirectory to export out into :param username: a username of the repository :param password: a password of the repository
cofilter = None if verbose.lower() == 'false': cre = re.compile(r'^[AU]\s.*$') cofilter = lambda s: cre.sub('', s) if shared_path is not None: # run checkout on shared_path, then copy shared_path = ctxt.resolve(shared_path) checkout(ctxt, url, path, revision, dir_=shared_path, verbose=verbose) try: copytree(shared_path, ctxt.resolve(dir_)) except Exception, e: ctxt.log('error copying shared tree (%s)' % e) from bitten.build import shtools returncode = shtools.execute(ctxt, file_='svn', args=args, filter_=cofilter) if returncode != 0: ctxt.error('svn checkout failed (%s)' % returncode) def export(ctxt, url, path=None, revision=None, dir_='.', username=None, password=None, no_auth_cache='false'): """Perform an export from a Subversion repository.