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
Show file tree
Hide file tree
Changes from 14 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
130 changes: 66 additions & 64 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.apple import fix_apple_shared_install_name
from conan.tools.files import copy, get, rm, rmdir, export_conandata_patches, apply_conandata_patches
Jihadist 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
import os


Expand Down Expand Up @@ -36,14 +41,7 @@ class LibVertoConan(ConanFile):
}
settings = "os", "arch", "compiler", "build_type"

exports_sources = "patches/*"
generators = "pkg_config"

_autotools = None

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


@property
def _settings_build(self):
Expand All @@ -58,6 +56,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 +72,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 +91,15 @@ 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], strip_root=True)

def requirements(self):
if self.options.with_glib:
self.requires("glib/2.69.2")
self.requires("glib/2.75.2")
if self.options.with_libevent:
self.requires("libevent/2.1.12")
if self.options.with_libev:
Expand All @@ -106,62 +109,61 @@ 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 = []
if not self.conf.get("tools.gnu:pkg_config", check_type=str):
self.tool_requires("pkgconf/1.9.3")
self.tool_requires("libtool/2.4.7")
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):
self.run("{} -fiv".format(tools.get_env("AUTORECONF")), run_environment=True, win_bash=tools.os_info.is_windows)
with self._build_context():
autotools = self._configure_autotools()
autotools.make()
apply_conandata_patches(self)
autotools = Autotools(self)
Jihadist marked this conversation as resolved.
Show resolved Hide resolved
autotools.autoreconf()
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
fix_apple_shared_install_name(self)

def package_id(self):
del self.info.options.default
Expand Down
5 changes: 2 additions & 3 deletions recipes/libverto/all/test_package/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
cmake_minimum_required(VERSION 3.1)
project(test_package C)

include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake)
conan_basic_setup()
find_package(libverto REQUIRED CONFIG)

add_executable(${PROJECT_NAME} test_package.c)
target_link_libraries(${PROJECT_NAME} ${CONAN_LIBS})
target_link_libraries(${PROJECT_NAME} PRIVATE libverto::liberto)
prince-chrismc marked this conversation as resolved.
Show resolved Hide resolved
23 changes: 15 additions & 8 deletions recipes/libverto/all/test_package/conanfile.py
Original file line number Diff line number Diff line change
@@ -1,20 +1,27 @@
from conans import ConanFile, CMake, tools
from conan import ConanFile
from conan.tools.build import can_run
from conan.tools.cmake import CMake, cmake_layout
import os


class TestPackageConan(ConanFile):
settings = "os", "compiler", "build_type", "arch"
generators = "cmake"
settings = "os", "arch", "compiler", "build_type"
generators = "CMakeToolchain", "CMakeDeps", "VirtualRunEnv"
test_type = "explicit"

def layout(self):
cmake_layout(self)

def requirements(self):
self.requires(self.tested_reference_str)

def build(self):
cmake = CMake(self)
cmake.configure()
cmake.build()

def test(self):
if not tools.cross_building(self):
bin_path = os.path.join("bin", "test_package")

if can_run(self):
bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package")
for impl in self.deps_user_info["libverto"].backends.split(","):
self.run("{} {}".format(bin_path, impl), run_environment=True)

self.run("{} {}".format(bin_path, impl), env="conanrun")
8 changes: 8 additions & 0 deletions recipes/libverto/all/test_v1_package/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
cmake_minimum_required(VERSION 3.1)
project(test_package)

include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake)
conan_basic_setup(TARGETS)

add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/../test_package
${CMAKE_CURRENT_BINARY_DIR}/test_package)
20 changes: 20 additions & 0 deletions recipes/libverto/all/test_v1_package/conanfile.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
from conans import ConanFile, CMake, tools
import os


class TestPackageConan(ConanFile):
settings = "os", "compiler", "build_type", "arch"
generators = "cmake", "cmake_find_package_multi"

def build(self):
cmake = CMake(self)
cmake.configure()
cmake.build()

def test(self):
if not tools.cross_building(self):
bin_path = os.path.join("bin", "test_package")

for impl in self.deps_user_info["libverto"].backends.split(","):
self.run("{} {}".format(bin_path, impl), run_environment=True)

Jihadist marked this conversation as resolved.
Show resolved Hide resolved