Skip to content

add package qpid-proton 0.40.0 #26525

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

Open
wants to merge 1 commit 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/qpid-proton/all/conandata.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
sources:
"0.40.0":
url: "https://github.com/apache/qpid-proton/archive/refs/tags/0.40.0.tar.gz"
sha256: "f3dcd30e85626d8eff13a98009f0b75b2a4d0cbf91520830a67202157dc63d6d"
154 changes: 154 additions & 0 deletions recipes/qpid-proton/all/conanfile.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,154 @@
from conan import ConanFile
from conan.tools.build import check_min_cppstd
from conan.tools.cmake import CMake, CMakeDeps, CMakeToolchain, cmake_layout
from conan.tools.files import copy, export_conandata_patches, get, rmdir
from conan.tools.microsoft import is_msvc

import os

required_conan_version = ">=2.1.0"

class QpidProtonConan(ConanFile):
version = "0.40.0"
name = "qpid-proton"
description = "Qpid Proton is a high-performance, lightweight messaging library."
license = "Apache-2.0"
url = "https://github.com/conan-io/conan-center-index"
homepage = "https://qpid.apache.org/proton/"
topics = ("conan", "qpid", "proton", "messaging", "message", "queue", "topic", "mq", "amqp")
package_type = "library"
settings = "os", "arch", "compiler", "build_type"
options = {
"shared": [True, False],
"fPIC": [True, False],
"tools": [True, False],
"tls": [True, False],
"with_opentelemetry": [True, False],
}
default_options = {
"shared": False,
"fPIC": True,
"tools": False,
"tls": True,
"with_opentelemetry": True,
}

@property
def _min_cppstd(self):
return "14"

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):
self.requires("openssl/3.3.2")
self.requires("cyrus-sasl/2.1.28")
if self.options.with_opentelemetry:
self.requires("opentelemetry-cpp/1.14.2")
if self.settings.os == "Macos":
self.requires("libuv/1.49.2")

def validate(self):
if self.settings.compiler.get_safe("cppstd"):
check_min_cppstd(self, "14")

def build_requirements(self):
self.tool_requires("cmake/[>=3.16 <4]")
self.tool_requires("cpython/[>=3.9]")
if not self.conf.get("tools.gnu:pkg_config", check_type=str):
self.tool_requires("pkgconf/[>=1.7 <3]")

def source(self):
get(self, **self.conan_data["sources"][self.version], filename=f"{self.version}.tar.gz", strip_root=True)

def generate(self):
tc = CMakeToolchain(self)

tc.variables["BUILD_PYTHON"] = False
tc.variables["BUILD_RUBY"] = False
tc.variables["BUILD_GO"] = False

tc.variables["ENABLE_WARNING_ERROR"] = False
tc.variables["ENABLE_UNDEFINED_ERROR"] = False
tc.variables["ENABLE_LINKTIME_OPTIMIZATION"] = False
tc.variables["ENABLE_HIDE_UNEXPORTED_SYMBOLS"] = False
tc.variables["ENABLE_FUZZ_TESTING"] = False
tc.variables["ENABLE_BENCHMARKS"] = False

tc.variables["BUILD_STATIC_LIBS"] = not bool(self.options["shared"])

tc.variables["BUILD_TESTING"] = False
tc.variables["BUILD_TOOLS"] = bool(self.options["tools"])
tc.variables["BUILD_EXAMPLES"] = False
if self.settings.os == "Macos":
tc.variables["BUILD_TLS"] = False
else:
tc.variables["BUILD_TLS"] = bool(self.options["tls"])

tc.generate()

deps = CMakeDeps(self)
deps.set_property("libuv", "cmake_file_name", "Libuv")
deps.set_property("libuv", "cmake_target_name", "Libuv::Libuv")
deps.generate()

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

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

rmdir(self, os.path.join(self.package_folder, "lib", "cmake"))
rmdir(self, os.path.join(self.package_folder, "lib", "pkgconfig"))
rmdir(self, os.path.join(self.package_folder, "share"))

