Пример #1
0
 def _add_libraries_from_pc(self, library, static=None):
     if static is None:
         static = not self.options.shared
     pkg_config = tools.PkgConfig(library, static=static)
     libs = [lib[2:] for lib in pkg_config.libs_only_l]  # cut -l prefix
     lib_paths = [lib[2:]
                  for lib in pkg_config.libs_only_L]  # cut -L prefix
     self.cpp_info.libs.extend(libs)
     self.cpp_info.libdirs.extend(lib_paths)
     self.cpp_info.sharedlinkflags.extend(pkg_config.libs_only_other)
     self.cpp_info.exelinkflags.extend(pkg_config.libs_only_other)
Пример #2
0
    def build(self):
        if self.settings.os != 'Windows':
            with tools.environment_append({'PKG_CONFIG_PATH': "."}):
                pkg_config = tools.PkgConfig("gobject-introspection-1.0")
                for tool in ["g_ir_compiler", "g_ir_generate", "g_ir_scanner"]:
                    self.run('%s --version' % pkg_config.variables[tool], run_environment=True)
                self.run('g-ir-annotation-tool --version', run_environment=True)
                self.run('g-ir-inspect -h', run_environment=True)

        cmake = CMake(self)
        cmake.configure()
        cmake.build()
Пример #3
0
    def add_libraries_from_pc(self, library):
        pkg_config = tools.PkgConfig(library)

        libs = []
        # cut -l prefix
        for lib in pkg_config.libs_only_l:
            l = lib[2:]
            if l != "freetype" or not self.options["freetype"].shared:
                libs.append(l)

        lib_paths = [lib[2:]
                     for lib in pkg_config.libs_only_L]  # cut -L prefix
        self.cpp_info.libs.extend(libs)
        self.cpp_info.libdirs.extend(lib_paths)
        self.cpp_info.sharedlinkflags.extend(pkg_config.libs_only_other)
        self.cpp_info.exelinkflags.extend(pkg_config.libs_only_other)
Пример #4
0
    def package_info(self):
        excluded_dep_libs = []
        for k, v in self.deps_cpp_info.dependencies:
            excluded_dep_libs.extend(v.libs)

        pkgconfigpath = os.path.join(self.package_folder, "lib/pkgconfig")
        self.output.info("package info file: " + pkgconfigpath)
        with tools.environment_append({'PKG_CONFIG_PATH': pkgconfigpath}):
            pkg_config = tools.PkgConfig("libpjproject")
            self.copy_cleaned(pkg_config.libs_only_L, "-L",
                              self.cpp_info.lib_paths, [])
            # exclude all libraries from dependencies here, they are separately included
            self.copy_cleaned(pkg_config.libs_only_l, "-l", self.cpp_info.libs,
                              excluded_dep_libs)  #["ssl", "crypto", "z"]
            self.copy_prefix_merged(pkg_config.libs_only_other, "-framework",
                                    self.cpp_info.exelinkflags)
            self.cpp_info.sharedlinkflags = self.cpp_info.exelinkflags
Пример #5
0
    def get_cpp_info_fields_from_pkg(self, pkg_name):
        pkg = tools.PkgConfig(pkg_name)
        libdirs = []
        syslibs = []
        libs = []
        following_is_syslibs = False
        for _i in pkg.libs:
            if not _i.strip():
                continue
            if _i.startswith('-L'):
                conans.tools.logger.debug('required lib: {}; default_lib_paths: {}'.format(_i[2:], self.default_lib_paths))
                if _i[2:] in self.default_lib_paths:
                    self.output.info('found system libdir {}'.format(_i[2:]))
                    following_is_syslibs = True
                    continue
                else:
                    libdirs.append(_i[2:])
                    following_is_syslibs = False
                    continue
            elif _i.startswith('-l'):
                if following_is_syslibs:
                    syslibs.append(_i[2:])
                else:
                    libs.append(_i[2:])
            elif _i.startswith('-Wl'):
                self.output.info('ignore linker flags {}'.format(_i))
            else:
                raise conans.errors.ConanException('Does not support libs entries without "-L" or "-l"')


        if len(libdirs) > 1:
            #TODO: cpp_info is still clumsy here, the -L and -l order actually mattered. the components is come into rescue but it still have some issue in the way they designed it.
            self.output.warn('FIXME: multiple libdirs={}. libs in one of the dir can hide the libs in another dir. Use components instead. If components is already in use, it might require split this project into sub-packages.'.format(libdirs))
        cflags = pkg.cflags_only_other
        # TODO: split cflags to defines and pure cflags
        includedirs = [_i[2:] for _i in pkg.cflags_only_I]
        if MyPkgConfig(None).is_pkgconf():
            _prefix = re.compile(pkg.variables['prefix'])
            conans.tools.logger.debug(
                'replace prefix (`{}`) with current package folder.'.format(_prefix.pattern))
            libdirs = self.fix_pkgconfig_prefix(libdirs, _prefix)
            libs = self.fix_pkgconfig_prefix(libs, _prefix)
            cflags = self.fix_pkgconfig_prefix(cflags, _prefix)
            includedirs = self.fix_pkgconfig_prefix(includedirs, _prefix)
        return cflags, includedirs, libdirs, libs, syslibs
