Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

libverto: Update dependencies #14295

Merged
merged 18 commits into from
Feb 16, 2023
Merged
Changes from 7 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
127 changes: 65 additions & 62 deletions recipes/libverto/all/conanfile.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
from conans import AutoToolsBuildEnvironment, ConanFile, tools
from conans.errors import ConanInvalidConfiguration
import contextlib
from conan import ConanFile
from conan.errors import ConanInvalidConfiguration
from conan.tools.files import copy, get, rm, rmdir, chdir, export_conandata_patches, apply_conandata_patches
prince-chrismc marked this conversation as resolved.
Show resolved Hide resolved
from conan.tools.env import VirtualBuildEnv
from conan.tools.gnu import Autotools, AutotoolsToolchain,AutotoolsDeps, PkgConfigDeps
prince-chrismc marked this conversation as resolved.
Show resolved Hide resolved
from conan.tools.microsoft import is_msvc
from conan.tools.layout import basic_layout
from conans import tools
prince-chrismc marked this conversation as resolved.
Show resolved Hide resolved
import os


Expand Down Expand Up @@ -37,13 +42,7 @@ class LibVertoConan(ConanFile):
settings = "os", "arch", "compiler", "build_type"

exports_sources = "patches/*"
Jihadist marked this conversation as resolved.
Show resolved Hide resolved
generators = "pkg_config"

_autotools = None

@property
def _source_subfolder(self):
return "source_subfolder"


@property
def _settings_build(self):
Expand All @@ -58,6 +57,9 @@ def _backend_dict(self):
"tevent": self.options.with_tevent,
}

def layout(self):
basic_layout(self, src_folder="src")

def config_options(self):
if self.settings.os == "Windows":
del self.options.fPIC
Expand All @@ -71,7 +73,7 @@ def configure(self):
del self.settings.compiler.cppstd

def validate(self):
if self.settings.compiler == "Visual Studio":
if is_msvc(self):
raise ConanInvalidConfiguration("libverto does not support Visual Studio")
if self.settings.os == "Windows" and self.options.shared:
raise ConanInvalidConfiguration("Shared libraries are not supported on Windows")
Expand All @@ -90,13 +92,16 @@ def validate(self):
if count_builtins > 0 and count_externals > 0:
raise ConanInvalidConfiguration("Cannot combine builtin and external backends")

def export_sources(self):
export_conandata_patches(self)

def source(self):
tools.get(**self.conan_data["sources"][self.version],
destination=self._source_subfolder, strip_root=True)
get(self, **self.conan_data["sources"][self.version],
destination=self.source_folder, strip_root=True)
Jihadist marked this conversation as resolved.
Show resolved Hide resolved

def requirements(self):
if self.options.with_glib:
self.requires("glib/2.69.2")
self.requires("glib/2.74.21")
Jihadist marked this conversation as resolved.
Show resolved Hide resolved
if self.options.with_libevent:
self.requires("libevent/2.1.12")
if self.options.with_libev:
Expand All @@ -106,62 +111,60 @@ def requirements(self):
raise ConanInvalidConfiguration("tevent is not (yet) available on conan-center")

def build_requirements(self):
self.build_requires("pkgconf/1.7.4")
self.build_requires("libtool/2.4.6")
if self._settings_build.os == "Windows" and not tools.get_env("CONAN_BASH_PATH"):
self.build_requires("msys2/cci.latest")

@contextlib.contextmanager
def _build_context(self):
if self.settings.compiler == "Visual Studio":
with tools.vcvars(self):
env = {
"CC": "{} cl -nologo".format(tools.unix_path(self.deps_user_info["automake"].compile)),
"CXX": "{} cl -nologo".format(tools.unix_path(self.deps_user_info["automake"].compile)),
"LD": "{} link -nologo".format(tools.unix_path(self.deps_user_info["automake"].compile)),
"AR": "{} lib".format(tools.unix_path(self.deps_user_info["automake"].ar_lib)),
}
with tools.environment_append(env):
yield
else:
yield

def _configure_autotools(self):
if self._autotools:
return self._autotools
self._autotools = AutoToolsBuildEnvironment(self, win_bash=tools.os_info.is_windows)
self._autotools.libs = []
self.build_requires("pkgconf/1.9.3")
self.build_requires("libtool/2.4.7")
Jihadist marked this conversation as resolved.
Show resolved Hide resolved
if self._settings_build.os == "Windows":
self.win_bash = True
if not self.conf.get("tools.microsoft.bash:path", check_type=str):
self.tool_requires("msys2/cci.latest")

