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

eventpp: new recipe #22611

Merged
merged 3 commits into from
Feb 1, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
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/eventpp/all/conandata.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
sources:
"0.1.3":
url: "https://github.com/wqking/eventpp/archive/v0.1.3.tar.gz"
sha256: "D87ABA67223FD9ACED2BA55EB82BD534007E43E1B919106A53FCD3070FA125EA"
54 changes: 54 additions & 0 deletions recipes/eventpp/all/conanfile.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
from conan import ConanFile
from conan.tools.files import get, copy, export_conandata_patches, apply_conandata_patches
from conan.tools.build import check_min_cppstd
from conan.tools.layout import basic_layout
import os

required_conan_version = ">=1.51.1"

class EventppConan(ConanFile):
name = "eventpp"
description = "Event Dispatcher and callback list for C++"
license = "Apache-2.0"
url = "https://github.com/conan-io/conan-center-index"
homepage = "https://github.com/wqking/eventpp"
topics = ("observer-pattern", "event-dispatcher", "signal", "slot", "publish-subscribe", "nested-events", "thread-safe", "header-only")

package_type = "header-library"
settings = "os", "arch", "compiler", "build_type"

@property
def _min_cppstd(self):
return 11

def export_sources(self):
export_conandata_patches(self)

AbrilRBS marked this conversation as resolved.
Show resolved Hide resolved
def layout(self):
basic_layout(self, src_folder="src")

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

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

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

def build(self):
apply_conandata_patches(self)

AbrilRBS marked this conversation as resolved.
Show resolved Hide resolved
def package(self):
copy(self, pattern="license",
dst=os.path.join(self.package_folder, "licenses"),
src=self.source_folder)
copy(self, pattern="*.h",
dst=os.path.join(self.package_folder, "include"),
src=os.path.join(self.source_folder, "include"),
)

def package_info(self):
self.cpp_info.bindirs = []
self.cpp_info.libdirs = []
8 changes: 8 additions & 0 deletions recipes/eventpp/all/test_package/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
cmake_minimum_required(VERSION 3.12)
project(test_package LANGUAGES CXX)

find_package(eventpp REQUIRED CONFIG)

add_executable(${PROJECT_NAME} test_package.cpp)
target_link_libraries(${PROJECT_NAME} PRIVATE eventpp::eventpp)
target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_11)
26 changes: 26 additions & 0 deletions recipes/eventpp/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")
14 changes: 14 additions & 0 deletions recipes/eventpp/all/test_package/test_package.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#include <eventpp/callbacklist.h>

int main(void) {
eventpp::CallbackList<void (const int, const bool)> callbackList;

callbackList.append([](const int i, const bool b) {
(void) i;
(void) b;
});

callbackList(1, true);

return 0;
}
9 changes: 9 additions & 0 deletions recipes/eventpp/all/test_v1_package/CMakeLists.txt
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No need for test_v1_packages for new recipes, but won't hurt if you leave it now that it's here :)

Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
cmake_minimum_required(VERSION 3.12)

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/)
18 changes: 18 additions & 0 deletions recipes/eventpp/all/test_v1_package/conanfile.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
from conans import ConanFile, CMake
from conan.tools.build import cross_building
import os


class TestPackageV1Conan(ConanFile):
settings = "os", "arch", "compiler", "build_type"
generators = "cmake", "cmake_find_package_multi"

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

def test(self):
if not cross_building(self):
bin_path = os.path.join("bin", "test_package")
self.run(bin_path, run_environment=True)
3 changes: 3 additions & 0 deletions recipes/eventpp/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
versions:
"0.1.3":
folder: all
Loading