Пример #6
0
    def _fill_cppinfo_from_pkgconfig(self, name):
        pkg_config = tools.PkgConfig(name)
        if not pkg_config.provides:
            raise ConanException("OpenGL development files aren't available, give up")
        libs = [lib[2:] for lib in pkg_config.libs_only_l]
        lib_dirs = [lib[2:] for lib in pkg_config.libs_only_L]
        ldflags = [flag for flag in pkg_config.libs_only_other]
        include_dirs = [include[2:] for include in pkg_config.cflags_only_I]
        cflags = [flag for flag in pkg_config.cflags_only_other if not flag.startswith("-D")]
        defines = [flag[2:] for flag in pkg_config.cflags_only_other if flag.startswith("-D")]

        self.cpp_info.system_libs.extend(libs)
        self.cpp_info.libdirs.extend(lib_dirs)
        self.cpp_info.sharedlinkflags.extend(ldflags)
        self.cpp_info.exelinkflags.extend(ldflags)
        self.cpp_info.defines.extend(defines)
        self.cpp_info.includedirs.extend(include_dirs)
        self.cpp_info.cflags.extend(cflags)
        self.cpp_info.cxxflags.extend(cflags)
Пример #7
0
def libpkg_exists(
        libname: str, scope_output,
        ver_range: Union[Tuple[str], Tuple[str, str]] = ()
):
    pkgconf = tools.PkgConfig(libname)
    try:
        _modversion = Version(pkgconf._get_option('modversion')[0])
        pkgconf_vars = pkgconf.variables
        scope_output.info('{} {} exists'.format(libname, _modversion))
        if ver_range:
            min_ver = Version(ver_range[0])
            max_ver = Version(ver_range[1]) if len(ver_range) == 2 else None
            if _modversion < min_ver or (max_ver is not None and _modversion > max_ver):
                scope_output.info('{} version {} is not in {}'.format(libname, _modversion, ver_range))
                return False
        return True
    except conans.errors.ConanException as e:
        scope_output.warn('{}'.format(e))
        return False
Пример #8
0
    def package_info(self):
        # pkgpath = "usr/lib/%s/pkgconfig" % self.triplet_name()
        pkgpath = "lib/pkgconfig"
        pkgconfigpath = os.path.join(self.package_folder, pkgpath)
        if self.settings.os == "Linux":
            self.output.info("package info file: " + pkgconfigpath)
            with tools.environment_append({'PKG_CONFIG_PATH': pkgconfigpath}):
                pkg_config = tools.PkgConfig(
                    "libudev", variables={"prefix": self.package_folder})

                self.output.info("lib_paths %s" % self.cpp_info.lib_paths)

                # exclude all libraries from dependencies here, they are separately included
                self.copy_cleaned(pkg_config.libs_only_l, "-l",
                                  self.cpp_info.libs)
                self.output.info("libs: %s" % self.cpp_info.libs)

                self.output.info("include_paths: %s" %
                                 self.cpp_info.include_paths)
Пример #9
0
	def build(self):
		self.output.warn("build")
		cmake = CMake(self)
		with tools.environment_append({'PKG_CONFIG_PATH': "/tmp/logtest"}):
			pkg_config = tools.PkgConfig("libsystemd")
			include_dir = os.path.join(pkg_config.variables["includedir"], "systemd")
			lib_dir = os.path.join(pkg_config.variables["libdir"])
			print("CFLAGS: %s" % pkg_config.cflags)
			print("Includes: %s" % pkg_config.cflags_only_I)
			print("Include dir: %s" % include_dir)
			print("Libs: %s" % pkg_config.libs_only_L)
			print("More Libs: %s" % pkg_config.libs_only_l)
			print("lib dir: %s" % lib_dir)
			print("variables: %s" % pkg_config.variables)
			cmake.definitions["CMAKE_VERBOSE_MAKEFILE"] = "TRUE"
			cmake.definitions["CONAN_SYSTEM_INCLUDEDIRS"] = include_dir
			cmake.definitions["CONAN_SYSTEM_LIBDIRS"] = lib_dir
			cmake.definitions["CONAN_SYSTEM_LIBS"] = "systemd"
			cmake.configure()
			cmake.build()
Пример #10
0
    def package_info(self):
        pkgpath = "lib/pkgconfig"
        pkgconfigpath = os.path.join(self.package_folder, pkgpath)
        if self.settings.os == "Linux":
            self.output.info("package info file: " + pkgconfigpath)
            with tools.environment_append({'PKG_CONFIG_PATH': pkgconfigpath}):
                pkg_config = tools.PkgConfig(
                    "libsystemd", variables={"prefix": self.package_folder})

                # if self.settings.compiler == 'gcc':
                #     # Allow executables consuming this package to ignore missing secondary dependencies at compile time
                #     # needed so we can use libsystemd.so withouth providing a couple of secondary library dependencies
                #     # http://www.kaizou.org/2015/01/linux-libraries.html
                #     self.cpp_info.exelinkflags.extend(['-Wl,--unresolved-symbols=ignore-in-shared-libs'])

                self.output.info("lib_paths %s" % self.cpp_info.lib_paths)

                # exclude all libraries from dependencies here, they are separately included
                self.copy_cleaned(pkg_config.libs_only_l, "-l",
                                  self.cpp_info.libs)
                self.output.info("libs: %s" % self.cpp_info.libs)

                self.output.info("include_paths: %s" %
                                 self.cpp_info.include_paths)
Пример #11
0
 def _check_pkg_config(self, option, package_name):
     if option:
         pkg_config = tools.PkgConfig(package_name)
         if not pkg_config.provides:
             raise ConanInvalidConfiguration("package %s is not available" %
                                             package_name)
Пример #12
0
 def check_pkg_config(self, option, package_name):
     if option:
         pkg_config = tools.PkgConfig(package_name)
         if not pkg_config.provides:
             raise Exception('package %s is not available' % package_name)
def replace_prefix_everywhere_in_pc_file(file, prefix):
    pkg_config = tools.PkgConfig(file)
    old_prefix = pkg_config.variables["prefix"]
    tools.replace_in_file(file, old_prefix, prefix)