def generate(self):
env = VirtualBuildEnv(self)
env.generate()
tc = AutotoolsToolchain(self)
yes_no = lambda v: "yes" if v else "no"
yes_no_builtin = lambda v: {"external": "yes", "False": "no", "builtin": "builtin"}[str(v)]
args = [
"--enable-shared={}".format(yes_no(self.options.shared)),
"--enable-static={}".format(yes_no(not self.options.shared)),
"--with-pthread={}".format(yes_no(self.options.get_safe("pthread", False))),
"--with-glib={}".format(yes_no_builtin(self.options.with_glib)),
"--with-libev={}".format(yes_no_builtin(self.options.with_libev)),
"--with-libevent={}".format(yes_no_builtin(self.options.with_libevent)),
"--with-tevent={}".format(yes_no_builtin(self.options.with_tevent)),
]
self._autotools.configure(args=args, configure_dir=self._source_subfolder)
return self._autotools
tc.configure_args.extend([
f"--with-pthread={yes_no(self.options.get_safe('pthread'))}",
f"--with-glib={yes_no_builtin(self.options.with_glib)}",
f"--with-libev={yes_no_builtin(self.options.with_libev)}",
f"--with-libevent={yes_no_builtin(self.options.with_libevent)}",
f"--with-tevent={yes_no_builtin(self.options.with_tevent)}",
])

env = tc.environment()
# if is_msvc(self):
# # FIXME: Use the conf once https://github.com/conan-io/conan-center-index/pull/12898 is merged
Jihadist marked this conversation as resolved.
Show resolved Hide resolved
# # env.define("AR", f"{unix_path(self, self.conf.get('tools.automake:ar-lib'))}")
# [version_major, version_minor, _] = self.dependencies.direct_build['automake'].ref.version.split(".", 2)
# automake_version = f"{version_major}.{version_minor}"
# ar_wrapper = unix_path(self, os.path.join(self.dependencies.direct_build['automake'].cpp_info.resdirs[0], f"automake-{automake_version}", "ar-lib"))
# env.define("CC", "{} cl -nologo".format(unix_path(self.dependencies.direct_build["automake"].compile)))
# env.define("CXX", "{} cl -nologo".format(unix_path(self.deps_user_info["automake"].compile)))
# env.define("LD", "link -nologo")
# env.define("AR", f"{ar_wrapper} \"lib -nologo\"")

Jihadist marked this conversation as resolved.
Show resolved Hide resolved
tc.generate()
prince-chrismc marked this conversation as resolved.
Show resolved Hide resolved
deps = AutotoolsDeps(self)
deps.generate()
Jihadist marked this conversation as resolved.
Show resolved Hide resolved
pkg = PkgConfigDeps(self)
pkg.generate()

def build(self):
for patch in self.conan_data.get("patches", {}).get(self.version, []):
tools.patch(**patch)
with tools.chdir(self._source_subfolder):
apply_conandata_patches(self)
with chdir(self, self.source_folder):
Jihadist marked this conversation as resolved.
Show resolved Hide resolved
self.run("{} -fiv".format(tools.get_env("AUTORECONF")), run_environment=True, win_bash=tools.os_info.is_windows)
Jihadist marked this conversation as resolved.
Show resolved Hide resolved
with self._build_context():
autotools = self._configure_autotools()
autotools.make()
autotools = Autotools(self)
Jihadist marked this conversation as resolved.
Show resolved Hide resolved
autotools.configure()
autotools.make()

def package(self):
self.copy("COPYING", src=self._source_subfolder, dst="licenses")
with self._build_context():
autotools = self._configure_autotools()
autotools.install()
copy(self,"COPYING", src=self.source_folder, dst=os.path.join(self.package_folder, "licenses"))
autotools = Autotools(self)
autotools.install()

tools.remove_files_by_mask(os.path.join(self.package_folder, "lib"), "*.la")
tools.rmdir(os.path.join(self.package_folder, "lib", "pkgconfig"))
rm(self, "*.la", os.path.join(self.package_folder, "lib"))
rmdir(self, os.path.join(self.package_folder, "lib", "pkgconfig"))
Jihadist marked this conversation as resolved.
Show resolved Hide resolved

def package_id(self):
del self.info.options.default
Expand Down