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: add master snapshot #20465

Open
wants to merge 18 commits into
base: master
Choose a base branch
from
Open
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: 4 additions & 0 deletions recipes/resiprocate/cmake/conandata.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
sources:
"cci.20231127":
url: "https://github.com/resiprocate/resiprocate/archive/fcd0ba6fc8c421b9bebb92d75ce4f366878f29db.tar.gz"
sha256: "2049e5f6509f8404b89909fee1299dc4b2a5a84ad9ad1e653aca1dce475f5f5b"
157 changes: 157 additions & 0 deletions recipes/resiprocate/cmake/conanfile.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,157 @@
import os

from conan import ConanFile
from conan.errors import ConanInvalidConfiguration
from conan.tools.apple import is_apple_os
from conan.tools.build import check_min_cppstd, cross_building
from conan.tools.cmake import CMake, CMakeDeps, CMakeToolchain, cmake_layout
from conan.tools.env import VirtualBuildEnv
from conan.tools.files import apply_conandata_patches, copy, export_conandata_patches, get, rm, rmdir
from conan.tools.gnu import PkgConfigDeps
from conan.tools.microsoft import is_msvc
gjasny marked this conversation as resolved.
Show resolved Hide resolved
from conan.tools.scm import Version

required_conan_version = ">=1.53.0"


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."
)
license = "VSL-1.0"
url = "https://github.com/conan-io/conan-center-index"
homepage = "https://github.com/resiprocate/resiprocate/wiki/"
topics = ("sip", "voip", "communication", "signaling")

package_type = "library"
settings = "os", "arch", "compiler", "build_type"
options = {
"shared": [True, False],
"fPIC": [True, False],
"with_cares": [True, False],
"with_ssl": [True, False],
}
default_options = {
"shared": False,
"fPIC": True,
"with_cares": True,
"with_ssl": True,
}

gjasny marked this conversation as resolved.
Show resolved Hide resolved
@property
def _min_cppstd(self):
return 11

@property
def _compilers_minimum_version(self):
return {
"apple-clang": "10",
"clang": "6",
"gcc": "7",
"msvc": "191",
"Visual Studio": "15",
}

def export_sources(self):
export_conandata_patches(self)

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

def configure(self):
if self.options.shared:
self.options.rm_safe("fPIC")

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

def requirements(self):
if self.options.with_cares:
self.requires("c-ares/1.22.1")
if self.options.with_ssl:
self.requires("openssl/[>=1.1 <4]")

def validate(self):
gjasny marked this conversation as resolved.
Show resolved Hide resolved
if self.settings.compiler.cppstd:
check_min_cppstd(self, self._min_cppstd)
minimum_version = self._compilers_minimum_version.get(str(self.settings.compiler), False)
if minimum_version and Version(self.settings.compiler.version) < minimum_version:
raise ConanInvalidConfiguration(
f"{self.ref} requires C++{self._min_cppstd}, which your compiler does not support."
)
if is_msvc(self) and self.options.shared:
raise ConanInvalidConfiguration(f"{self.ref} can not be built as shared on Visual Studio and msvc.")

def build_requirements(self):
if not self.conf.get("tools.gnu:pkg_config", check_type=str):
self.tool_requires("pkgconf/2.0.3")

def source(self):
get(self, **self.conan_data["sources"][self.version], strip_root=True)

def generate(self):
tc = CMakeToolchain(self)
tc.variables["BUILD_DSO_PLUGINS"] = False
tc.variables["BUILD_QPID_PROTON"] = False
tc.variables["BUILD_REPRO"] = False
tc.variables["BUILD_RETURN"] = False
tc.variables["ENABLE_LOG_REPOSITORY_DETAILS"] = False
tc.variables["REGENERATE_MEDIA_SAMPLES"] = False
tc.variables["RESIP_ASSERT_SYSLOG"] = False
tc.variables["USE_CONTRIB"] = False
tc.variables["USE_DTLS"] = self.options.with_ssl
tc.variables["USE_NUGET"] = False
tc.variables["VERSIONED_SONAME"] = False
tc.variables["WITH_C_ARES"] = self.options.with_cares
tc.variables["WITH_SSL"] = self.options.with_ssl
if self.settings.os in ["Linux"]:
tc.preprocessor_definitions["RESIP_RANDOM_THREAD_LOCAL"] = True
if cross_building(self):
tc.cache_variables["HAVE_CLOCK_GETTIME_MONOTONIC"] = not self.settings.os in ["Windows"]
tc.generate()
tc = PkgConfigDeps(self)
tc.generate()
tc = CMakeDeps(self)
tc.generate()
tc = VirtualBuildEnv(self)
tc.generate(scope="build")

def _patch_sources(self):
apply_conandata_patches(self)

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

def package(self):
copy(self, "COPYING", src=self.source_folder, dst=os.path.join(self.package_folder, "licenses"))
cmake = CMake(self)
cmake.install()

