All pastes #1601748 Raw Edit

waf.py v4

public python v1 · immutable
#1601748 ·published 2009-10-07 16:30 UTC
rendered paste body
# -*- coding: utf-8 -*-## Copyright (C) 2009, TUBITAK/UEKAE## This program is free software; you can redistribute it and/or modify it under# the terms of the GNU General Public License as published by the Free# Software Foundation; either version 2 of the License, or (at your option)# any later version.## Please read the COPYING file.# Standard Python Modulesimport osimport gettext__trans = gettext.translation('pisi', fallback=True)_ = __trans.ugettext# Pisi Modulesimport pisi.context as ctx# ActionsAPI Modulesimport pisi.actionsapiimport pisi.actionsapi.get as getfrom pisi.actionsapi.shelltools import systemfrom pisi.actionsapi.shelltools import can_access_filefrom pisi.actionsapi.shelltools import unlinkclass WafPathError(pisi.actionsapi.Error):    def __init__(self, value=''):        pisi.actionsapi.Error.__init__(self, value)        self.value = value        ctx.ui.error(value)class ConfigureError(pisi.actionsapi.Error):    def __init__(self, value=''):        pisi.actionsapi.Error.__init__(self, value)        self.value = value        ctx.ui.error(value)class BuildError(pisi.actionsapi.Error):    def __init__(self, value=''):        pisi.actionsapi.Error.__init__(self, value)        self.value = value        ctx.ui.error(value)class InstallError(pisi.actionsapi.Error):    def __init__(self, value=''):        pisi.actionsapi.Error.__init__(self, value)        self.value = value        ctx.ui.error(value)class RunTimeError(pisi.actionsapi.Error):    def __init__(self, value=''):        pisi.actionsapi.Error.__init__(self, value)        self.value = value        ctx.ui.error(value)def getWafPath():    if can_access_file('waf'):        return 'python waf'    else if system('which waf &>/dev/null'):        return system('which waf')    else        raise WafPathError('No waf executable found.')def configure(parameters = ''):    '''configure source with given parameters = "--enable-something-useful etc."'''    if can_access_file('wscript'):        args = '%s \                --prefix=/%s \                --blddir=%s \                --datadir=/%s \                --sysconfdir=/%s \                --localstatedir=/%s \                --libexecdir=/%s \                %s configure' % (getWafPath(), get.defaultprefixDIR(), get.HOST(), \                get.dataDIR(), get.confDIR(), get.localstateDIR(), get.libexecDIR(), \                parameters)        if system(args):            raise ConfigureError(_('Configure failed.'))    else:        raise ConfigureError(_('No wscript found.'))def rawConfigure(parameters = ''):    '''configure source with given parameters = "--prefix=... --enable-foobar etc."'''    if can_access_file('wscript'):        if system('%s %s configure' % (getWafPath(), parameters)):            raise ConfigureError(_('Configure failed.'))    else:        raise ConfigureError(_('No wscript found.'))def build(parameters = ''):    '''build source with given parameters = --targets="doc,bin" etc.'''    if can_access_file('wscript'):        if system('%s build' % (getWafPath(), parameters)):            raise BuildError(_('Build failed.'))    else:        raise ConfigureError(_('No wscript found.'))def fixInfoDir():    infoDir = '%s/usr/share/info/dir' % get.installDIR()    if can_access_file(infoDir):        unlink(infoDir)def install(parameters = ''):    '''install files into install directory with given parameters'''    if can_access_file('wscript'):        args = '%(wafcmd)s --prefix=%(prefix)s/%(defaultprefix)s \                --datadir=%(prefix)s/%(data)s \                --localstatedir=%(prefix)s/%(localstate)s \                --sysconfdir=%(prefix)s/%(conf)s \                %(parameters)s install' % { \                            'wafcmd':getWafPath(),                            'prefix': get.installDIR(),                            'defaultprefix': get.defaultprefixDIR(),                            'data': get.dataDIR(),                            'localstate': get.localstateDIR(),                            'conf': get.confDIR(),                            'parameters': parameters}        if system(args):            raise InstallError(_('Install failed.'))        else:            fixInfoDir()    else:        raise InstallError(_('No wscript found.'))def rawInstall(parameters = ''):    '''install files into install directory with given parameters'''    if can_access_file('wscript'):        if system('%s %s install' % (getWafPath(), parameters)):            raise InstallError(_('Install failed.'))        else:            fixInfoDir()    else:        raise InstallError(_('No wscript found.'))def clean(parameters = ''):    '''remove the build files'''    if can_access_file('wscript'):        if system('%s %s clean' % (getWafPath(), parameters)):            raise RunTimeError(_('Clean failed.'))    else:        raise InstallError(_('No wscript found.'))