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

resiprocate: migrate to Conan v2 #18956

Merged
merged 16 commits into from
May 9, 2024
Merged
Show file tree
Hide file tree
Changes from all 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
4 changes: 2 additions & 2 deletions recipes/resiprocate/all/conandata.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
sources:
"1.12.0":
url: https://www.resiprocate.org/files/pub/reSIProcate/releases/resiprocate-1.12.0.tar.gz
sha256: 046826503d3c8682ae0e42101b28f903c5f988235f1ff4a98dbfb9066d0d3d49
url: "https://github.com/resiprocate/resiprocate/archive/refs/tags/resiprocate-1.12.0.tar.gz"
sha256: "aa8906082e4221bffbfab3210df68a6ba1f57ba1532d89ea4572b4fa9877914f"
128 changes: 70 additions & 58 deletions recipes/resiprocate/all/conanfile.py
Original file line number Diff line number Diff line change
@@ -1,94 +1,106 @@
import os
from conans import ConanFile, AutoToolsBuildEnvironment, tools
from conans.errors import ConanInvalidConfiguration

from conan import ConanFile
from conan.errors import ConanInvalidConfiguration
from conan.tools.apple import is_apple_os
from conan.tools.build import cross_building
from conan.tools.env import VirtualRunEnv
from conan.tools.files import copy, get, rm, rmdir, chdir
from conan.tools.gnu import Autotools, AutotoolsToolchain, AutotoolsDeps
from conan.tools.layout import basic_layout

required_conan_version = ">=1.53.0"

required_conan_version = ">=1.29.1"

class ResiprocateConan(ConanFile):
name = "resiprocate"
description = "The project is dedicated to maintaining a complete, correct, and commercially usable implementation of SIP and a few related protocols. "
topics = ("sip", "voip", "communication", "signaling")
url = "https://github.com/conan-io/conan-center-index"
homepage = "http://www.resiprocate.org"
description = (
"The project is dedicated to maintaining a complete, correct, "
"and commercially usable implementation of SIP and a few related protocols."
)
license = "VSL-1.0"
settings = "os", "compiler", "build_type", "arch"
options = {"fPIC": [True, False],
"shared": [True, False],
"with_ssl": [True, False],
"with_postgresql": [True, False],
"with_mysql": [True, False]}
default_options = {"fPIC": True,
"shared": False,
"with_ssl": True,
"with_postgresql": True,
"with_mysql": True}
_autotools = None
url = "https://github.com/conan-io/conan-center-index"
homepage = "https://github.com/resiprocate/resiprocate/wiki/"
topics = ("sip", "voip", "communication", "signaling")

@property
def _source_subfolder(self):
return "source_subfolder"
package_type = "library"
settings = "os", "arch", "compiler", "build_type"
options = {
"shared": [True, False],
"fPIC": [True, False],
"with_ssl": [True, False],
"with_postgresql": [True, False],
"with_mysql": [True, False],
}
default_options = {
"shared": False,
"fPIC": True,
"with_ssl": True,
"with_postgresql": True,
"with_mysql": False,
}

def config_options(self):
if self.settings.os == 'Windows':
if self.settings.os == "Windows":
del self.options.fPIC

def configure(self):
if self.settings.os in ("Windows", "Macos"):
# FIXME: Visual Studio project & Mac support seems available in resiprocate
raise ConanInvalidConfiguration("reSIProcate recipe does not currently support {}.".format(self.settings.os))
if self.settings.os == "Windows" or is_apple_os(self):
# FIXME: unreleased versions of resiprocate use CMake and should support Windows and macOS
raise ConanInvalidConfiguration(f"reSIProcate recipe does not currently support {self.settings.os}.")
if self.options.shared:
del self.options.fPIC
self.options.rm_safe("fPIC")

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

def requirements(self):
if self.options.with_ssl:
self.requires("openssl/1.1.1q")
self.requires("openssl/1.1.1w") # OpenSSL 3.x is not supported
if self.options.with_postgresql:
self.requires("libpq/14.2")
self.requires("libpq/15.4")
if self.options.with_mysql:
self.requires("libmysqlclient/8.0.29")
self.requires("libmysqlclient/8.1.0")

