root/dsutils.py

Revision 1139:3ea914ad5605, 1.1 KB (checked in by Ronny Pfannschmidt <Ronny.Pfannschmidt@…>, 8 months ago)

fixes to moo/moopaned usage

Line 
1import sys
2import os
3from commands import getstatusoutput, getoutput
4
5def pkgc_version_check(name, longname, req_version):
6    is_installed = not os.system('pkg-config --exists %s' % name)
7    if not is_installed:
8        print "Could not find %s" % longname
9        return 0
10
11    orig_version = getoutput('pkg-config --modversion %s' % name)
12    version = map(int, orig_version.split('.'))
13    pkc_version = map(int, req_version.split('.'))
14
15    if version >= pkc_version:
16        return True
17    else:
18        print "Warning: Too old version of %s" % longname
19        print "         Need %s, but %s is installed" % \
20              (pkc_version, orig_version)
21        return False
22
23def pkc_get_dirs(names, option, flag):
24    retval = []
25    for name in names:
26        output = getoutput(' '.join(['pkg-config', option, name]))
27        retval.extend(output.replace(flag, '').split())
28    return retval
29
30def pkc_get_include_dirs(*names):
31    return pkc_get_dirs(names, '--cflags-only-I', '-I')
32
33def pkc_get_libraries(*names):
34    return pkc_get_dirs(names, '--libs-only-l', '-l')
35
36def pkc_get_library_dirs(*names):
37    return pkc_get_dirs(names, '--libs-only-L', '-L')
Note: See TracBrowser for help on using the browser.