rmdir(self, os.path.join(self.package_folder, "lib", "pkgconfig"))
rmdir(self, os.path.join(self.package_folder, "lib", "cmake"))
rmdir(self, os.path.join(self.package_folder, "share"))
rm(self, "*.la", os.path.join(self.package_folder, "lib"))
rm(self, "*.pdb", os.path.join(self.package_folder, "lib"))
rm(self, "*.pdb", os.path.join(self.package_folder, "bin"))

def package_info(self):
resiprocate_lib = "resiprocate" if self.settings.os == "Windows" else "resip"
self.cpp_info.libs = [resiprocate_lib, "rutil", "dum"]
if not self.options.with_cares:
self.cpp_info.libs.append("resipares")
if is_apple_os(self):
self.cpp_info.frameworks.append("CoreFoundation")
self.cpp_info.frameworks.append("CoreServices")
self.cpp_info.frameworks.append("Security")
if self.settings.os in ["Linux", "FreeBSD"]:
self.cpp_info.system_libs.append("m")
self.cpp_info.system_libs.append("pthread")
elif self.settings.os in ["Windows"]:
self.cpp_info.system_libs.append("winmm")
self.cpp_info.system_libs.append("ws2_32")
8 changes: 8 additions & 0 deletions recipes/resiprocate/cmake/test_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 LANGUAGES CXX)

find_package(resiprocate REQUIRED CONFIG)

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


class TestPackageConan(ConanFile):
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 can_run(self):
bin_path = os.path.join(self.cpp.build.bindir, "test_package")
self.run(bin_path, env="conanrun")
71 changes: 71 additions & 0 deletions recipes/resiprocate/cmake/test_package/test_package.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
#include <resip/stack/SipMessage.hxx>
#include <resip/stack/Helper.hxx>
#include <rutil/Logger.hxx>
#include <iostream>

#define RESIPROCATE_SUBSYSTEM Subsystem::TEST

using namespace resip;

std::string sipRawData = "INVITE sip:nikolia@example.ru SIP/2.0\r\n"
"Record-Route: <sip:nikolia@10.0.0.10;lr>\r\n"
"Via: SIP/2.0/UDP 10.0.0.10;branch=z9hG4bK3af7.0a6e92f4.0\r\n"
"Via: SIP/2.0/UDP 192.168.0.2:5060;branch=z9hG4bK12ee92cb;rport=5060\r\n"
"From: \"78128210000\" <sip:78128210000@neutral.ru>;tag=as149b2d97\r\n"
"To: <sip:nikolia@example.ru>\r\n"
"Contact: <sip:78128210000@neutral.ru>\r\n"
"Call-ID: 3cbf958e6f43d91905c3fa964a373dcb@example.ru\r\n"
"CSeq: 103 INVITE\r\n"
"Max-Forwards: 16\r\n"
"Date: Wed, 10 Jan 2001 13:16:23 GMT\r\n"
"Allow: INVITE, ACK, CANCEL, OPTIONS, BYE, REFER, SUBSCRIBE, NOTIFY\r\n"
"Supported: replaces\r\n"
"Content-Type: application/sdp\r\n"
"Content-Length: 394\r\n"
"\r\n"
"v=0\r\n"
"o=root 3303 3304 IN IP4 10.0.0.10\r\n"
"s=session\r\n"
"c=IN IP4 10.0.0.10\r\n"
"t=0 0\r\n"
"m=audio 40358 RTP/AVP 0 8 101\r\r\n"
"a=rtpmap:0 PCMU/8000\r\n"
"a=rtpmap:8 PCMA/8000\r\n"
"a=rtpmap:101 telephone-event/8000\r\n"
"a=fmtp:101 0-16\r\n"
"a=silenceSupp:off - - - -\r\n"
"a=sendrecv\r\n";

int main(int argc, char* argv[])
{
Log::initialize(Log::Cout, Log::Warning, argv[0]);

SipMessage* msg = SipMessage::make(Data(Data::Share, sipRawData.data()), true);
if (!msg)
{
return 1;
}

std::cout << std::string(msg->methodStr().data()) << std::endl;
std::string headers = "";
for (int i = 0; i < Headers::Type::MAX_HEADERS; i++)
{
auto rawHeader = msg->getRawHeader(static_cast<Headers::Type>(i));
if (!rawHeader)
{
continue;
}
for (auto value : *rawHeader)
{
headers += std::string(value.getBuffer(), value.getLength());
}
headers += "\r\n";
}

std::cout << headers << std::endl;
std::cout << std::string(msg->getRawBody().getBuffer(), msg->getRawBody().getLength()) << std::endl;

delete msg;
return 0;
}

8 changes: 8 additions & 0 deletions recipes/resiprocate/cmake/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/cmake/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)
2 changes: 2 additions & 0 deletions recipes/resiprocate/config.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
versions:
"cci.20231127":
folder: cmake
"1.12.0":
folder: all