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

add package for the rocket library #20151

Merged
merged 10 commits into from
Jun 18, 2024
Merged
10 changes: 10 additions & 0 deletions recipes/rocket/all/conandata.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
sources:
"cci.20200603":
url: "https://github.com/tripleslash/rocket/archive/348869fcda83f8b8b521c7654f83fea07ebe7a0a.tar.gz"
sha256: "de03b9c7f9b9478cfaa60683f95a7b0773dc0929d14e510c23f53b3804cc921f"
patches:
"cci.20200603":
- patch_file: "patches/0001-fix-thread_id.patch"
patch_description: "Fix compilation on different C++ std versions"
patch_type: "backport"

Check warning on line 9 in recipes/rocket/all/conandata.yml

View workflow job for this annotation

GitHub Actions / Lint changed files (YAML files)

conandata.yml schema warning

Schema outlined in https://github.com/conan-io/conan-center-index/blob/master/docs/adding_packages/conandata_yml_format.md#patches-fields is not followed. found arbitrary text in patch_type: backport ^ (line: 9)
perseoGI marked this conversation as resolved.
Show resolved Hide resolved
patch_source: "https://github.com/tripleslash/rocket/issues/10"
72 changes: 72 additions & 0 deletions recipes/rocket/all/conanfile.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
from conan import ConanFile
from conan.errors import ConanInvalidConfiguration
from conan.tools.build import check_min_cppstd
from conan.tools.files import apply_conandata_patches, copy, export_conandata_patches, get, load, save
from conan.tools.scm import Version
import os

required_conan_version = ">=1.53.0"


class RocketConan(ConanFile):
name = "rocket"
description = "Fast single header signal/slots library for C++"
license = "DocumentRef-README.md:LicenseRef-Rocket-public-domain"
url = "https://github.com/conan-io/conan-center-index"
homepage = "https://github.com/tripleslash/rocket"
topics = ("signal-slots", "observer-pattern", "header-only")
package_type = "header-library"
settings = "os", "compiler", "build_type", "arch"

@property
def _min_cppstd(self):
return 17

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

def export_sources(self):
export_conandata_patches(self)

def validate(self):
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."
)

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

def package_id(self):
self.info.clear()

def build(self):
apply_conandata_patches(self)

def _extract_license(self):
readme_content = load(self, os.path.join(self.source_folder, "README.md"))
first = readme_content.find("# rocket")
last = readme_content.find("signals2).")
license_content = readme_content[first:last+len("signals2).")]
# Make sure the extracted text from README has the license type
assert license_content.find("public-domain") != -1
AbrilRBS marked this conversation as resolved.
Show resolved Hide resolved
save(self, os.path.join(self.package_folder, "licenses", "LICENSE"), license_content)

def package(self):
self._extract_license()
copy(self, "rocket.hpp", self.build_folder, os.path.join(self.package_folder, "include"))

def package_info(self):
self.cpp_info.bindirs = []
self.cpp_info.libdirs = []

16 changes: 16 additions & 0 deletions recipes/rocket/all/patches/0001-fix-thread_id.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
diff --git a/rocket.hpp b/rocket.hpp
index 8c4e539..47d650a 100644
--- a/rocket.hpp
+++ b/rocket.hpp
@@ -2082,8 +2082,8 @@ namespace rocket

bool is_queued() const ROCKET_NOEXCEPT
{
- return thread_id != std::thread::id{}
- && thread_id != std::this_thread::get_id();
+ return !(thread_id == std::thread::id{})
+ && !(thread_id == std::this_thread::get_id());
}

#ifndef ROCKET_NO_BLOCKING_CONNECTIONS

8 changes: 8 additions & 0 deletions recipes/rocket/all/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(rocket REQUIRED CONFIG)

add_executable(${PROJECT_NAME} test_package.cpp)
target_link_libraries(${PROJECT_NAME} PRIVATE rocket::rocket)
target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_17)
26 changes: 26 additions & 0 deletions recipes/rocket/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, cmake_layout
import os


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

def layout(self):
cmake_layout(self)

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

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")
16 changes: 16 additions & 0 deletions recipes/rocket/all/test_package/test_package.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#include <cstdlib>
#include <rocket.hpp>
#include <iostream>

int main()
{
rocket::signal<int(int)> test;
test.connect([](int x)
{ return x * 3; });

constexpr int value = 2;

const auto result{test(value) == value * 3};
std::cout << "Rocket test success: " << std::boolalpha << result << '\n';
return result? EXIT_SUCCESS : EXIT_FAILURE;
}
3 changes: 3 additions & 0 deletions recipes/rocket/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
versions:
"cci.20200603":
folder: "all"
Loading