All pastes #1970280 Raw Edit

global_libs waftool

public text v1 · immutable
#1970280 ·published 2010-10-22 19:50 UTC
rendered paste body
#! /usr/bin/env python
# encoding: utf-8

print(".. loading global library map")

from waflib.Configure import conf

global_libs = {

'browserlauncher2':     'browserlauncher2/BrowserLauncher2.jar',
'commons-beanutils':    'commons-beanutils-1.7.0/commons-beanutils-core.jar',
'commons-collections':  'commons-collections/commons-collections.jar',
'commons-httpclient':   'commons-httpclient/commons-httpclient.jar',
'commons-io':           'commons-io/commons-io.jar',
'commons-lang':         'commons-lang/commons-lang.jar',
'commons-logging':      'commons-logging/commons-logging.jar',
'google-collect':       'google-collect/google-collect.jar',
'jsr173.api':           'jsr173/jsr173_1.0_api.jar',
'jsr173.ri':            'jsr173/jsr173_1.0_ri.jar',
'mks':                  'mks/mksapi.jar',
'vault':                'vault/vault_client_api.jar'

}


def configure(ctx):
    # fixup global_libs by prepending 'lib/'
    # ...omitted purely for convenience and brevity in the table above
    for (key, value) in global_libs.items():
        global_libs[key] = 'lib/' + value
    ctx.env.global_libs = global_libs
    ctx.env.global_libs_inuse = []
    ctx.env.global_libs_classpath = ""



@conf
def add_global_libs(self, libs, relto=None):
    """ add the specified libs to the .env.global_classpath
        if relto is unspecified, it defaults to the top; otherwise
           it's prepended to the paths in the classpath. 
    """
    # don't put them on the classpath multiple times
    newlibs = self.env.global_libs_inuse
    for lib in libs:
        if not lib in newlibs:
            newlibs.append(lib)
    self.set_global_libs(relto=relto, *newlibs)


@conf
def set_global_libs(self, libs, relto=None):
    # figure out the prepath to append
    prepath = self.srcnode.abspath()
    if relto is not None:
        prepath = relto
    if not prepath.endswith('/'): prepath += '/'
    # build the classpath
    classpath = ''
    for lib in libs:
        if classpath: classpath += ':'
        classpath += prepath + self.env.global_libs[lib]
    # set the environment vars
    self.env.global_libs_inuse = libs
    self.env.global_libs_classpath = classpath