forked from BehaviorTree/BehaviorTree.CPP
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
BehaviorTree#2 Conan package support
- Add conan recipe for BehaviorTree.CPP - Add build script for Appveyor - Add build script for Travis CI - Add dummy test package Signed-off-by: Uilian Ries <uilianries@gmail.com>
- Loading branch information
1 parent
c8092e3
commit 8c2055d
Showing
8 changed files
with
255 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,7 @@ | ||
cmake_minimum_required(VERSION 2.8.11) | ||
project(cmake_wrapper) | ||
|
||
include(conanbuildinfo.cmake) | ||
conan_basic_setup() | ||
|
||
include(${CMAKE_SOURCE_DIR}/CMakeListsOriginal.txt) |
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 @@ | ||
#!/usr/bin/env python | ||
# -*- coding: utf-8 -*- | ||
import os | ||
|
||
if os.getenv("APPVEYOR_REPO_TAG") != "true": | ||
print("Skip step. It's not TAG") | ||
else: | ||
os.system("pip install conan conan-package-tools") |
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,81 @@ | ||
#!/usr/bin/env python | ||
# -*- coding: utf-8 -*- | ||
|
||
import os | ||
import re | ||
from cpt.packager import ConanMultiPackager | ||
from cpt.ci_manager import CIManager | ||
from cpt.printer import Printer | ||
|
||
|
||
class BuilderSettings(object): | ||
@property | ||
def username(self): | ||
""" Set catchorg as package's owner | ||
""" | ||
return os.getenv("CONAN_USERNAME", "BehaviorTree") | ||
|
||
@property | ||
def login_username(self): | ||
""" Set Bintray login username | ||
""" | ||
return os.getenv("CONAN_LOGIN_USERNAME", "facontidavide") | ||
|
||
@property | ||
def upload(self): | ||
""" Set Catch2 repository to be used on upload. | ||
The upload server address could be customized by env var | ||
CONAN_UPLOAD. If not defined, the method will check the branch name. | ||
Only master or CONAN_STABLE_BRANCH_PATTERN will be accepted. | ||
The master branch will be pushed to testing channel, because it does | ||
not match the stable pattern. Otherwise it will upload to stable | ||
channel. | ||
""" | ||
return os.getenv("CONAN_UPLOAD", "https://api.bintray.com/conan/facontidavide/Catch2") | ||
|
||
@property | ||
def upload_only_when_stable(self): | ||
""" Force to upload when running over tag branch | ||
""" | ||
return os.getenv("CONAN_UPLOAD_ONLY_WHEN_STABLE", "True").lower() in ["true", "1", "yes"] | ||
|
||
@property | ||
def stable_branch_pattern(self): | ||
""" Only upload the package the branch name is like a tag | ||
""" | ||
return os.getenv("CONAN_STABLE_BRANCH_PATTERN", r"v\d+\.\d+\.\d+") | ||
|
||
@property | ||
def reference(self): | ||
""" Read project version from branch create Conan referece | ||
""" | ||
return os.getenv("CONAN_REFERENCE", "Catch2/{}@{}/{}".format(self._branch, self.username, self.channel)) | ||
|
||
@property | ||
def channel(self): | ||
""" Default Conan package channel when not stable | ||
""" | ||
return os.getenv("CONAN_CHANNEL", "testing") | ||
|
||
@property | ||
def _branch(self): | ||
""" Get branch name from CI manager | ||
""" | ||
printer = Printer(None) | ||
ci_manager = CIManager(printer) | ||
return ci_manager.get_branch() | ||
|
||
|
||
if __name__ == "__main__": | ||
settings = BuilderSettings() | ||
builder = ConanMultiPackager( | ||
reference=settings.reference, | ||
channel=settings.channel, | ||
upload=settings.upload, | ||
upload_only_when_stable=settings.upload_only_when_stable, | ||
stable_branch_pattern=settings.stable_branch_pattern, | ||
login_username=settings.login_username, | ||
username=settings.username, | ||
test_folder=os.path.join(".conan", "test_package")) | ||
builder.add() | ||
builder.run() |
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,22 @@ | ||
#!/bin/bash | ||
|
||
set -e | ||
set -x | ||
|
||
if [[ "$(uname -s)" == 'Darwin' ]]; then | ||
brew update || brew update | ||
brew outdated pyenv || brew upgrade pyenv | ||
brew install pyenv-virtualenv | ||
brew install cmake || true | ||
|
||
if which pyenv > /dev/null; then | ||
eval "$(pyenv init -)" | ||
fi | ||
|
||
pyenv install 3.7.1 | ||
pyenv virtualenv 3.7.1 conan | ||
pyenv rehash | ||
pyenv activate conan | ||
fi | ||
|
||
pip install -U conan_package_tools conan |
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,11 @@ | ||
cmake_minimum_required(VERSION 2.8.11) | ||
project(test_package CXX) | ||
|
||
include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) | ||
conan_basic_setup() | ||
|
||
find_package(BehaviorTree REQUIRED CONFIG) | ||
|
||
add_executable(${PROJECT_NAME} test_package.cpp) | ||
target_link_libraries(${PROJECT_NAME} ${CONAN_LIBS}) | ||
set_property(TARGET ${PROJECT_NAME} PROPERTY CXX_STANDARD 11) |
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,19 @@ | ||
#!/usr/bin/env python | ||
# -*- coding: utf-8 -*- | ||
import os | ||
from conans import ConanFile, CMake | ||
|
||
|
||
class TestPackageConan(ConanFile): | ||
settings = "os", "compiler", "build_type", "arch" | ||
generators = "cmake" | ||
|
||
def build(self): | ||
cmake = CMake(self) | ||
cmake.configure() | ||
cmake.build() | ||
|
||
def test(self): | ||
assert os.path.isfile(os.path.join(self.deps_cpp_info["BehaviorTree.CPP"].rootpath, "licenses", "LICENSE")) | ||
bin_path = os.path.join("bin", "test_package") | ||
self.run(bin_path, run_environment=True) |
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,47 @@ | ||
#include "behaviortree_cpp/blackboard/blackboard_local.h" | ||
|
||
/** | ||
* In this first tutorial we demonstrate how to: | ||
* | ||
* - Create ActionNodes either from a single function/method or using inheritance | ||
* - Create a Sequence of Actions. | ||
* - Build a Tree programmatically. | ||
*/ | ||
|
||
int main() | ||
{ | ||
// sequence_root will be the root of our tree | ||
// BT::SequenceNode sequence_root("sequence"); | ||
|
||
// // Function pointers can be wrapped inside ActionNodeBase | ||
// // using the SimpleActionNode | ||
// SimpleActionNode say_hello("action_hello", std::bind(SayHello)); | ||
|
||
// // SimpleActionNode works also with class methods, using std::bind | ||
// SimpleActionNode open_gripper("open_gripper", std::bind(&GripperInterface::open, &gripper)); | ||
// SimpleActionNode close_gripper("close_gripper", std::bind(&GripperInterface::close, &gripper)); | ||
|
||
// // To be able to use ALL the functionalities of a TreeNode, | ||
// // your should create a class that inherits from either: | ||
// // - ConditionNode (synchronous execution) | ||
// // - ActionNodeBase (synchronous execution) | ||
// // - ActionNode (asynchronous execution in a separate thread). | ||
// ApproachObject approach_object("approach_object"); | ||
|
||
// // Add children to the sequence. | ||
// // they will be executed in the same order they are added. | ||
// sequence_root.addChild(&say_hello); | ||
// sequence_root.addChild(&open_gripper); | ||
// sequence_root.addChild(&approach_object); | ||
// sequence_root.addChild(&close_gripper); | ||
|
||
// // The tick is propagated to all the children. | ||
// // until one of them returns FAILURE or RUNNING. | ||
// // In this case all of them return SUCCESS immediately | ||
// sequence_root.executeTick(); | ||
|
||
// // needed when you use ActionNodes with their own thread | ||
// haltAllActions(&sequence_root); | ||
|
||
return 0; | ||
} |
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,60 @@ | ||
#!/usr/bin/env python | ||
# -*- coding: utf-8 -*- | ||
|
||
"""Conan recipe package for Google FlatBuffers | ||
""" | ||
from conans import ConanFile, CMake, tools | ||
|
||
|
||
class FlatbuffersConan(ConanFile): | ||
name = "BehaviorTree.CPP" | ||
license = "MIT" | ||
url = "https://github.com/BehaviorTree/BehaviorTree.CPP" | ||
author = "Davide Faconti <davide.faconti@gmail.com>" | ||
topics = ("conan", "behaviortree", "ai", "robotics", "games", "coordination") | ||
description = "This C++ library provides a framework to create BehaviorTrees. It was designed to be flexible, easy to use and fast." | ||
settings = "os", "compiler", "build_type", "arch" | ||
options = {"zmq": [True, False]} | ||
default_options = {"zmq": True} | ||
generators = "cmake" | ||
exports = "LICENSE" | ||
exports_sources = ("cmake/*", "include/*", "src/*", "3rdparty/*", "CMakeLists.txt") | ||
|
||
def requirements(self): | ||
"""Install ZMQ when required | ||
""" | ||
if self.options.zmq: | ||
self.requires("zmq/4.2.5@bincrafters/stable") | ||
|
||
def _configure_cmake(self): | ||
"""Create CMake instance and execute configure step | ||
""" | ||
cmake = CMake(self) | ||
cmake.verbose = True | ||
cmake.definitions["BUILD_EXAMPLES"] = False | ||
cmake.definitions["BUILD_UNIT_TESTS"] = False | ||
cmake.configure() | ||
return cmake | ||
|
||
def build(self): | ||
"""Configure, build and install FlatBuffers using CMake. | ||
""" | ||
tools.replace_in_file("CMakeLists.txt", | ||
"project(behaviortree_cpp)", | ||
"""project(behaviortree_cpp) | ||
include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) | ||
conan_basic_setup()""") | ||
cmake = self._configure_cmake() | ||
cmake.build() | ||
|
||
def package(self): | ||
"""Copy Flatbuffers' artifacts to package folder | ||
""" | ||
self.copy(pattern="LICENSE", dst="licenses") | ||
cmake = self._configure_cmake() | ||
cmake.install() | ||
|
||
def package_info(self): | ||
"""Collect built libraries names and solve flatc path. | ||
""" | ||
self.cpp_info.libs = tools.collect_libs(self) |