Skip to content

Commit 3e92575

Browse files
committed
Add initial version of Conan package for sml library
1 parent 30c8e3a commit 3e92575

File tree

4 files changed

+115
-0
lines changed

4 files changed

+115
-0
lines changed

conanfile.py

+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
#!/usr/bin/env python
2+
# -*- coding: utf-8 -*-
3+
4+
import os
5+
from conans import ConanFile, tools
6+
7+
8+
class SmlConan(ConanFile):
9+
name = "sml"
10+
version = "1.1.0"
11+
license = "MIT"
12+
author = "Alexander Zaitsev [email protected]"
13+
url = "https://github.com/ZaMaZaN4iK/conan-sml"
14+
homepage = "https://github.com/boost-experimental/sml"
15+
description = "[Boost].SML: C++14 State Machine Library"
16+
topics = ("sml", "boost", "metaprogramming", "design-patterns", "state-machine")
17+
no_copy_sources = True
18+
19+
_source_subfolder = "source_subfolder"
20+
21+
def source(self):
22+
checksum = "5b51a0b0318fb155c65621f77179ae80f61d136789ea749dde18c4a1fca51a74"
23+
tools.get("{0}/archive/v{1}.tar.gz".format(self.homepage, self.version), sha256=checksum)
24+
extracted_dir = self.name + "-" + self.version
25+
os.rename(extracted_dir, self._source_subfolder)
26+
27+
def package(self):
28+
self.copy("*hpp", dst="include", src=os.path.join(self._source_subfolder, "include"))
29+
30+
def package_info(self):
31+
self.info.header_only()

test_package/CMakeLists.txt

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
cmake_minimum_required(VERSION 2.8.12)
2+
project(PackageTest CXX)
3+
4+
include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake)
5+
conan_basic_setup()
6+
7+
add_executable(example example.cpp)
8+
target_link_libraries(example ${CONAN_LIBS})
9+
10+
# CTest is a testing tool that can be used to test your project.
11+
# enable_testing()
12+
# add_test(NAME example
13+
# WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/bin
14+
# COMMAND example)

test_package/conanfile.py

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
import os
2+
3+
from conans import ConanFile, CMake, tools
4+
5+
6+
class SmlTestConan(ConanFile):
7+
settings = "os", "compiler", "build_type", "arch"
8+
generators = "cmake"
9+
10+
def build(self):
11+
cmake = CMake(self)
12+
# Current dir is "test_package/build/<build_id>" and CMakeLists.txt is
13+
# in "test_package"
14+
cmake.configure()
15+
cmake.build()
16+
17+
def imports(self):
18+
self.copy("*.dll", dst="bin", src="bin")
19+
self.copy("*.dylib*", dst="bin", src="lib")
20+
self.copy('*.so*', dst='bin', src='lib')
21+
22+
def test(self):
23+
if not tools.cross_building(self.settings):
24+
os.chdir("bin")
25+
self.run(".%sexample" % os.sep)

test_package/example.cpp

+45
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
//
2+
// Copyright (c) 2016-2019 Kris Jusiak (kris at jusiak dot net)
3+
//
4+
// Distributed under the Boost Software License, Version 1.0.
5+
// (See accompanying file LICENSE_1_0.txt or copy at
6+
// http://www.boost.org/LICENSE_1_0.txt)
7+
//
8+
9+
#include <boost/sml.hpp>
10+
#include <cassert>
11+
#include <iostream>
12+
13+
namespace sml = boost::sml;
14+
15+
namespace {
16+
struct e1 {};
17+
struct e2 {};
18+
struct e3 {};
19+
20+
struct states {
21+
auto operator()() const noexcept {
22+
using namespace sml;
23+
const auto idle = state<class idle>;
24+
// clang-format off
25+
return make_transition_table(
26+
*idle + event<e1> = "s1"_s
27+
, "s1"_s + sml::on_entry<_> / [] { std::cout << "s1 on entry" << std::endl; }
28+
, "s1"_s + sml::on_exit<_> / [] { std::cout << "s1 on exit" << std::endl; }
29+
, "s1"_s + event<e2> = state<class s2>
30+
, state<class s2> + event<e3> = X
31+
);
32+
// clang-format on
33+
}
34+
};
35+
} // namespace
36+
37+
int main() {
38+
sml::sm<states> sm;
39+
sm.process_event(e1{});
40+
sm.process_event(e2{});
41+
sm.process_event(e3{});
42+
assert(sm.is(sml::X));
43+
44+
return 0;
45+
}

0 commit comments

Comments
 (0)