Пример #1
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
Пример #2
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
Пример #3
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)
Пример #4
0
    def pack(self,
             output_dir,
             devel=True,
             force=False,
             keep_temp=False,
             version=None,
             target='10.5',
             install_dir=None,
             include_dirs=None,
             sdk_version=None):
        PackagerBase.pack(self, output_dir, devel, force, keep_temp)

        self.install_dir = install_dir or self.package.get_install_dir()
        self.version = version or self.package.version
        self.sdk_version = sdk_version or self.version
        self.include_dirs = include_dirs or PkgConfig.list_all_include_dirs()

        # create the runtime package
        try:
            runtime_path = self._create_package(PackageType.RUNTIME,
                                                output_dir, force, target)
        except EmptyPackageError, e:
            if not devel:
                raise e
            runtime_path = None
Пример #5
0
    def pack(self, output_dir, devel=False, force=False, keep_temp=False):
        PackagerBase.pack(self, output_dir, devel, force, keep_temp)

        self.include_dirs = PkgConfig.list_all_include_dirs()
        self.tmp = tempfile.mkdtemp()

        self.empty_packages = {PackageType.RUNTIME: [], PackageType.DEVEL: []}
        self.packages_paths = {PackageType.RUNTIME: {}, PackageType.DEVEL: {}}

        if isinstance(self.package, SDKPackage):
            self._create_framework_bundle_package()
        self._create_packages()

        paths = []
        # create runtime package
        r_path = self._create_pmdoc(PackageType.RUNTIME)
        paths.append(r_path)

        if devel:
            # create devel package
            d_path = self._create_pmdoc(PackageType.DEVEL)
            paths.append(d_path)

        # FIXME: Figure out why PackageMaker refuses to create flat meta-packages
        # using flat packages created by himself
        self.package.set_mode(PackageType.RUNTIME)
        for path in paths:
            self._create_dmgs(paths)

        if not keep_temp:
            shutil.rmtree(self.tmp)

        return paths
Пример #6
0
    def pack(self, output_dir, devel=True, force=False, keep_temp=False,
             version=None, install_dir=None, include_dirs=None,
             sdk_version=None):
        PackagerBase.pack(self, output_dir, devel, force, keep_temp)

        self.install_dir = install_dir or self.package.get_install_dir()
        self.version = version or self.package.version
        self.sdk_version = sdk_version or self.version
        self.include_dirs = include_dirs or PkgConfig.list_all_include_dirs()

        # create the runtime package
        try:
            runtime_path = self._create_package(PackageType.RUNTIME,
                    output_dir, force)
        except EmptyPackageError as e:
            if not devel:
                raise e
            runtime_path = None

        if not devel:
            return [runtime_path, None]

        try:
            # create the development package
            devel_path = self._create_package(PackageType.DEVEL, output_dir,
                    force)
        except EmptyPackageError as e:
            if runtime_path is None:
                raise e
            devel_path = None

        return [runtime_path, devel_path]
Пример #7
0
    def _prepare_pack(self):
        self.include_dirs = PkgConfig.list_all_include_dirs()
        self.tmp = tempfile.mkdtemp()
        self.fw_path = self.tmp

        self.empty_packages = {PackageType.RUNTIME: [], PackageType.DEVEL: []}
        self.packages_paths = {PackageType.RUNTIME: {}, PackageType.DEVEL: {}}
Пример #8
0
    def _prepare_pack(self):
        self.include_dirs = PkgConfig.list_all_include_dirs()
        self.tmp = tempfile.mkdtemp()
        self.fw_path = self.tmp

        self.empty_packages = {PackageType.RUNTIME: [], PackageType.DEVEL: []}
        self.packages_paths = {PackageType.RUNTIME: {}, PackageType.DEVEL: {}}
Пример #9
0
    def pack(
        self,
        output_dir,
        devel=True,
        force=False,
        keep_temp=False,
        version=None,
        install_dir=None,
        include_dirs=None,
        sdk_version=None,
    ):
        PackagerBase.pack(self, output_dir, devel, force, keep_temp)

        self.install_dir = install_dir or self.package.get_install_dir()
        self.version = version or self.package.version
        self.sdk_version = sdk_version or self.version
        self.include_dirs = include_dirs or PkgConfig.list_all_include_dirs()

        # create the runtime package
        try:
            runtime_path = self._create_package(PackageType.RUNTIME, output_dir, force)
        except EmptyPackageError, e:
            if not devel:
                raise e
            runtime_path = None
Пример #10
0
    def pack(self, output_dir, devel=False, force=False, keep_temp=False):
        PackagerBase.pack(self, output_dir, devel, force, keep_temp)

        self.include_dirs = PkgConfig.list_all_include_dirs()
        self.tmp = tempfile.mkdtemp()

        self.empty_packages = {PackageType.RUNTIME: [], PackageType.DEVEL: []}
        self.packages_paths = {PackageType.RUNTIME: {}, PackageType.DEVEL: {}}

        if isinstance(self.package, SDKPackage):
            self._create_framework_bundle_package()
        self._create_packages()

        paths = []
        # create runtime package
        r_path = self._create_pmdoc(PackageType.RUNTIME)
        paths.append(r_path)

        if devel:
            # create devel package
            d_path = self._create_pmdoc(PackageType.DEVEL)
            paths.append(d_path)

        # FIXME: Figure out why PackageMaker refuses to create flat meta-packages
        # using flat packages created by himself
        self.package.set_mode(PackageType.RUNTIME)
        for path in paths:
            self._create_dmgs(paths)

        if not keep_temp:
            shutil.rmtree(self.tmp)

        return paths
Пример #11
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
Пример #12
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)
Пример #13
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
Пример #14
0
    def runargs(self, config, output_dir, prefix=DEFAULT_PREFIX_MACRO):
        if not os.path.exists(output_dir):
            os.makedirs(output_dir)

        for pc in PkgConfig.list_all():
            p2v = PkgConfig2VSProps(pc, prefix=config.prefix,
                    inherit_common=True,
                    prefix_replacement='$(%s)' % prefix)
            p2v.create(output_dir)
            m.action('Created %s.props' % pc)

        common = CommonProps(prefix)
        common.create(output_dir)

        m.message('Property sheets files were sucessfully created in %s' %
                  os.path.abspath(output_dir))
Пример #15
0
    def runargs(self, config, output_dir, prefix=DEFAULT_PREFIX_MACRO):
        if not os.path.exists(output_dir):
            os.makedirs(output_dir)

        for pc in PkgConfig.list_all(env=config.env):
            p2v = PkgConfig2VSProps(pc, prefix=config.prefix,
                    inherit_common=True,
                    prefix_replacement='$(%s)' % prefix, env=config.env)
            p2v.create(output_dir)
            m.action('Created %s.props' % pc)

        common = CommonProps(prefix)
        common.create(output_dir)

        m.message('Property sheets files were sucessfully created in %s' %
                  os.path.abspath(output_dir))
Пример #16
0
 def __init__(self, libraries, env=None):
     self.pkgconfig = PkgConfig(libraries, env=env)
 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 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)
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')
Пример #20
0
 def __init__(self, libraries):
     self.pkgconfig = PkgConfig(libraries)
 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 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)
Пример #23
0
 def __init__(self, libraries):
     self.pkgconfig = PkgConfig(libraries)
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')