@property
def _module_subfolder(self):
return os.path.join("lib", "cmake")

def package_info(self):
self.cpp_info.set_property("cmake_file_name", "QpidProton")

suffix = "-static" if is_msvc(self) and not self.options.shared else ""

self.cpp_info.components["proton"].set_property("cmake_target_name", "Proton::proton")
self.cpp_info.components["proton"].libs = [f"qpid-proton{suffix}"]
self.cpp_info.components["proton"].requires = ["openssl::ssl", "cyrus-sasl::cyrus-sasl"]

self.cpp_info.components["core"].set_property("cmake_target_name", "Proton::core")
self.cpp_info.components["core"].libs = [f"qpid-proton-core{suffix}"]
self.cpp_info.components["core"].requires = ["openssl::ssl", "cyrus-sasl::cyrus-sasl"]

self.cpp_info.components["proactor"].set_property("cmake_target_name", "Proton::proactor")
self.cpp_info.components["proactor"].libs = [f"qpid-proton-proactor{suffix}"]
self.cpp_info.components["proactor"].requires = ["core"]

self.cpp_info.components["cpp"].set_property("cmake_target_name", "Proton::cpp")
self.cpp_info.components["cpp"].libs = [f"qpid-proton-cpp{suffix}"]
self.cpp_info.components["cpp"].requires = ["core", "proactor"]

if self.options["tls"] and self.settings.os != "Macos":
self.cpp_info.components["tls"].set_property("cmake_target_name", "Proton::tls")
self.cpp_info.components["tls"].libs = [f"qpid-proton-tls{suffix}"]

if self.settings.os == "Macos":
self.cpp_info.components["core"].requires.append("libuv::libuv")

if self.options["with_opentelemetry"]:
self.cpp_info.components["cpp"].requires.append("opentelemetry-cpp::opentelemetry-cpp")
10 changes: 10 additions & 0 deletions recipes/qpid-proton/all/test_package/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
cmake_minimum_required(VERSION 3.8)
project(test_package LANGUAGES CXX)

find_package(QpidProton REQUIRED CONFIG)

add_executable(${PROJECT_NAME} test_package.cpp)

target_link_libraries(${PROJECT_NAME} PRIVATE Proton::cpp)

target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_14)
26 changes: 26 additions & 0 deletions recipes/qpid-proton/all/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.bindirs[0], "test_package")
self.run(bin_path, env="conanrun")
74 changes: 74 additions & 0 deletions recipes/qpid-proton/all/test_package/test_package.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
/*
*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*
*/

#include <proton/connection.hpp>
#include <proton/container.hpp>
#include <proton/delivery.hpp>
#include <proton/message.hpp>
#include <proton/messaging_handler.hpp>
#include <proton/tracker.hpp>

#include <iostream>


class hello_world : public proton::messaging_handler {
std::string conn_url_;
std::string addr_;

public:
hello_world(const std::string& u, const std::string& a) :
conn_url_(u), addr_(a) {}

void on_container_start(proton::container& c) override {
c.connect(conn_url_);
}

void on_connection_open(proton::connection& c) override {
c.open_receiver(addr_);
c.open_sender(addr_);
}

void on_sendable(proton::sender &s) override {
proton::message m("Hello World!");
s.send(m);
s.close();
}

void on_message(proton::delivery &d, proton::message &m) override {
std::cout << m.body() << std::endl;
d.connection().close();
}
};

int main(int argc, char **argv) {
try {
std::string conn_url = argc > 1 ? argv[1] : "//127.0.0.1:5672";
std::string addr = argc > 2 ? argv[2] : "examples";

hello_world hw(conn_url, addr);
proton::container(hw).run();

} catch (const std::exception& e) {
std::cerr << e.what() << std::endl;
}

return 0;
}
3 changes: 3 additions & 0 deletions recipes/qpid-proton/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
versions:
"0.40.0":
folder: "all"