Skip to content

Commit

Permalink
resiprocate: add master snapshot
Browse files Browse the repository at this point in the history
  • Loading branch information
gjasny committed Oct 9, 2023
1 parent 165418f commit 3ac4188
Show file tree
Hide file tree
Showing 8 changed files with 240 additions and 0 deletions.
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.20231009":
url: "https://github.com/resiprocate/resiprocate/archive/dadcf4baffea26b979e2c082a4d1a0f128b1b1fe.tar.gz"
sha256: "bf42a3719f62049e34a6d8ea0f6e6535c806fee7965966b3f9b757ab6bf5b8ab"
104 changes: 104 additions & 0 deletions recipes/resiprocate/cmake/conanfile.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
import os

from conan import ConanFile
from conan.errors import ConanInvalidConfiguration

Check warning on line 4 in recipes/resiprocate/cmake/conanfile.py

View workflow job for this annotation

GitHub Actions / Lint changed conanfile.py (v2 migration)

Unused ConanInvalidConfiguration imported from conan.errors
from conan.tools.cmake import CMake, CMakeDeps, CMakeToolchain, cmake_layout
from conan.tools.env import VirtualBuildEnv
from conan.tools.files import copy, get, rm, rmdir
from conan.tools.gnu import PkgConfigDeps

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_ssl": [True, False],
}
default_options = {
"shared": False,
"fPIC": True,
"with_ssl": True,
}

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):
self.requires("c-ares/1.19.1")
if self.options.with_ssl:
self.requires("openssl/[>=1.1 <4]")

def build_requirements(self):
if not self.conf.get("tools.gnu:pkg_config", check_type=str):
self.tool_requires("pkgconf/1.9.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["WITH_C_ARES"] = True
tc.variables["WITH_SSL"] = self.options.with_ssl
if self.settings.os in ["Linux"]:
tc.preprocessor_definitions["RESIP_RANDOM_THREAD_LOCAL"] = True
tc.generate()
tc = PkgConfigDeps(self)
tc.generate()
tc = CMakeDeps(self)
tc.generate()
tc = VirtualBuildEnv(self)
tc.generate(scope="build")

def build(self):
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):
self.cpp_info.libs = ["resip", "rutil", "dum"]
if self.settings.os in ["Linux", "FreeBSD"]:
self.cpp_info.system_libs = ["pthread"]
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.20231009":
folder: cmake
"1.12.0":
folder: all

0 comments on commit 3ac4188

Please sign in to comment.