Skip to content

Commit

Permalink
BehaviorTree#2 Build Conan package on CI service
Browse files Browse the repository at this point in the history
- Add Travis support for Conan package
- Add Appveyor file to build on Windows

Signed-off-by: Uilian Ries <uilianries@gmail.com>
  • Loading branch information
uilianries committed Dec 12, 2018
1 parent e05ad94 commit c6341ab
Show file tree
Hide file tree
Showing 7 changed files with 194 additions and 6 deletions.
57 changes: 55 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,26 @@ os:
compiler:
- gcc

conan-linux: &conan-linux
os: linux
dist: xenial
language: python
python: "3.7"
services:
- docker
install:
- ./conan/travis/install.sh
script:
- ./conan/travis/build.sh

conan-osx: &conan-osx
os: osx
language: generic
install:
- ./conan/travis/install.sh
script:
- ./conan/travis/build.sh

matrix:
include:
- bare_linux:
Expand All @@ -21,10 +41,43 @@ matrix:
env: ROS_DISTRO="kinetic"
- ros_melodic:
env: ROS_DISTRO="melodic"
- <<: *conan-linux
env: CONAN_GCC_VERSIONS=4.9 CONAN_DOCKER_IMAGE=conanio/gcc49
- <<: *conan-linux
env: CONAN_GCC_VERSIONS=5 CONAN_DOCKER_IMAGE=conanio/gcc5
- <<: *conan-linux
env: CONAN_GCC_VERSIONS=6 CONAN_DOCKER_IMAGE=conanio/gcc6
- <<: *conan-linux
env: CONAN_GCC_VERSIONS=7 CONAN_DOCKER_IMAGE=conanio/gcc7
- <<: *conan-linux
env: CONAN_GCC_VERSIONS=8 CONAN_DOCKER_IMAGE=conanio/gcc8
- <<: *conan-linux
env: CONAN_CLANG_VERSIONS=3.9 CONAN_DOCKER_IMAGE=conanio/clang39
- <<: *conan-linux
env: CONAN_CLANG_VERSIONS=4.0 CONAN_DOCKER_IMAGE=conanio/clang40
- <<: *conan-linux
env: CONAN_CLANG_VERSIONS=5.0 CONAN_DOCKER_IMAGE=conanio/clang50
- <<: *conan-linux
env: CONAN_CLANG_VERSIONS=6.0 CONAN_DOCKER_IMAGE=conanio/clang60
- <<: *conan-osx
osx_image: xcode7.3
env: CONAN_APPLE_CLANG_VERSIONS=7.3
- <<: *conan-osx
osx_image: xcode8.3
env: CONAN_APPLE_CLANG_VERSIONS=8.1
- <<: *conan-osx
osx_image: xcode9
env: CONAN_APPLE_CLANG_VERSIONS=9.0
- <<: *conan-osx
osx_image: xcode9.4
env: CONAN_APPLE_CLANG_VERSIONS=9.1
- <<: *conan-osx
osx_image: xcode10.1
env: CONAN_APPLE_CLANG_VERSIONS=10.0
fast_finish: false

before_install:
- sudo apt-get update && sudo apt-get --reinstall install -qq build-essential
- sudo apt-get update && sudo apt-get --reinstall install -qq build-essential
- if [ "$ROS_DISTRO" = "none" ]; then sudo apt-get --reinstall install -qq libzmq3-dev; fi
# GTest: see motivation here https://www.eriksmistad.no/getting-started-with-google-test-on-ubuntu/
- sudo apt-get --reinstall install -qq libgtest-dev cmake
Expand All @@ -40,7 +93,7 @@ install:
before_script:
# Prepare build directory
- mkdir -p build

script:
- if [ "$ROS_DISTRO" = "none" ]; then (cd build; cmake .. ; sudo cmake --build . --target install; ./bin/behaviortree_cpp_test); fi
- if [ "$ROS_DISTRO" != "none" ]; then (.ci_config/travis.sh); fi
Expand Down
20 changes: 20 additions & 0 deletions appveyor.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
build: false

environment:
PYTHON: "C:\\Python37"

matrix:
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015
CONAN_VISUAL_VERSIONS: 12
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015
CONAN_VISUAL_VERSIONS: 14
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017
CONAN_VISUAL_VERSIONS: 15

install:
- set PATH=%PATH%;%PYTHON%/Scripts/
- pip.exe install conan --upgrade
- pip.exe install conan_package_tools bincrafters_package_tools

test_script:
- python conan/build.py
9 changes: 9 additions & 0 deletions conan/test_package/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
project(test_package CXX)
cmake_minimum_required(VERSION 2.8.11)

include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake)
conan_basic_setup()

add_executable(${PROJECT_NAME} test_package.cpp)
target_link_libraries(${PROJECT_NAME} ${CONAN_LIBS})
set_property(TARGET ${PROJECT_NAME} PROPERTY CXX_STANDARD 11)
19 changes: 19 additions & 0 deletions conan/test_package/conanfile.py
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)
68 changes: 68 additions & 0 deletions conan/test_package/test_package.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
#include "behaviortree_cpp/behavior_tree.h"
#include "behaviortree_cpp/bt_factory.h"

using namespace BT;

NodeStatus SayHello()
{
printf("hello\n");
return NodeStatus::SUCCESS;
}

class ActionTestNode : public ActionNode
{
public:
ActionTestNode(const std::string& name) : ActionNode(name)
{
}

NodeStatus tick() override
{
time_ = 5;
stop_loop_ = false;
int i = 0;
while (!stop_loop_ && i++ < time_)
{
std::this_thread::sleep_for(std::chrono::milliseconds(100));
}
return NodeStatus::SUCCESS;
}

virtual void halt() override
{
stop_loop_ = true;
setStatus(NodeStatus::IDLE);
}

private:
int time_;
std::atomic_bool stop_loop_;
};

int main()
{
BT::SequenceNode root("root");
BT::SimpleActionNode action1("say_hello", std::bind(SayHello));
ActionTestNode action2("async_action");

root.addChild(&action1);
root.addChild(&action2);

int count = 0;

NodeStatus status = NodeStatus::RUNNING;

while (status == NodeStatus::RUNNING)
{
status = root.executeTick();

std::cout << count++ << " : " << root.status() << " / " << action1.status() << " / "
<< action2.status() << std::endl;

std::this_thread::sleep_for(std::chrono::milliseconds(100));
}

haltAllActions(&root);

return 0;
}
22 changes: 22 additions & 0 deletions conan/travis/install.sh
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
5 changes: 1 addition & 4 deletions conanfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,7 @@ class BehaviorTreeConan(ConanFile):
generators = "cmake"
exports = "LICENSE"
exports_sources = ("cmake/*", "include/*", "src/*", "3rdparty/*", "CMakeLists.txt")

def requirements(self):

self.requires("cppzmq/4.3.0@bincrafters/stable")
requires = "cppzmq/4.3.0@bincrafters/stable"

def _configure_cmake(self):
"""Create CMake instance and execute configure step
Expand Down

0 comments on commit c6341ab

Please sign in to comment.