Skip to content

Commit

Permalink
(#14295) libverto: Update dependencies
Browse files Browse the repository at this point in the history
* Update dependencies

* update recipe

* update generate

* without msvc

* Fix build folder

* Fix licenses and *.pc

* Apply suggestions from code review

Co-authored-by: Chris Mc <prince.chrismc@gmail.com>

* Update recipes/libverto/all/conanfile.py

Co-authored-by: SpaceIm <30052553+SpaceIm@users.noreply.github.com>

* Apply suggestions from code review

Co-authored-by: SpaceIm <30052553+SpaceIm@users.noreply.github.com>

* Apply suggestions from code review

* Update test packages

* Update recipes/libverto/all/test_package/CMakeLists.txt

Co-authored-by: SpaceIm <30052553+SpaceIm@users.noreply.github.com>

* Apply suggestions from code review

Co-authored-by: SpaceIm <30052553+SpaceIm@users.noreply.github.com>

* Apply suggestions from code review

Co-authored-by: SpaceIm <30052553+SpaceIm@users.noreply.github.com>

* Update recipes/libverto/all/test_package/CMakeLists.txt

* * bump version. remove AutotoolsDeps

* Apply suggestions from code review

Co-authored-by: SpaceIm <30052553+SpaceIm@users.noreply.github.com>

* Update recipes/libverto/all/conanfile.py

Co-authored-by: SpaceIm <30052553+SpaceIm@users.noreply.github.com>

---------

Co-authored-by: Anonymous Maarten <anonymous.maarten@gmail.com>
Co-authored-by: Chris Mc <prince.chrismc@gmail.com>
Co-authored-by: SpaceIm <30052553+SpaceIm@users.noreply.github.com>
  • Loading branch information
4 people committed Feb 16, 2023
1 parent 80feb99 commit 1dc284d
Show file tree
Hide file tree
Showing 5 changed files with 96 additions and 76 deletions.
117 changes: 52 additions & 65 deletions recipes/libverto/all/conanfile.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,15 @@
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
from conan.tools.env import VirtualBuildEnv
from conan.tools.gnu import Autotools, AutotoolsToolchain, PkgConfigDeps
from conan.tools.microsoft import is_msvc
from conan.tools.layout import basic_layout
import os


required_conan_version = ">=1.33.0"
required_conan_version = ">=1.54.0"


class LibVertoConan(ConanFile):
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,46 @@ 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)}",
])
tc.generate()
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)
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"))
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::libverto)
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)
19 changes: 19 additions & 0 deletions recipes/libverto/all/test_v1_package/conanfile.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
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)

0 comments on commit 1dc284d

Please sign in to comment.