class TestPkgConfig(unittest.TestCase):
    def setUp(self):
        pc_path = os.path.join(os.path.dirname(__file__), 'pkgconfig')
        os.environ['PKG_CONFIG_LIBDIR'] = pc_path
        os.environ['PKG_CONFIG_PATH'] = pc_path
        self.pkgconfig = PkgConfig('gstreamer-0.10')
        self.pkgconfig2 = PkgConfig('gstreamer-0.10', False)

    def testListAll(self):
        expected = [
            'gobject-2.0', 'gmodule-2.0', 'libxml-2.0', 'gthread-2.0',
            'glib-2.0', 'gmodule-no-export-2.0', 'gstreamer-0.10'
        ]
        self.assertEquals(sorted(PkgConfig.list_all()), sorted(expected))

    def testIncludeDirs(self):
        expected = [
            '/usr/include/gstreamer-0.10', '/usr/include/glib-2.0',
            '/usr/lib/glib-2.0/include', '/usr/include/libxml2'
        ]
        self.assertEquals(self.pkgconfig.include_dirs(), expected)
        expected = ['/usr/include/gstreamer-0.10']
        self.assertEquals(self.pkgconfig2.include_dirs(), expected)

    def testCFlags(self):
        expected = ['-pthread']
        self.assertEquals(self.pkgconfig.cflags(), expected)
        expected = []
        self.assertEquals(self.pkgconfig2.cflags(), expected)

    def testLibrariesDir(self):
        expected = []
        self.assertEquals(self.pkgconfig.libraries_dirs(), expected)
        expected = []
        self.assertEquals(self.pkgconfig2.libraries_dirs(), expected)

    def testLibraries(self):
        expected = [
            'gstreamer-0.10', 'gobject-2.0', 'gmodule-2.0', 'xml2',
            'gthread-2.0', 'rt', 'glib-2.0'
        ]
        self.assertEquals(self.pkgconfig.libraries(), expected)
        expected = ['gstreamer-0.10']
        self.assertEquals(self.pkgconfig2.libraries(), expected)

    def testRequires(self):
        expected = [
            'glib-2.0', 'gobject-2.0', 'gmodule-no-export-2.0', 'gthread-2.0',
            'libxml-2.0'
        ]
        self.assertEquals(self.pkgconfig.requires(), expected)
        self.assertEquals(self.pkgconfig2.requires(), expected)

    def testPrefix(self):
        self.assertEquals(self.pkgconfig.prefix(), '/usr')
        self.assertEquals(self.pkgconfig2.prefix(), '/usr')
class TestPkgConfig(unittest.TestCase):

    def setUp(self):
        pc_path = os.path.join(os.path.dirname(__file__), 'pkgconfig')
        os.environ['PKG_CONFIG_LIBDIR'] = pc_path
        os.environ['PKG_CONFIG_PATH'] = pc_path
        self.pkgconfig = PkgConfig('gstreamer-0.10')
        self.pkgconfig2 = PkgConfig('gstreamer-0.10', False)

    def testListAll(self):
        expected = ['gobject-2.0', 'gmodule-2.0', 'libxml-2.0', 'gthread-2.0',
                'glib-2.0', 'gmodule-no-export-2.0', 'gstreamer-0.10']
        self.assertEqual(sorted(PkgConfig.list_all()), sorted(expected))

    def testIncludeDirs(self):
        expected = ['/usr/include/gstreamer-0.10', '/usr/include/glib-2.0',
                    '/usr/lib/glib-2.0/include',
                    '/usr/include/libxml2']
        self.assertEqual(self.pkgconfig.include_dirs(), expected)
        expected = ['/usr/include/gstreamer-0.10']
        self.assertEqual(self.pkgconfig2.include_dirs(), expected)

    def testCFlags(self):
        expected = ['-pthread']
        self.assertEqual(self.pkgconfig.cflags(), expected)
        expected = []
        self.assertEqual(self.pkgconfig2.cflags(), expected)

    def testLibrariesDir(self):
        expected = []
        self.assertEqual(self.pkgconfig.libraries_dirs(), expected)
        expected = []
        self.assertEqual(self.pkgconfig2.libraries_dirs(), expected)

    def testLibraries(self):
        expected = ['gstreamer-0.10', 'gobject-2.0', 'gmodule-2.0', 'xml2',
                    'gthread-2.0', 'rt', 'glib-2.0']
        self.assertEqual(self.pkgconfig.libraries(), expected)
        expected = ['gstreamer-0.10']
        self.assertEqual(self.pkgconfig2.libraries(), expected)

    def testRequires(self):
        expected = ['glib-2.0', 'gobject-2.0', 'gmodule-no-export-2.0',
                    'gthread-2.0', 'libxml-2.0']
        self.assertEqual(self.pkgconfig.requires(), expected)
        self.assertEqual(self.pkgconfig2.requires(), expected)

    def testPrefix(self):
        self.assertEqual(self.pkgconfig.prefix(), '/usr')
        self.assertEqual(self.pkgconfig2.prefix(), '/usr')
