-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
base: master
Are you sure you want to change the base?
Add HFSM2 Recipe #22647
Changes from 3 commits
fa5c69b
76a4af0
0a747c2
a1ef894
c782447
ddb152e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
sources: | ||
"2.5.0": | ||
url: "https://github.com/andrew-gresyk/HFSM2/archive/refs/tags/2.5.0.zip" | ||
sha256: "e295f8bccacc9d40eb04f08414e5abe623913453bad1d2b5b70210bf8080b309" | ||
"2.4.0": | ||
url: "https://github.com/andrew-gresyk/HFSM2/archive/refs/tags/2.4.0.zip" | ||
sha256: "d9863aa7cd0ff1ba2c451dcb256e1275c6e6e6619c3809ef92da831493e2b7ca" |
Original file line number | Diff line number | Diff line change | ||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
@@ -0,0 +1,44 @@ | ||||||||||||||||
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.16" | ||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
Conan 1.x support is still mandatory in CCI. |
||||||||||||||||
|
||||||||||||||||
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" | ||||||||||||||||
exports_sources = "include/*" | ||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
That's only required when export from source, which means, both recipe and source are the same repository. As example: https://docs.conan.io/2/tutorial/developing_packages/local_package_development_flow.html |
||||||||||||||||
settings = "os", "arch", "compiler", "build_type" | ||||||||||||||||
no_copy_source = True | ||||||||||||||||
|
||||||||||||||||
def layout(self): | ||||||||||||||||
basic_layout(self, src_folder="src") | ||||||||||||||||
|
||||||||||||||||
def validate(self): | ||||||||||||||||
if self.settings.compiler.get_safe("cppstd"): | ||||||||||||||||
check_min_cppstd(self, 11) | ||||||||||||||||
|
||||||||||||||||
def source(self): | ||||||||||||||||
get(self, **self.conan_data["sources"][self.version], strip_root=True) | ||||||||||||||||
|
||||||||||||||||
def package(self): | ||||||||||||||||
# This will also copy the "include" folder | ||||||||||||||||
copy(self, os.path.join(self.exports_sources, "*.hpp"), self.source_folder, self.package_folder) | ||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||||||||
|
||||||||||||||||
def package_info(self): | ||||||||||||||||
# For header-only packages, libdirs and bindirs are not used | ||||||||||||||||
# so it's necessary to set those as empty. | ||||||||||||||||
self.cpp_info.bindirs = [] | ||||||||||||||||
self.cpp_info.libdirs = [] | ||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
Please, add an empty line to avoid future errors with git diff. Plus, template comments are not really needed. |
Original file line number | Diff line number | Diff line change | ||||||
---|---|---|---|---|---|---|---|---|
@@ -0,0 +1,8 @@ | ||||||||
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) | ||||||||
set_property(TARGET example PROPERTY CXX_STANDARD 11) | ||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
Missing empty EOL. To the CI, it's an error. |
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") | ||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
Missing empty EOL. To the CI, it's an error. |
Original file line number | Diff line number | Diff line change | ||||||
---|---|---|---|---|---|---|---|---|
@@ -0,0 +1,45 @@ | ||||||||
#include <assert.h> | ||||||||
#include <hfsm2/machine.hpp> | ||||||||
|
||||||||
struct Context { | ||||||||
bool on = false; | ||||||||
}; | ||||||||
|
||||||||
using Config = hfsm2::Config | ||||||||
::ContextT<Context&>; | ||||||||
|
||||||||
using M = hfsm2::MachineT<Config>; | ||||||||
|
||||||||
using FSM = M::PeerRoot< | ||||||||
struct Off, | ||||||||
struct On | ||||||||
>; | ||||||||
|
||||||||
struct Off | ||||||||
: FSM::State | ||||||||
{ | ||||||||
void enter(PlanControl& control) { | ||||||||
control.context().on = false; | ||||||||
} | ||||||||
}; | ||||||||
|
||||||||
struct On | ||||||||
: FSM::State | ||||||||
{ | ||||||||
void enter(PlanControl& control) { | ||||||||
control.context().on = true; | ||||||||
} | ||||||||
}; | ||||||||
|
||||||||
int | ||||||||
main() { | ||||||||
Context context; | ||||||||
FSM::Instance machine{context}; | ||||||||
|
||||||||
machine.changeTo<On>(); | ||||||||
machine.update(); | ||||||||
|
||||||||
assert(context.on == true); | ||||||||
|
||||||||
return 0; | ||||||||
} | ||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
Missing empty EOL. To the CI, it's an error. |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
versions: | ||
"2.5.0": | ||
folder: all | ||
"2.4.0": | ||
folder: all |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do need both versions? Otherwise, I would ask adding only the latest to save the CI. In case someone asks 2.4.0, so no problem, we add it later.