-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
112 additions
and
69 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,94 +1,104 @@ | ||
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.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": True, | ||
} | ||
|
||
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"): | ||
if self.settings.os == "Windows" or is_apple_os(self): | ||
# FIXME: Visual Studio project & Mac support seems available in resiprocate | ||
raise ConanInvalidConfiguration("reSIProcate recipe does not currently support {}.".format(self.settings.os)) | ||
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 <4]") | ||
if self.options.with_postgresql: | ||
self.requires("libpq/14.2") | ||
self.requires("libpq/15.3") | ||
if self.options.with_mysql: | ||
self.requires("libmysqlclient/8.0.29") | ||
self.requires("libmysqlclient/8.0.31") | ||
|
||
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): | ||
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", src=self.source_folder, dst=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.output.info(f"Appending PATH environment variable: {bin_path}") | ||
self.env_info.PATH.append(os.path.join(self.package_folder, "bin")) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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/) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |