-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
(#20151) add package for the rocket library
* add package for the rocket library * Added support for conan V1, add verify and license * Fix compilation erron on linux * Fix min cppstd version * Force fixed straction of license * Fixed compilation issues on different versions * Add check for minimum compiler support * Resolved threads --------- Co-authored-by: PerseoGI <[email protected]> Co-authored-by: Rubén Rincón Blanco <[email protected]>
- Loading branch information
1 parent
3119604
commit 2874bcd
Showing
7 changed files
with
151 additions
and
0 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 |
---|---|---|
@@ -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" | ||
patch_source: "https://github.com/tripleslash/rocket/issues/10" |
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,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 | ||
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 = [] | ||
|
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,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 | ||
|
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 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) |
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,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") |
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,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; | ||
} |
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,3 @@ | ||
versions: | ||
"cci.20200603": | ||
folder: "all" |