Ejemplo n.º 3
0
    def __init__(self,
                 libname,
                 target='vs2010',
                 prefix=None,
                 prefix_replacement=None,
                 inherit_common=False,
                 env=None):

        if target not in self.generators:
            raise FatalError('Target version must be one of %s' %
                             list(generators.keys()))

        pkgconfig = PkgConfig([libname], False, env=env)
        requires = pkgconfig.requires()
        include_dirs = pkgconfig.include_dirs()
        libraries_dirs = pkgconfig.libraries_dirs()

        libs = pkgconfig.libraries()
        if None not in [prefix_replacement, prefix]:
            libraries_dirs = [
                x.replace(prefix, prefix_replacement) for x in libraries_dirs
            ]
            include_dirs = [
                x.replace(prefix, prefix_replacement) for x in include_dirs
            ]
        self.vsprops = self.generators[target](libname, requires, include_dirs,
                                               libraries_dirs, libs,
                                               inherit_common)
Ejemplo n.º 4
0
 def _libraries_paths(self, libraries):
     pkgconfig = PkgConfig(libraries)
     libdirs = pkgconfig.libraries_dirs()
     libs = pkgconfig.libraries()
     libspaths = []
     for lib in libs:
         for libdir in libdirs:
             libpath = os.path.join(libdir, self._get_lib_file_name(lib))
             if not os.path.exists(libpath):
                 continue
             libspaths.append(os.path.realpath(libpath))
             break
     return libspaths
Ejemplo n.º 5
0
 def _libraries_paths(self, libraries):
     pkgconfig = PkgConfig(libraries)
     libdirs = pkgconfig.libraries_dirs()
     libs = pkgconfig.libraries()
     libspaths = []
     for lib in libs:
         for libdir in libdirs:
             libpath = os.path.join(libdir, self._get_lib_file_name (lib))
             if not os.path.exists(libpath):
                 continue
             libspaths.append(os.path.realpath(libpath))
             break
     return libspaths
Ejemplo n.º 6
0
    def __init__(self, libname, target="vs2010", prefix=None, prefix_replacement=None, inherit_common=False):

        if target not in self.generators:
            raise FatalError("Target version must be one of %s" % generators.keys())

        pkgconfig = PkgConfig([libname], False)
        requires = pkgconfig.requires()
        include_dirs = pkgconfig.include_dirs()
        libraries_dirs = pkgconfig.libraries_dirs()

        libs = pkgconfig.libraries()
        if None not in [prefix_replacement, prefix]:
            libraries_dirs = [x.replace(prefix, prefix_replacement) for x in libraries_dirs]
            include_dirs = [x.replace(prefix, prefix_replacement) for x in include_dirs]
        self.vsprops = self.generators[target](libname, requires, include_dirs, libraries_dirs, libs, inherit_common)
Ejemplo n.º 7
0
class XCConfig(object):
    '''
    Creates an xcode config file to compile and link against the SDK using
    pkgconfig to guess the headers search path, the libraries search path and
    the libraries that need to be linked.
    '''
    def __init__(self, libraries, env=None):
        self.pkgconfig = PkgConfig(libraries, env=env)

    def create(self, outfile):
        args = self._fill()
        with open(outfile, 'w') as f:
            f.write(XCCONFIG_TPL % args)

    def _fill(self):
        args = dict()
        args['hsp'] = ' '.join(self.pkgconfig.include_dirs())
        args['lsp'] = ' '.join(self.pkgconfig.libraries_dirs())
        args['libs'] = reduce(lambda x, y: '%s -l%s' % (x, y),
                              self.pkgconfig.libraries(), '')
        return args
Ejemplo n.º 8
0
class XCConfig(object):
    '''
    Creates an xcode config file to compile and link against the SDK using
    pkgconfig to guess the headers search path, the libraries search path and
    the libraries that need to be linked.
    '''

    def __init__(self, libraries):
        self.pkgconfig = PkgConfig(libraries)

    def create(self, outfile):
        args = self._fill()
        with open(outfile, 'w') as f:
            f.write(XCCONFIG_TPL % args)

    def _fill(self):
        args = dict()
        args['hsp'] = ' '.join(self.pkgconfig.include_dirs())
        args['lsp'] = ' '.join(self.pkgconfig.libraries_dirs())
        args['libs'] = reduce(lambda x, y: '%s -l%s' % (x, y),
                              self.pkgconfig.libraries(), '')
        return args