Skip to content

Commit

Permalink
Merge 982e793 into 5261307
Browse files Browse the repository at this point in the history
  • Loading branch information
Croydon authored Sep 18, 2018
2 parents 5261307 + 982e793 commit 693d8b7
Show file tree
Hide file tree
Showing 2 changed files with 121 additions and 0 deletions.
43 changes: 43 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
78 changes: 78 additions & 0 deletions conanfile.py
Original file line number Diff line number Diff line change
@@ -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")

0 comments on commit 693d8b7

Please sign in to comment.