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 HFSM2 Recipe #22647

Open
wants to merge 11 commits into
base: master
Choose a base branch
from
4 changes: 4 additions & 0 deletions recipes/hfsm2/all/conandata.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
sources:
"2.5.2":
url: "https://github.com/andrew-gresyk/HFSM2/archive/refs/tags/2.5.2.tar.gz"
sha256: "b5a35ce065ea3e32cf9cda48813877e35526a0e377b9344f726d1d80aeaeaa5d"
40 changes: 40 additions & 0 deletions recipes/hfsm2/all/conanfile.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
import os

from conan import ConanFile
from conan.tools.files import copy
from conan.tools.build import check_min_cppstd
from conan.tools.layout import basic_layout
from conan.tools.files import get

required_conan_version = ">=2.0"

class Hfsm2Conan(ConanFile):
name = "hfsm2"
description = "High-Performance Hierarchical Finite State Machine Framework"
license = "MIT"
topics = ("embedded", "fsm", "state-machine", "cpp", "modern-cpp", "game-development",
"cpp11", "embedded-systems", "template-metaprogramming", "header-only",
"mit-license", "fsm-library", "hierarchical-state-machine", "game-dev", "hfsm")
homepage = "https://hfsm.dev/"
url = "https://github.com/conan-io/conan-center-index"

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

def layout(self):
basic_layout(self, src_folder="src")

def validate(self):
check_min_cppstd(self, 11)

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

def package(self):
copy(self, "LICENSE", self.source_folder, os.path.join(self.package_folder, "licenses"))
copy(self, "*.hpp", os.path.join(self.source_folder, "include"), os.path.join(self.package_folder, "include"))

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

find_package(hfsm2 REQUIRED CONFIG)

add_executable(example example.cpp)
target_link_libraries(example PRIVATE hfsm2::hfsm2)
26 changes: 26 additions & 0 deletions recipes/hfsm2/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"
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, "example")
self.run(bin_path, env="conanrun")
20 changes: 20 additions & 0 deletions recipes/hfsm2/all/test_package/example.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#include <cstdlib>
#include <iostream>
#include <hfsm2/machine.hpp>

struct Context{};

using Config = hfsm2::Config::ContextT<Context&>;
using M = hfsm2::MachineT<Config>;
using FSM = M::PeerRoot<struct State>;

struct State : FSM::State {};


int main(void) {
Context context;
FSM::Instance machine{context};
machine.update();
std::cout << "[HFSM2] Test package passed with success." << std::endl;
return EXIT_SUCCESS;
}
3 changes: 3 additions & 0 deletions recipes/hfsm2/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
versions:
"2.5.2":
folder: all