From d60e73a7c86c5e0548c23dae08b9347486824c8a Mon Sep 17 00:00:00 2001 From: Croydon Date: Sun, 29 Jul 2018 11:37:16 +0200 Subject: [PATCH 1/9] Init Conan recipe (fix #635) --- conanfile.py | 78 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 78 insertions(+) create mode 100644 conanfile.py diff --git a/conanfile.py b/conanfile.py new file mode 100644 index 0000000000..3b95d55cf2 --- /dev/null +++ b/conanfile.py @@ -0,0 +1,78 @@ +from conans import ConanFile, CMake, tools + + +class GoogleBenchmarkConan(ConanFile): + name = "benchmark" + description = "A microbenchmark support library." + url = "https://github.com/google/benchmark" + homepage = "https://github.com/google/benchmark" + license = "Apache-2.0" + settings = "arch", "build_type", "compiler", "os" + options = { + "shared": [True, False], + "fPIC": [True, False], + "enable_exceptions": [True, False], + "enable_lto": [True, False], + "enable_testing": [True, False], + "enable_gtest_tests": [True, False] + } + default_options = "shared=False", "fPIC=True", "enable_exceptions=True", "enable_lto=False", "enable_testing=False", "enable_gtest_tests=False" + exports_sources = ["*"] + generators = "cmake" + + build_subfolder = "." + + def config_options(self): + if self.settings.os == 'Windows': + del self.options.fPIC + + def configure(self): + if self.settings.os == 'Windows' and self.options.shared: + raise Exception("Windows shared builds are not supported right now, see issue #639") + + if self.options.enable_testing == False: + self.options.enable_gtest_tests = False + + def _configure_cmake(self): + cmake = CMake(self) + cmake.definitions['BENCHMARK_ENABLE_TESTING'] = "ON" if self.options.enable_testing else "OFF" + cmake.definitions['BENCHMARK_ENABLE_GTEST_TESTS'] = "ON" if self.options.enable_gtest_tests and self.options.enable_testing else "OFF" + cmake.definitions["BENCHMARK_ENABLE_LTO"] = "ON" if self.options.enable_lto else "OFF" + cmake.definitions["BENCHMARK_ENABLE_EXCEPTIONS"] = "ON" if self.options.enable_exceptions else "OFF" + + # See https://github.com/google/benchmark/pull/638 for Windows 32 build explanation + if self.settings.os != "Windows": + cmake.definitions["BENCHMARK_BUILD_32_BITS"] = "ON" if "64" not in str(self.settings.arch) else "OFF" + cmake.definitions["BENCHMARK_USE_LIBCXX"] = "ON" if (str(self.settings.compiler.libcxx) == "libc++") else "OFF" + else: + cmake.definitions["BENCHMARK_USE_LIBCXX"] = "OFF" + + cmake.configure(build_folder=self.build_subfolder) + return cmake + + def build_requirements(self): + if self.options.enable_gtest_tests: + self.build_requires("gtest/1.8.0@bincrafters/stable") + + def build(self): + tools.replace_in_file("CMakeLists.txt", "project (benchmark)", '''project (benchmark) + include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) + conan_basic_setup()''') + + cmake = self._configure_cmake() + cmake.build() + + def package(self): + cmake = self._configure_cmake() + cmake.install() + + self.copy(pattern="LICENSE", dst="licenses") + + def package_info(self): + self.cpp_info.libs = tools.collect_libs(self) + if self.settings.os == "Linux": + self.cpp_info.libs.extend(["pthread", "rt"]) + elif self.settings.os == "Windows": + self.cpp_info.libs.append("shlwapi") + elif self.settings.os == "SunOS": + self.cpp.info.libs.append("kstat") From bf4f4eea30645d43780ebaaf83fc634794705f1a Mon Sep 17 00:00:00 2001 From: Croydon Date: Sun, 29 Jul 2018 11:38:18 +0200 Subject: [PATCH 2/9] Travis: Add Conan testing & uploading --- .travis.yml | 43 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) diff --git a/.travis.yml b/.travis.yml index 4625dfb087..3b7096353e 100644 --- a/.travis.yml +++ b/.travis.yml @@ -117,6 +117,49 @@ matrix: - LIBCXX_BUILD=1 LIBCXX_SANITIZER=Thread - ENABLE_SANITIZER=1 - EXTRA_FLAGS="-stdlib=libc++ -g -O2 -fno-omit-frame-pointer -fsanitize=thread -fno-sanitize-recover=all" + # Conan testing and uploading + - compiler: gcc + env: CONAN=True + language: python + python: "3.6" + before_script: + - pip install -U pip + before_install: + - pip --version + install: + - pip install conan + script: + - conan create . benchmark/master@google/testing --build + after_success: + # If this build is NOT triggered by a pull request; AND got triggered by either a tag OR push to master + # and the following environment variables are set: + # CONAN_UPLOAD - a reference to the Conan repository e.g. https://bintray.com/google/conan + # CONAN_LOGIN_USERNAME - user for the upload e.g. upload_bot_username + # CONAN_PASSWORD - password for the CONAN_LOGIN_USERNAME; for Bintray this is the API key + # then upload the new recipe version to the Conan repository. + # + # For the tag pushes we are using for the + # version the tag name, removing the "v" + # channel "stable" + # For master pushes we are using for the + # version simply "master" + # channel "testing" + - if [[ "${TRAVIS_PULL_REQUEST}" == "false" && ( -n "${TRAVIS_TAG}" || "${TRAVIS_BRANCH}" == "master" ) && -n "${CONAN_UPLOAD}" && -n "${CONAN_LOGIN_USERNAME}" && -n "${CONAN_PASSWORD}" ]]; then + conan remote add benchmark ${CONAN_UPLOAD} --insert; + conan remote list; + + if [ -n "${TRAVIS_TAG}" ]; then + CONANVERSION=${TRAVIS_TAG//v}; + CONANREFERENCE=benchmark/${CONANVERSION}@google/stable; + conan export . ${CONANREFERENCE}; + else + CONANVERSION="master"; + CONANREFERENCE=benchmark/${CONANVERSION}@google/testing; + fi; + + conan user -p "${CONAN_PASSWORD}" -r benchmark "${CONAN_LOGIN_USERNAME}"; + conan upload --force -r benchmark --retry 3 --retry-wait 10 --confirm "${CONANREFERENCE}"; + fi; - os: osx osx_image: xcode8.3 compiler: clang From 6a2be0adb585d6451a7ebb754db2beb13f504556 Mon Sep 17 00:00:00 2001 From: Croydon Date: Mon, 24 Sep 2018 21:42:58 +0200 Subject: [PATCH 3/9] WIP Conan CI completion --- .travis.yml | 124 +++++++++++++++++++++++++++----------- conan/CMakeLists.txt | 7 +++ conan/appveyor/build.py | 8 +++ conan/appveyor/install.py | 8 +++ conan/build.py | 36 +++++++++++ conan/travis/build.sh | 14 +++++ conan/travis/install.sh | 22 +++++++ conanfile.py | 8 ++- 8 files changed, 191 insertions(+), 36 deletions(-) create mode 100644 conan/CMakeLists.txt create mode 100644 conan/appveyor/build.py create mode 100644 conan/appveyor/install.py create mode 100644 conan/build.py create mode 100644 conan/travis/build.sh create mode 100644 conan/travis/install.sh diff --git a/.travis.yml b/.travis.yml index 3b7096353e..2f4e208e34 100644 --- a/.travis.yml +++ b/.travis.yml @@ -5,6 +5,37 @@ language: cpp env: global: - /usr/local/bin:$PATH + - CONAN_USERNAME="google" + - CONAN_PACKAGE_NAME="benchmark" + +conan-linux: &conan-linux + os: linux + sudo: required + language: python + python: "3.6" + services: + - docker + install: + - | + CONAN_VERSION=${TRAVIS_TAG//v}; + export CONAN_REFERENCE=${CONAN_USERNAME}/${CONAN_VERSION}; + export CONAN_CHANNEL="stable"; + - ./conan/travis/install.sh + script: + - ./conan/travis/build.sh + if: tag IS present +conan-osx: &conan-osx + os: osx + language: generic + install: + - | + CONAN_VERSION=${TRAVIS_TAG//v}; + export CONAN_REFERENCE=${CONAN_USERNAME}/${CONAN_VERSION}; + export CONAN_CHANNEL="stable"; + - ./conan/travis/install.sh + script: + - ./conan/travis/build.sh + if: tag IS present matrix: include: @@ -117,19 +148,41 @@ matrix: - LIBCXX_BUILD=1 LIBCXX_SANITIZER=Thread - ENABLE_SANITIZER=1 - EXTRA_FLAGS="-stdlib=libc++ -g -O2 -fno-omit-frame-pointer -fsanitize=thread -fno-sanitize-recover=all" + - os: osx + osx_image: xcode8.3 + compiler: clang + env: + - COMPILER=clang++ BUILD_TYPE=Debug + - os: osx + osx_image: xcode8.3 + compiler: clang + env: + - COMPILER=clang++ BUILD_TYPE=Release + - os: osx + osx_image: xcode8.3 + compiler: clang + env: + - COMPILER=clang++ BUILD_TYPE=Release BUILD_32_BITS=ON + - os: osx + osx_image: xcode8.3 + compiler: gcc + env: + - COMPILER=g++-7 C_COMPILER=gcc-7 BUILD_TYPE=Debug # Conan testing and uploading - compiler: gcc env: CONAN=True language: python python: "3.6" - before_script: - - pip install -U pip before_install: - - pip --version + - pip install -U pip install: - pip install conan + before_script: + - pip --version + - conan --version script: - - conan create . benchmark/master@google/testing --build + - CONAN_FULL_REFERENCE=${CONAN_PACKAGE_NAME}/master@${CONAN_USERNAME}/testing + - conan create . ${CONAN_FULL_REFERENCE} --build after_success: # If this build is NOT triggered by a pull request; AND got triggered by either a tag OR push to master # and the following environment variables are set: @@ -144,42 +197,43 @@ matrix: # For master pushes we are using for the # version simply "master" # channel "testing" - - if [[ "${TRAVIS_PULL_REQUEST}" == "false" && ( -n "${TRAVIS_TAG}" || "${TRAVIS_BRANCH}" == "master" ) && -n "${CONAN_UPLOAD}" && -n "${CONAN_LOGIN_USERNAME}" && -n "${CONAN_PASSWORD}" ]]; then - conan remote add benchmark ${CONAN_UPLOAD} --insert; + - if [[ "${TRAVIS_PULL_REQUEST}" == "false" && "${TRAVIS_BRANCH}" == "master" && -n "${CONAN_UPLOAD}" && -n "${CONAN_LOGIN_USERNAME}" && -n "${CONAN_PASSWORD}" ]]; then + conan remote add ${CONAN_PACKAGE_NAME} ${CONAN_UPLOAD} --insert; conan remote list; - if [ -n "${TRAVIS_TAG}" ]; then - CONANVERSION=${TRAVIS_TAG//v}; - CONANREFERENCE=benchmark/${CONANVERSION}@google/stable; - conan export . ${CONANREFERENCE}; - else - CONANVERSION="master"; - CONANREFERENCE=benchmark/${CONANVERSION}@google/testing; - fi; - conan user -p "${CONAN_PASSWORD}" -r benchmark "${CONAN_LOGIN_USERNAME}"; - conan upload --force -r benchmark --retry 3 --retry-wait 10 --confirm "${CONANREFERENCE}"; + conan upload --force -r ${CONAN_PACKAGE_NAME} --retry 3 --retry-wait 10 --confirm "${CONAN_FULL_REFERENCE}"; fi; - - os: osx - osx_image: xcode8.3 - compiler: clang - env: - - COMPILER=clang++ BUILD_TYPE=Debug - - os: osx + - <<: *conan-linux + env: CONAN_GCC_VERSIONS=4.9 CONAN_DOCKER_IMAGE=lasote/conangcc49 + - <<: *conan-linux + env: CONAN_GCC_VERSIONS=5 CONAN_DOCKER_IMAGE=lasote/conangcc5 + - <<: *conan-linux + env: CONAN_GCC_VERSIONS=6 CONAN_DOCKER_IMAGE=lasote/conangcc6 + - <<: *conan-linux + env: CONAN_GCC_VERSIONS=7 CONAN_DOCKER_IMAGE=lasote/conangcc7 + - <<: *conan-linux + env: CONAN_GCC_VERSIONS=8 CONAN_DOCKER_IMAGE=lasote/conangcc8 + - <<: *conan-linux + env: CONAN_CLANG_VERSIONS=3.9 CONAN_DOCKER_IMAGE=lasote/conanclang39 + - <<: *conan-linux + env: CONAN_CLANG_VERSIONS=4.0 CONAN_DOCKER_IMAGE=lasote/conanclang40 + - <<: *conan-linux + env: CONAN_CLANG_VERSIONS=5.0 CONAN_DOCKER_IMAGE=lasote/conanclang50 + - <<: *conan-linux + env: CONAN_CLANG_VERSIONS=6.0 CONAN_DOCKER_IMAGE=lasote/conanclang60 + - <<: *conan-osx + osx_image: xcode7.3 + env: CONAN_APPLE_CLANG_VERSIONS=7.3 + - <<: *conan-osx osx_image: xcode8.3 - compiler: clang - env: - - COMPILER=clang++ BUILD_TYPE=Release - - os: osx - osx_image: xcode8.3 - compiler: clang - env: - - COMPILER=clang++ BUILD_TYPE=Release BUILD_32_BITS=ON - - os: osx - osx_image: xcode8.3 - compiler: gcc - env: - - COMPILER=g++-7 C_COMPILER=gcc-7 BUILD_TYPE=Debug + 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 before_script: - if [ -n "${LIBCXX_BUILD}" ]; then diff --git a/conan/CMakeLists.txt b/conan/CMakeLists.txt new file mode 100644 index 0000000000..15b92ca91a --- /dev/null +++ b/conan/CMakeLists.txt @@ -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) diff --git a/conan/appveyor/build.py b/conan/appveyor/build.py new file mode 100644 index 0000000000..9bac46dbe7 --- /dev/null +++ b/conan/appveyor/build.py @@ -0,0 +1,8 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- +import os + +if os.getenv("APPVEYOR_REPO_TAG") != "true": + print("Skip build step. It's not TAG") +else: + os.system("python conan/build.py") diff --git a/conan/appveyor/install.py b/conan/appveyor/install.py new file mode 100644 index 0000000000..962c7da6b7 --- /dev/null +++ b/conan/appveyor/install.py @@ -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") diff --git a/conan/build.py b/conan/build.py new file mode 100644 index 0000000000..47c79e7080 --- /dev/null +++ b/conan/build.py @@ -0,0 +1,36 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- +from cpt.packager import ConanMultiPackager +import os + +def set_appveyor_environment(): + if os.getenv("APPVEYOR") is not None: + compiler_version = os.getenv("CMAKE_VS_VERSION").split(" ")[0].replace('"', '') + os.environ["CONAN_VISUAL_VERSIONS"] = compiler_version + os.environ["CONAN_STABLE_BRANCH_PATTERN"] = "master" + ci_platform = os.getenv("Platform").replace('"', '') + ci_platform = "x86" if ci_platform == "x86" else "x86_64" + os.environ["CONAN_ARCHS"] = ci_platform + os.environ["CONAN_BUILD_TYPES"] = os.getenv("Configuration").replace('"', '') + +if __name__ == "__main__": + login_username = os.getenv("CONAN_LOGIN_USERNAME") + username = os.getenv("CONAN_USERNAME") + reference = os.getenv("CONAN_REFERENCE") + channel = os.getenv("CONAN_CHANNEL") + upload = os.getenv("CONAN_UPLOAD") + stable_branch_pattern = os.getenv("CONAN_STABLE_BRANCH_PATTERN", r"v\d+\.\d+\.\d+.*") + test_folder = os.getenv("CPT_TEST_FOLDER", os.path.join("conan", "test_package")) + upload_only_when_stable = os.getenv("CONAN_UPLOAD_ONLY_WHEN_STABLE", True) + set_appveyor_environment() + + builder = ConanMultiPackager(username=username, + reference=reference, + channel=channel, + login_username=login_username, + upload=upload, + stable_branch_pattern=stable_branch_pattern, + upload_only_when_stable=upload_only_when_stable, + test_folder=test_folder) + builder.add_common_builds(pure_c=False) + builder.run() diff --git a/conan/travis/build.sh b/conan/travis/build.sh new file mode 100644 index 0000000000..069ced202f --- /dev/null +++ b/conan/travis/build.sh @@ -0,0 +1,14 @@ +#!/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 + +conan user +python conan/build.py diff --git a/conan/travis/install.sh b/conan/travis/install.sh new file mode 100644 index 0000000000..f4208d8264 --- /dev/null +++ b/conan/travis/install.sh @@ -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 2.7.10 + pyenv virtualenv 2.7.10 conan + pyenv rehash + pyenv activate conan +fi + +pip install -U conan_package_tools conan diff --git a/conanfile.py b/conanfile.py index 3b95d55cf2..0147c843ea 100644 --- a/conanfile.py +++ b/conanfile.py @@ -1,5 +1,5 @@ from conans import ConanFile, CMake, tools - +import shutil class GoogleBenchmarkConan(ConanFile): name = "benchmark" @@ -22,6 +22,12 @@ class GoogleBenchmarkConan(ConanFile): build_subfolder = "." + def source(self): + """Wrap the original CMake file to call conan_basic_setup + """ + shutil.move("CMakeLists.txt", "CMakeListsOriginal.txt") + shutil.move(os.path.join("conan", "CMakeLists.txt"), "CMakeLists.txt") + def config_options(self): if self.settings.os == 'Windows': del self.options.fPIC From 9547105c534a91d6dc897496cefae38f526aaccf Mon Sep 17 00:00:00 2001 From: Croydon Date: Mon, 24 Sep 2018 21:51:56 +0200 Subject: [PATCH 4/9] WIP --- conanfile.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/conanfile.py b/conanfile.py index 0147c843ea..fabc168118 100644 --- a/conanfile.py +++ b/conanfile.py @@ -1,5 +1,7 @@ from conans import ConanFile, CMake, tools import shutil +import os + class GoogleBenchmarkConan(ConanFile): name = "benchmark" From 438971422ed0755dcdd768f2b9d69088e0ff95a1 Mon Sep 17 00:00:00 2001 From: Croydon Date: Mon, 24 Sep 2018 22:01:16 +0200 Subject: [PATCH 5/9] WIP --- .travis.yml | 1 + conan/build.py | 0 conan/travis/build.sh | 0 conan/travis/install.sh | 0 4 files changed, 1 insertion(+) mode change 100644 => 100755 conan/build.py mode change 100644 => 100755 conan/travis/build.sh mode change 100644 => 100755 conan/travis/install.sh diff --git a/.travis.yml b/.travis.yml index 2f4e208e34..b909d6c2e4 100644 --- a/.travis.yml +++ b/.travis.yml @@ -204,6 +204,7 @@ matrix: conan user -p "${CONAN_PASSWORD}" -r benchmark "${CONAN_LOGIN_USERNAME}"; conan upload --force -r ${CONAN_PACKAGE_NAME} --retry 3 --retry-wait 10 --confirm "${CONAN_FULL_REFERENCE}"; fi; + if: NOT tag IS present - <<: *conan-linux env: CONAN_GCC_VERSIONS=4.9 CONAN_DOCKER_IMAGE=lasote/conangcc49 - <<: *conan-linux diff --git a/conan/build.py b/conan/build.py old mode 100644 new mode 100755 diff --git a/conan/travis/build.sh b/conan/travis/build.sh old mode 100644 new mode 100755 diff --git a/conan/travis/install.sh b/conan/travis/install.sh old mode 100644 new mode 100755 From d4303c09fc5ff4b2032d16899ffdbebdc7689d88 Mon Sep 17 00:00:00 2001 From: Croydon Date: Mon, 24 Sep 2018 22:04:46 +0200 Subject: [PATCH 6/9] WIP --- conanfile.py | 4 ---- 1 file changed, 4 deletions(-) diff --git a/conanfile.py b/conanfile.py index fabc168118..2ce1549653 100644 --- a/conanfile.py +++ b/conanfile.py @@ -63,10 +63,6 @@ def build_requirements(self): self.build_requires("gtest/1.8.0@bincrafters/stable") def build(self): - tools.replace_in_file("CMakeLists.txt", "project (benchmark)", '''project (benchmark) - include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) - conan_basic_setup()''') - cmake = self._configure_cmake() cmake.build() From 30de3848c64f84f0cf4a938585b5725b9ba17543 Mon Sep 17 00:00:00 2001 From: Croydon Date: Mon, 24 Sep 2018 22:14:05 +0200 Subject: [PATCH 7/9] WIP --- .travis.yml | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index b909d6c2e4..62ea491b98 100644 --- a/.travis.yml +++ b/.travis.yml @@ -15,26 +15,38 @@ conan-linux: &conan-linux python: "3.6" services: - docker - install: + before_install: - | CONAN_VERSION=${TRAVIS_TAG//v}; export CONAN_REFERENCE=${CONAN_USERNAME}/${CONAN_VERSION}; export CONAN_CHANNEL="stable"; + install: - ./conan/travis/install.sh script: - ./conan/travis/build.sh + # the following are dummies to overwrite default build steps + before_script: + - true + after_success: + - true if: tag IS present conan-osx: &conan-osx os: osx language: generic - install: + before_install: - | CONAN_VERSION=${TRAVIS_TAG//v}; export CONAN_REFERENCE=${CONAN_USERNAME}/${CONAN_VERSION}; export CONAN_CHANNEL="stable"; + install: - ./conan/travis/install.sh script: - ./conan/travis/build.sh + # the following are dummies to overwrite default build steps + before_script: + - true + after_success: + - true if: tag IS present matrix: From 7ce6ecff04dedf2a34aaf66d3003e3808508f8be Mon Sep 17 00:00:00 2001 From: Croydon Date: Mon, 24 Sep 2018 22:25:19 +0200 Subject: [PATCH 8/9] WIP --- .travis.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index 62ea491b98..87f218e3dc 100644 --- a/.travis.yml +++ b/.travis.yml @@ -18,7 +18,7 @@ conan-linux: &conan-linux before_install: - | CONAN_VERSION=${TRAVIS_TAG//v}; - export CONAN_REFERENCE=${CONAN_USERNAME}/${CONAN_VERSION}; + export CONAN_REFERENCE=${CONAN_PACKAGE_NAME}/${CONAN_VERSION}; export CONAN_CHANNEL="stable"; install: - ./conan/travis/install.sh @@ -36,7 +36,7 @@ conan-osx: &conan-osx before_install: - | CONAN_VERSION=${TRAVIS_TAG//v}; - export CONAN_REFERENCE=${CONAN_USERNAME}/${CONAN_VERSION}; + export CONAN_REFERENCE=${CONAN_PACKAGE_NAME}/${CONAN_VERSION}; export CONAN_CHANNEL="stable"; install: - ./conan/travis/install.sh From a605b73a31044ff117215893a224b94c5cde33aa Mon Sep 17 00:00:00 2001 From: Croydon Date: Mon, 24 Sep 2018 23:29:15 +0200 Subject: [PATCH 9/9] WIP test_package --- conan/test_package/CMakeLists.txt | 10 ++++++++++ conan/test_package/conanfile.py | 20 ++++++++++++++++++++ conan/test_package/test_package.cpp | 18 ++++++++++++++++++ 3 files changed, 48 insertions(+) create mode 100644 conan/test_package/CMakeLists.txt create mode 100644 conan/test_package/conanfile.py create mode 100644 conan/test_package/test_package.cpp diff --git a/conan/test_package/CMakeLists.txt b/conan/test_package/CMakeLists.txt new file mode 100644 index 0000000000..74a74af38d --- /dev/null +++ b/conan/test_package/CMakeLists.txt @@ -0,0 +1,10 @@ +project(test_package) +cmake_minimum_required(VERSION 2.8.11) + +set(CMAKE_VERBOSE_MAKEFILE TRUE) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup() + +add_executable(${PROJECT_NAME} test_package.cpp) +target_link_libraries(${PROJECT_NAME} ${CONAN_LIBS}) diff --git a/conan/test_package/conanfile.py b/conan/test_package/conanfile.py new file mode 100644 index 0000000000..f940718a40 --- /dev/null +++ b/conan/test_package/conanfile.py @@ -0,0 +1,20 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- +# vim: tabstop=8 expandtab shiftwidth=4 softtabstop=4 + +from conans import ConanFile, CMake +import os + + +class TestPackageConan(ConanFile): + settings = "os", "compiler", "build_type", "arch" + generators = "cmake" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) diff --git a/conan/test_package/test_package.cpp b/conan/test_package/test_package.cpp new file mode 100644 index 0000000000..4fa7ec0bf9 --- /dev/null +++ b/conan/test_package/test_package.cpp @@ -0,0 +1,18 @@ +#include "benchmark/benchmark.h" + +void BM_StringCreation(benchmark::State& state) { + while (state.KeepRunning()) + std::string empty_string; +} + +BENCHMARK(BM_StringCreation); + +void BM_StringCopy(benchmark::State& state) { + std::string x = "hello"; + while (state.KeepRunning()) + std::string copy(x); +} + +BENCHMARK(BM_StringCopy); + +BENCHMARK_MAIN();