diff options
author | Oleg Morozenkov <m@oleg.rocks> | 2018-12-10 00:33:50 +0300 |
---|---|---|
committer | Oleg Morozenkov <m@oleg.rocks> | 2018-12-10 00:33:50 +0300 |
commit | 9078804118bdeab9828d20b8535557ef162a3240 (patch) | |
tree | 556d89d67c305b76a700e67b6e094a10f71a8ca6 | |
parent | 644fd19832c20751d614b32ca0ef17cf5ad36642 (diff) |
Conan packaging support
Squashed commit of the following:
commit e3844568ae508375729a7b18133951462e1e1eb7
Author: Oleg Morozenkov <m@oleg.rocks>
Date: Mon Dec 10 00:32:31 2018 +0300
Change bintray credentials
commit 6e7b10a11d543811ed39ae131ab26cadb5c5a54f
Author: Oleg Morozenkov <m@oleg.rocks>
Date: Mon Dec 10 00:21:22 2018 +0300
Move conan test package to samples directory
commit c6e0480998dd2759581f2ddf45c625d074d983eb
Author: Artalus <artalus-mail@yandex.ru>
Date: Wed Nov 28 22:33:31 2018 +0300
Move packager variables to build.py
commit ca7316e70fe63136d7d18f89fb7a707ef6534fb2
Merge: 644fd19 a5f7cc8
Author: Artalus <artalus-mail@yandex.ru>
Date: Wed Nov 28 22:06:34 2018 +0300
Merge pull request #1 from jgsogo/master
Add Conan support
commit a5f7cc8e21f6156b9c2781ecaea26c3d6cbdecf3
Author: Javier G. Sogo <jgsogo@gmail.com>
Date: Wed Nov 28 11:48:55 2018 +0100
build missing for some versions of apple-clang [skip appveyor]
commit 956076587c56557ddaca61c92283bfd12e313985
Author: Javier G. Sogo <jgsogo@gmail.com>
Date: Wed Nov 28 10:07:26 2018 +0100
build missing for clang7
commit 0b84e5b09236196dd2b42f4e534da5952eb1b419
Author: Javier G. Sogo <jgsogo@gmail.com>
Date: Tue Nov 27 18:48:21 2018 +0100
keep openssl under 1.1
commit a52a7499370148c84c84f18cb355d108cad42c42
Author: Javier G. Sogo <jgsogo@gmail.com>
Date: Tue Nov 27 18:33:58 2018 +0100
up (and fixed) OpenSSL version
commit 04fd3bdd43cb1301047b5c8a9bf6a4119f8f143e
Author: Javier G. Sogo <jgsogo@gmail.com>
Date: Tue Nov 27 17:55:36 2018 +0100
up libcurl version
commit cafd32453ad1f96f899e30b5f3b2efec950a2b60
Merge: b35438d f2f39d4
Author: Javier G. Sogo <jgsogo@gmail.com>
Date: Sat Nov 24 10:33:00 2018 +0100
Merge pull request #1 from jgsogo/conan-minimum
Minimum implementation of a recipe file
commit f2f39d4688861e51f02f0f7ac20684edeb85cc78
Merge: 3f5680e 73965e5
Author: Javier G. Sogo <jgsogo@gmail.com>
Date: Fri Nov 23 21:55:00 2018 +0100
Merge pull request #3 from jgsogo/conan-ci
Conan CI
commit 73965e58d291c0bd91d527190a35b54685d2cb45
Author: Javier G. Sogo <jgsogo@gmail.com>
Date: Fri Nov 23 20:43:28 2018 +0100
remove mingw builds
commit 66381b16cebf92f42b54b890580a346aef90f8f6
Author: Javier G. Sogo <jgsogo@gmail.com>
Date: Fri Nov 23 18:29:59 2018 +0100
install targets to proper destinations
commit e41a4fd44e3fc00a5df8b70dcb28cee96b528a78
Author: Javier G. Sogo <jgsogo@gmail.com>
Date: Fri Nov 23 18:26:32 2018 +0100
add mingw compilations
commit bfdf0b408726725973ff004402ee623d3b6a38c3
Author: Javier G. Sogo <jgsogo@gmail.com>
Date: Fri Nov 23 18:25:12 2018 +0100
add more windows jobs
commit bd4f98f89cb0fa2775155b25d08672cb5f908e8d
Author: Javier G. Sogo <jgsogo@gmail.com>
Date: Fri Nov 23 17:54:11 2018 +0100
dive MT and MD visual runtime into separated jobs
commit 2d46eb903752f7331a7c79c8fe9f165daf6af091
Author: Javier G. Sogo <jgsogo@gmail.com>
Date: Fri Nov 23 17:52:53 2018 +0100
divide job into task (remove Debug builds)
commit df5e12fe3289c8a267f83c00de6561314d9563b9
Author: Javier G. Sogo <jgsogo@gmail.com>
Date: Fri Nov 23 17:45:09 2018 +0100
deactivate all warnings for Visual Studio
commit 0ca72be24551201c9cc029a2c8473d8d76c74104
Author: Javier G. Sogo <jgsogo@gmail.com>
Date: Fri Nov 23 16:38:50 2018 +0100
export everything for windows
commit a2d751b42746eeebc1f238d84c845a267b560390
Author: Javier G. Sogo <jgsogo@gmail.com>
Date: Tue Nov 20 14:03:22 2018 +0100
remove some jobs from CI
commit e229d63c31fa30dcd48ecd676d888564a816d101
Author: Javier G. Sogo <jgsogo@gmail.com>
Date: Wed Nov 14 23:56:36 2018 +0100
divide in two, let see if no timeout
commit 6a443ec91de039afabe9c63df27229aeb95e1e65
Author: Javier G. Sogo <jgsogo@gmail.com>
Date: Wed Nov 14 11:52:00 2018 +0100
install zlib too
commit 683760d7ab6578f2978b0665045f3dcbbf18a687
Author: Javier G. Sogo <jgsogo@gmail.com>
Date: Wed Nov 14 10:32:45 2018 +0100
add zlib libraries to linker
commit 41923a144207fdafd2f585a6cf02034595ecd698
Author: Javier G. Sogo <jgsogo@gmail.com>
Date: Wed Nov 14 10:31:18 2018 +0100
add ZLib to libraries
commit 56563887b279017ee00dbcc62eeef46e2b0257b0
Merge: 81fac64 8c0a21d
Author: Javier G. Sogo <jgsogo@gmail.com>
Date: Tue Nov 13 19:39:05 2018 +0100
Merge pull request #2 from jgsogo/build-stages
Build stages (restore original build)
commit 8c0a21d2d84bc476ed2634d63828a1f21ec4a098
Author: Javier G. Sogo <jgsogo@gmail.com>
Date: Tue Nov 13 19:28:07 2018 +0100
use python >>
commit 1ff044f227bffa370fdd6d734a80684602b66a26
Author: Javier G. Sogo <jgsogo@gmail.com>
Date: Tue Nov 13 18:46:59 2018 +0100
add name
commit 1ff7ebc2177d6571cc245562da40cc08fd850e5b
Author: Javier G. Sogo <jgsogo@gmail.com>
Date: Tue Nov 13 18:45:25 2018 +0100
add section with unittests
commit 8ce0b4d240875cf6b28c1e2b9161b82713288e90
Author: Javier G. Sogo <jgsogo@gmail.com>
Date: Tue Nov 13 18:42:25 2018 +0100
group builds in stages
commit 81fac6465c0e3c732579b1fe672ca1ade45fa44b
Author: Javier G. Sogo <jgsogo@gmail.com>
Date: Tue Nov 13 18:14:07 2018 +0100
use existing bintray repo
commit 65a8de4777fe31f7cf518cf1891a2482a18c1e05
Author: Javier G. Sogo <jgsogo@gmail.com>
Date: Mon Nov 12 22:38:56 2018 +0100
use known username
commit 50d380886f961b1d023e58d724ef0645f018db0f
Author: Javier G. Sogo <jgsogo@gmail.com>
Date: Mon Nov 12 18:25:59 2018 +0100
add build script
commit 6636d348e4b5445e30ba09c6989b28b569c61660
Author: Javier G. Sogo <jgsogo@gmail.com>
Date: Mon Nov 12 18:22:17 2018 +0100
touch
commit 0efd05fd48c556917272abcb27fcff70d0bff228
Author: Javier G. Sogo <jgsogo@gmail.com>
Date: Mon Nov 12 18:18:22 2018 +0100
modify user
commit 70e781c89c1b5ecae713928a60db3c8e2ac694f8
Author: Javier G. Sogo <jgsogo@gmail.com>
Date: Mon Nov 12 18:18:05 2018 +0100
add Conan CI
commit 3f5680e4379f94d298de78b334acee9721a7834a
Author: Javier G. Sogo <jgsogo@gmail.com>
Date: Mon Nov 12 18:13:15 2018 +0100
touch
commit 2e436cf771916413da456b26867ba11327c632d2
Author: Javier G. Sogo <jgsogo@gmail.com>
Date: Mon Nov 12 18:12:05 2018 +0100
reorder conanfile
commit 845147924ed9554a5e32adeb77df4361109e9959
Author: Javier G. Sogo <jgsogo@gmail.com>
Date: Mon Nov 12 16:46:25 2018 +0100
credit for these commits to @Artalus: https://github.com/Artalus/tgbot-cpp
commit 9fab5fe376ea328dfba8dbad68e30b6fd42e68b5
Author: Javier G. Sogo <jgsogo@gmail.com>
Date: Mon Nov 12 16:41:20 2018 +0100
remove blank lines
commit c2101503d8518492ce64dab82baabbff5cbb44a7
Author: Javier G. Sogo <jgsogo@gmail.com>
Date: Mon Nov 12 16:22:44 2018 +0100
add example
commit 746cc6f60e1e967a513da94ff4f56ce283feedc4
Author: Javier G. Sogo <jgsogo@gmail.com>
Date: Mon Nov 12 15:02:07 2018 +0100
minimum example for Conan
-rw-r--r-- | .travis.yml | 88 | ||||
-rwxr-xr-x | .travis/install.sh | 24 | ||||
-rwxr-xr-x | .travis/run.sh | 13 | ||||
-rw-r--r-- | CMakeLists.txt | 23 | ||||
-rw-r--r-- | Dockerfile | 2 | ||||
-rw-r--r-- | Dockerfile_test | 6 | ||||
-rw-r--r-- | appveyor.yml | 80 | ||||
-rw-r--r-- | build.py | 17 | ||||
-rw-r--r-- | conanfile.py | 61 | ||||
-rw-r--r-- | samples/echobot-conan/CMakeLists.txt | 9 | ||||
-rw-r--r-- | samples/echobot-conan/conanfile.py | 24 | ||||
-rw-r--r-- | samples/echobot-conan/example.cpp | 20 |
12 files changed, 355 insertions, 12 deletions
diff --git a/.travis.yml b/.travis.yml index 37629fb..f4e6c94 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,10 +1,84 @@ -sudo: required +linux: &linux + os: linux + dist: xenial + language: python + python: "3.7" + services: + - docker +osx: &osx + os: osx + language: generic -services: - - docker +stages: + - unittest + - conan-linux + - conan-osx -script: - - docker build -t reo7sp/tgbot-cpp -f Dockerfile . - - docker build -t reo7sp/tgbot-cpp-test -f Dockerfile_test . - - docker run --rm reo7sp/tgbot-cpp-test +jobs: + include: + - <<: *linux + stage: unittest + name: unittest + sudo: required + script: + - docker build -t reo7sp/tgbot-cpp -f Dockerfile . + - docker build -t reo7sp/tgbot-cpp-test -f Dockerfile_test . + - docker run --rm reo7sp/tgbot-cpp-test + + - <<: *linux + stage: conan-linux + env: CONAN_GCC_VERSIONS=4.9 CONAN_DOCKER_IMAGE=conanio/gcc49 + - <<: *linux + stage: conan-linux + env: CONAN_GCC_VERSIONS=5 CONAN_DOCKER_IMAGE=conanio/gcc5 + - <<: *linux + stage: conan-linux + env: CONAN_GCC_VERSIONS=6 CONAN_DOCKER_IMAGE=conanio/gcc6 + - <<: *linux + stage: conan-linux + env: CONAN_GCC_VERSIONS=7 CONAN_DOCKER_IMAGE=conanio/gcc7 + - <<: *linux + stage: conan-linux + env: CONAN_GCC_VERSIONS=8 CONAN_DOCKER_IMAGE=conanio/gcc8 + + - <<: *linux + stage: conan-linux + env: CONAN_CLANG_VERSIONS=4.0 CONAN_DOCKER_IMAGE=conanio/clang40 + - <<: *linux + stage: conan-linux + env: CONAN_CLANG_VERSIONS=5.0 CONAN_DOCKER_IMAGE=conanio/clang50 + - <<: *linux + stage: conan-linux + env: CONAN_CLANG_VERSIONS=6.0 CONAN_DOCKER_IMAGE=conanio/clang60 + - <<: *linux + stage: conan-linux + env: CONAN_CLANG_VERSIONS=7.0 CONAN_DOCKER_IMAGE=conanio/clang7 CONAN_BUILD_POLICY=missing + - <<: *osx + stage: conan-osx + osx_image: xcode7.3 + env: CONAN_APPLE_CLANG_VERSIONS=7.3 CONAN_BUILD_POLICY=missing + - <<: *osx + stage: conan-osx + osx_image: xcode8.3 + env: CONAN_APPLE_CLANG_VERSIONS=8.1 CONAN_BUILD_POLICY=missing + - <<: *osx + stage: conan-osx + osx_image: xcode9 + env: CONAN_APPLE_CLANG_VERSIONS=9.0 + - <<: *osx + stage: conan-osx + osx_image: xcode9.4 + env: CONAN_APPLE_CLANG_VERSIONS=9.1 + - <<: *osx + stage: conan-osx + osx_image: xcode10 + env: CONAN_APPLE_CLANG_VERSIONS=10.0 + +install: + - chmod +x .travis/install.sh + - ./.travis/install.sh + +script: + - chmod +x .travis/run.sh + - ./.travis/run.sh diff --git a/.travis/install.sh b/.travis/install.sh new file mode 100755 index 0000000..657ecc1 --- /dev/null +++ b/.travis/install.sh @@ -0,0 +1,24 @@ +#!/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 conan_package_tools +pip install conan +conan user diff --git a/.travis/run.sh b/.travis/run.sh new file mode 100755 index 0000000..0a3488e --- /dev/null +++ b/.travis/run.sh @@ -0,0 +1,13 @@ +#!/bin/bash + +set -e +set -x + +if [[ "$(uname -s)" == 'Darwin' ]]; then + if which pyenv > /dev/null; then + eval "$(pyenv init -)" + fi + pyenv activate conan +fi + +python build.py diff --git a/CMakeLists.txt b/CMakeLists.txt index c4f7195..290c91c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,12 +1,24 @@ cmake_minimum_required(VERSION 2.8.4) project(TgBot) +if (${CONAN_EXPORTED}) + include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) + conan_basic_setup() +endif() + +set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON) + # options option(ENABLE_TESTS "Set to ON to enable building of tests" OFF) option(BUILD_SHARED_LIBS "Build tgbot-cpp shared/static library." OFF) # sources -set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -Wall") +if(WIN32) + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11") # Do not activate all warnings in VS (too much output for Appveyor) +else() + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -Wall") +endif() + include_directories(include) set(SRC_LIST src/Api.cpp @@ -28,6 +40,9 @@ set(SRC_LIST ## threads find_package(Threads REQUIRED) +# zlib +find_package(ZLIB REQUIRED) + ## openssl find_package(OpenSSL REQUIRED) include_directories(${OPENSSL_INCLUDE_DIR}) @@ -50,6 +65,7 @@ include_directories(${Boost_INCLUDE_DIR}) set(LIB_LIST ${CMAKE_THREAD_LIBS_INIT} + ${ZLIB_LIBRARIES} ${OPENSSL_LIBRARIES} ${Boost_LIBRARIES} ${CURL_LIBRARIES} @@ -59,7 +75,10 @@ set(LIB_LIST add_library(${PROJECT_NAME} ${SRC_LIST}) target_include_directories(${PROJECT_NAME} PUBLIC include) target_link_libraries(${PROJECT_NAME} ${LIB_LIST}) -install(TARGETS ${PROJECT_NAME} DESTINATION lib) +install(TARGETS ${PROJECT_NAME} + RUNTIME DESTINATION bin + LIBRARY DESTINATION lib + ARCHIVE DESTINATION lib) install(DIRECTORY include/ DESTINATION include) # tests @@ -2,7 +2,7 @@ FROM debian:stretch MAINTAINER Oleg Morozenkov <a@reo7sp.ru> RUN apt-get -qq update && \ - apt-get -qq install -y g++ make binutils cmake libssl-dev libboost-system-dev libcurl4-openssl-dev + apt-get -qq install -y g++ make binutils cmake libssl-dev libboost-system-dev libcurl4-openssl-dev zlib1g-dev WORKDIR /usr/src/tgbot-cpp COPY include include diff --git a/Dockerfile_test b/Dockerfile_test index 8b16ae2..9ff0764 100644 --- a/Dockerfile_test +++ b/Dockerfile_test @@ -2,8 +2,10 @@ FROM ubuntu:14.04 MAINTAINER Oleg Morozenkov <a@reo7sp.ru> RUN apt-get -qq update && \ - apt-get -qq install -y g++ make binutils cmake libssl-dev libcurl4-openssl-dev \ - wget build-essential python-dev autotools-dev libicu-dev libbz2-dev + apt-get -qq install -y g++ make binutils cmake libssl-dev libcurl4-openssl-dev + +RUN apt-get -qq update && \ + apt-get -qq install -y wget build-essential python-dev autotools-dev libicu-dev libbz2-dev zlib1g-dev WORKDIR /usr/src/boost RUN wget -q -O boost_1_59_0.tar.gz https://sourceforge.net/projects/boost/files/boost/1.59.0/boost_1_59_0.tar.gz/download && \ diff --git a/appveyor.yml b/appveyor.yml new file mode 100644 index 0000000..4d16413 --- /dev/null +++ b/appveyor.yml @@ -0,0 +1,80 @@ +build: false + + +environment: + PYTHON: "C:\\Python37" + VS150COMNTOOLS: "C:\\Program Files (x86)\\Microsoft Visual Studio\\2017\\Community\\Common7\\Tools\\" + + matrix: + - APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015 + CONAN_VISUAL_VERSIONS: 12 + CONAN_ARCHS: x86 + CONAN_BUILD_TYPES: Release + CONAN_VISUAL_RUNTIMES: MT + - APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015 + CONAN_VISUAL_VERSIONS: 12 + CONAN_ARCHS: x86_64 + CONAN_BUILD_TYPES: Release + CONAN_VISUAL_RUNTIMES: MT + - APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015 + CONAN_VISUAL_VERSIONS: 12 + CONAN_ARCHS: x86 + CONAN_BUILD_TYPES: Release + CONAN_VISUAL_RUNTIMES: MD + - APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015 + CONAN_VISUAL_VERSIONS: 12 + CONAN_ARCHS: x86_64 + CONAN_BUILD_TYPES: Release + CONAN_VISUAL_RUNTIMES: MD + + - APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015 + CONAN_VISUAL_VERSIONS: 14 + CONAN_ARCHS: x86 + CONAN_BUILD_TYPES: Release + CONAN_VISUAL_RUNTIMES: MT + - APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015 + CONAN_VISUAL_VERSIONS: 14 + CONAN_ARCHS: x86_64 + CONAN_BUILD_TYPES: Release + CONAN_VISUAL_RUNTIMES: MT + - APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015 + CONAN_VISUAL_VERSIONS: 14 + CONAN_ARCHS: x86 + CONAN_BUILD_TYPES: Release + CONAN_VISUAL_RUNTIMES: MD + - APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015 + CONAN_VISUAL_VERSIONS: 14 + CONAN_ARCHS: x86_64 + CONAN_BUILD_TYPES: Release + CONAN_VISUAL_RUNTIMES: MD + + - APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017 + CONAN_VISUAL_VERSIONS: 15 + CONAN_ARCHS: x86 + CONAN_BUILD_TYPES: Release + CONAN_VISUAL_RUNTIMES: MT + - APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017 + CONAN_VISUAL_VERSIONS: 15 + CONAN_ARCHS: x86_64 + CONAN_BUILD_TYPES: Release + CONAN_VISUAL_RUNTIMES: MT + - APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017 + CONAN_VISUAL_VERSIONS: 15 + CONAN_ARCHS: x86 + CONAN_BUILD_TYPES: Release + CONAN_VISUAL_RUNTIMES: MD + - APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017 + CONAN_VISUAL_VERSIONS: 15 + CONAN_ARCHS: x86_64 + CONAN_BUILD_TYPES: Release + CONAN_VISUAL_RUNTIMES: MD + +install: + - set PATH=%PATH%;%PYTHON%/Scripts/ + - pip.exe install conan --upgrade + - pip.exe install conan_package_tools + - conan user # It creates the conan data directory + +test_script: + - python build.py + diff --git a/build.py b/build.py new file mode 100644 index 0000000..18a873a --- /dev/null +++ b/build.py @@ -0,0 +1,17 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- +from cpt.packager import ConanMultiPackager + + +if __name__ == "__main__": + builder = ConanMultiPackager( + username="reo7sp", + login_username="reo7sp", + upload="https://api.bintray.com/conan/reo7sp/tgbot-cpp", + channel="ci", + stable_branch_pattern="release/*", + upload_only_when_stable=True, # Will only upload when the branch matches "release/*" + docker_32_images=True + ) + builder.add_common_builds() + builder.run() diff --git a/conanfile.py b/conanfile.py new file mode 100644 index 0000000..96c3d22 --- /dev/null +++ b/conanfile.py @@ -0,0 +1,61 @@ + +#!/usr/bin/env python +# -*- coding: utf-8 -*- + +import os + +from conans import ConanFile, CMake, tools + + +class TgbotConan(ConanFile): + name = "tgbot_cpp" + version = "b35438d" + description = "C++ library for Telegram bot API" + url = "https://github.com/reo7sp/tgbot-cpp" + homepage = "http://reo7sp.github.io/tgbot-cpp" + license = "MIT" + + exports_sources = ["LICENSE", ] + scm = {"type": "git", + "url": "auto", + "revision": "auto"} + + generators = "cmake" + settings = "os", "arch", "compiler", "build_type" + options = {"fPIC": [True, False], + "shared": [True, False]} + default_options = {"fPIC": True, "shared": True} + + requires = ( + "boost/1.68.0@conan/stable", + "OpenSSL/1.0.2q@conan/stable", + "libcurl/7.61.1@bincrafters/stable" + ) + + def source(self): + boost_version = self.deps_cpp_info['boost'].version + tools.replace_in_file(os.path.join(self.source_folder, "CMakeLists.txt"), + "find_package(Boost 1.59.0 COMPONENTS system REQUIRED)", + "find_package(Boost {} COMPONENTS system REQUIRED)".format(boost_version)) + + def config_options(self): + if self.settings.os == "Windows": + del self.options.fPIC + + def _configure_cmake(self): + cmake = CMake(self) + cmake.definitions["ENABLE_TESTS"] = False + cmake.configure() + return cmake + + def build(self): + cmake = self._configure_cmake() + cmake.build() + + def package(self): + self.copy(pattern="LICENSE", dst="licenses") + cmake = self._configure_cmake() + cmake.install() + + def package_info(self): + self.cpp_info.libs = ['TgBot'] diff --git a/samples/echobot-conan/CMakeLists.txt b/samples/echobot-conan/CMakeLists.txt new file mode 100644 index 0000000..24d5422 --- /dev/null +++ b/samples/echobot-conan/CMakeLists.txt @@ -0,0 +1,9 @@ +project(PackageTest CXX) +cmake_minimum_required(VERSION 2.8.4) +set(CMAKE_CXX_STANDARD 11) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup() + +add_executable(example example.cpp) +target_link_libraries(example ${CONAN_LIBS}) diff --git a/samples/echobot-conan/conanfile.py b/samples/echobot-conan/conanfile.py new file mode 100644 index 0000000..732b9b8 --- /dev/null +++ b/samples/echobot-conan/conanfile.py @@ -0,0 +1,24 @@ + +import os +from conans import ConanFile, CMake, tools + + +class TestConan(ConanFile): + settings = "os", "compiler", "build_type", "arch" + generators = "cmake" + + def build(self): + cmake = CMake(self) + # Current dir is "echobot-conan/build/<build_id>" and CMakeLists.txt is in "echobot-conan" + cmake.configure() + cmake.build() + + def imports(self): + self.copy("*.dll", dst="bin", src="bin") + self.copy("*.dylib*", dst="bin", src="lib") + self.copy('*.so*', dst='bin', src='lib') + + def test(self): + if not tools.cross_building(self.settings): + os.chdir("bin") + self.run(".%sexample" % os.sep) diff --git a/samples/echobot-conan/example.cpp b/samples/echobot-conan/example.cpp new file mode 100644 index 0000000..f1c2863 --- /dev/null +++ b/samples/echobot-conan/example.cpp @@ -0,0 +1,20 @@ +#include <tgbot/tgbot.h> + +using namespace std; +using namespace TgBot; + +bool sigintGot = false; + +int main() { + Bot bot("PLACE YOUR TOKEN HERE"); + bot.getEvents().onCommand("start", [&bot](Message::Ptr message) { + bot.getApi().sendMessage(message->chat->id, "Hi!"); + }); + bot.getEvents().onAnyMessage([&bot](Message::Ptr message) { + printf("User wrote %s\n", message->text.c_str()); + if (StringTools::startsWith(message->text, "/start")) { + return; + } + bot.getApi().sendMessage(message->chat->id, "Your message is: " + message->text); + }); +} |