def source(self):
tools.get(**self.conan_data["sources"][self.version])
os.rename("{}-{}".format(self.name, self.version), self._source_subfolder)

def _configure_autotools(self):
if self._autotools:
return self._autotools
self._autotools = AutoToolsBuildEnvironment(self)
yes_no = lambda v: "yes" if v else "no"
configure_args = [
"--enable-shared={}".format(yes_no(self.options.shared)),
"--enable-static={}".format(yes_no(not self.options.shared)),
"--with-pic={}".format(yes_no(self.options.get_safe("fPIC", True)))
]
get(self, **self.conan_data["sources"][self.version], strip_root=True)

def generate(self):
if not cross_building(self):
venv = VirtualRunEnv(self)
venv.generate(scope="build")
tc = AutotoolsToolchain(self)
# These options do not support yes/no
if self.options.with_ssl:
configure_args.append("--with-ssl")
tc.configure_args.append("--with-ssl")
if self.options.with_mysql:
configure_args.append("--with-mysql")
tc.configure_args.append("--with-mysql")
if self.options.with_postgresql:
configure_args.append("--with-postgresql")

self._autotools.configure(configure_dir=self._source_subfolder, args=configure_args)
return self._autotools
tc.configure_args.append("--with-postgresql")
tc.generate()
deps = AutotoolsDeps(self)
deps.generate()

def build(self):
autotools = self._configure_autotools()
autotools.make()
with chdir(self, self.source_folder):
autotools = Autotools(self)
autotools.autoreconf()
autotools.configure()
autotools.make()

def package(self):
self.copy("COPYING", src=self._source_subfolder, dst="licenses")
autotools = self._configure_autotools()
autotools.install()
tools.rmdir(os.path.join(os.path.join(self.package_folder, "share")))
tools.remove_files_by_mask(os.path.join(self.package_folder), "*.la")
copy(self, "COPYING", self.source_folder, os.path.join(self.package_folder, "licenses"))
with chdir(self, self.source_folder):
autotools = Autotools(self)
autotools.install()
rmdir(self, os.path.join(os.path.join(self.package_folder, "share")))
rm(self, "*.la", os.path.join(self.package_folder), recursive=True)

def package_info(self):
self.cpp_info.libs = ["resip", "rutil", "dum", "resipares"]
if self.settings.os in ("Linux", "FreeBSD"):
self.cpp_info.system_libs = ["pthread"]

# TODO: Legacy, to be removed on Conan 2.0
bin_path = os.path.join(self.package_folder, "bin")
self.output.info("Appending PATH environment variable: {}".format(bin_path))
self.env_info.PATH.append(os.path.join(self.package_folder, "bin"))
self.env_info.PATH.append(bin_path)
9 changes: 4 additions & 5 deletions recipes/resiprocate/all/test_package/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
cmake_minimum_required(VERSION 3.1)
project(test_package)
cmake_minimum_required(VERSION 3.15)
project(test_package LANGUAGES CXX)

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

add_executable(${PROJECT_NAME} test_package.cpp)
target_link_libraries(${PROJECT_NAME} ${CONAN_LIBS})
target_link_libraries(${PROJECT_NAME} PRIVATE resiprocate::resiprocate)
set_property(TARGET ${PROJECT_NAME} PROPERTY CXX_STANDARD 11)
21 changes: 15 additions & 6 deletions recipes/resiprocate/all/test_package/conanfile.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,26 @@
from conan import ConanFile
from conan.tools.build import can_run
from conan.tools.cmake import cmake_layout, CMake
import os

from conans import ConanFile, CMake, tools

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

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

def layout(self):
cmake_layout(self)

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

def test(self):
if not tools.cross_building(self.settings):
bin_path = os.path.join("bin", "test_package")
self.run(bin_path, run_environment=True)
if can_run(self):
bin_path = os.path.join(self.cpp.build.bindir, "test_package")
self.run(bin_path, env="conanrun")
8 changes: 8 additions & 0 deletions recipes/resiprocate/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.15)
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/)
17 changes: 17 additions & 0 deletions recipes/resiprocate/all/test_v1_package/conanfile.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import os

from conans import ConanFile, CMake, tools

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.settings):
bin_path = os.path.join("bin", "test_package")
self.run(bin_path, run_environment=True)