Merge pull request #11 from steakhal/migrate-to-conan-ci
Migrate to conan ci
This commit is contained in:
commit
fea658233a
9 changed files with 273 additions and 183 deletions
|
@ -1,48 +1,37 @@
|
|||
version: "{branch} #{build}"
|
||||
|
||||
shallow_clone: true
|
||||
|
||||
image:
|
||||
- Visual Studio 2017
|
||||
|
||||
platform:
|
||||
- Win32
|
||||
- x64
|
||||
|
||||
configuration:
|
||||
- Debug
|
||||
- Release
|
||||
|
||||
build:
|
||||
parallel: true
|
||||
build: false
|
||||
|
||||
environment:
|
||||
PYTHON: "C:\\Python37"
|
||||
|
||||
CONAN_UPLOAD: "https://api.bintray.com/conan/steakhal/maintained"
|
||||
CONAN_BUILD_POLICY: "missing"
|
||||
CONAN_USERNAME: "steakhal"
|
||||
CONAN_CHANNEL: "stable"
|
||||
CONAN_UPLOAD_ONLY_WHEN_TAG: 1
|
||||
|
||||
matrix:
|
||||
- GENERATOR: "Visual Studio 15 2017"
|
||||
- MINGW_CONFIGURATIONS: '7@x86_64@seh@posix, 7@x86@dwarf2@posix, 8@x86_64@seh@posix, 8@x86@dwarf2@posix'
|
||||
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017
|
||||
CONAN_VISUAL_VERSIONS: 15
|
||||
CONAN_BUILD_TYPES: Release
|
||||
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017
|
||||
CONAN_VISUAL_VERSIONS: 15
|
||||
CONAN_BUILD_TYPES: Debug
|
||||
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2019
|
||||
CONAN_VISUAL_VERSIONS: 16
|
||||
CONAN_BUILD_TYPES: Release
|
||||
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2019
|
||||
CONAN_VISUAL_VERSIONS: 16
|
||||
CONAN_BUILD_TYPES: Debug
|
||||
|
||||
|
||||
install:
|
||||
# getting Catch2 library
|
||||
# redirect stderr to fix appveyor handling stderr
|
||||
- ps: $env:GIT_REDIRECT_STDERR = '2>&1'
|
||||
- ps: git clone https://github.com/catchorg/Catch2.git
|
||||
- ps: cd Catch2
|
||||
- ps: git checkout v2.9.1
|
||||
- ps: mkdir build
|
||||
- ps: cd build
|
||||
- ps: pwd
|
||||
- ps: cmake -DCATCH_BUILD_TESTING=OFF -DCATCH_INSTALL_DOCS=OFF -DCATCH_INSTALL_HELPERS=OFF -DCMAKE_INSTALL_PREFIX="$PWD/../installed" ..
|
||||
- ps: cmake --build . --target install --config Release
|
||||
- ps: cd ../..
|
||||
|
||||
before_build:
|
||||
- if exist build RMDIR /S /Q build
|
||||
- if not exist build mkdir build
|
||||
- cd build
|
||||
- pwd
|
||||
- cmake -G "%GENERATOR%" -A %PLATFORM% -DCMAKE_INSTALL_PREFIX="C:/projects/nameof/Catch2/installed" ..
|
||||
|
||||
build_script:
|
||||
- cmake --build . --config %CONFIGURATION%
|
||||
- set PATH=%PATH%;%PYTHON%/Scripts/
|
||||
- pip.exe install conan --upgrade
|
||||
- pip.exe install conan_package_tools bincrafters_package_tools
|
||||
- conan user # It creates the conan data directory
|
||||
|
||||
test_script:
|
||||
- ctest --output-on-failure -C %CONFIGURATION%
|
||||
- python .ci/build.py
|
||||
|
|
13
.ci/build.py
Normal file
13
.ci/build.py
Normal file
|
@ -0,0 +1,13 @@
|
|||
#!/usr/bin/env python
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
from cpt.packager import ConanMultiPackager
|
||||
|
||||
if __name__ == "__main__":
|
||||
options = { 'nameof:build_tests': True, 'nameof:build_examples': True }
|
||||
always_true = lambda build: True
|
||||
|
||||
builder = ConanMultiPackager()
|
||||
builder.add_common_builds()
|
||||
builder.update_build_if(always_true, new_options = options)
|
||||
builder.run()
|
24
.ci/install.sh
Normal file
24
.ci/install.sh
Normal file
|
@ -0,0 +1,24 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
set -ex
|
||||
|
||||
if [[ "$(uname -s)" == 'Darwin' ]]; then
|
||||
brew update || brew update
|
||||
brew outdated pyenv || brew upgrade pyenv
|
||||
brew install pyenv-virtualenv
|
||||
brew install cmake || brew upgrade 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 --upgrade
|
||||
pip install conan_package_tools bincrafters_package_tools
|
||||
|
||||
conan user
|
12
.ci/run.sh
Normal file
12
.ci/run.sh
Normal file
|
@ -0,0 +1,12 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
set -ex
|
||||
|
||||
if [[ "$(uname -s)" == 'Darwin' ]]; then
|
||||
if which pyenv > /dev/null; then
|
||||
eval "$(pyenv init -)"
|
||||
fi
|
||||
pyenv activate conan
|
||||
fi
|
||||
|
||||
python .ci/build.py
|
192
.travis.yml
192
.travis.yml
|
@ -1,162 +1,74 @@
|
|||
os: linux # Use linux unless specified otherwise.
|
||||
dist: xenial
|
||||
sudo: required
|
||||
env:
|
||||
global:
|
||||
- CONAN_UPLOAD: "https://api.bintray.com/conan/steakhal/maintained"
|
||||
- CONAN_BUILD_POLICY: "missing"
|
||||
- CONAN_USERNAME: "steakhal"
|
||||
- CONAN_CHANNEL: "stable"
|
||||
- CONAN_UPLOAD_ONLY_WHEN_TAG: 1
|
||||
|
||||
language: cpp
|
||||
linux: &linux
|
||||
os: linux
|
||||
dist: xenial
|
||||
sudo: required
|
||||
language: python
|
||||
python: "3.6"
|
||||
services:
|
||||
- docker
|
||||
|
||||
git:
|
||||
depth: 1
|
||||
osx: &osx
|
||||
os: osx
|
||||
language: generic
|
||||
|
||||
matrix:
|
||||
include:
|
||||
- os: linux
|
||||
compiler: g++
|
||||
addons:
|
||||
apt:
|
||||
sources:
|
||||
- ubuntu-toolchain-r-test
|
||||
packages:
|
||||
- g++-7
|
||||
env:
|
||||
- CXX_COMPILER=g++-7 CC_COMPILER=gcc-7
|
||||
- <<: *linux
|
||||
env: CONAN_GCC_VERSIONS=7 CONAN_DOCKER_IMAGE=conanio/gcc7
|
||||
|
||||
- os: linux
|
||||
compiler: g++
|
||||
addons:
|
||||
apt:
|
||||
sources:
|
||||
- ubuntu-toolchain-r-test
|
||||
packages:
|
||||
- g++-8
|
||||
env:
|
||||
- CXX_COMPILER=g++-8 CC_COMPILER=gcc-8
|
||||
- <<: *linux
|
||||
env: CONAN_GCC_VERSIONS=8 CONAN_DOCKER_IMAGE=conanio/gcc8
|
||||
|
||||
- os: linux
|
||||
compiler: g++
|
||||
addons:
|
||||
apt:
|
||||
sources:
|
||||
- ubuntu-toolchain-r-test
|
||||
packages:
|
||||
- g++-9
|
||||
env:
|
||||
- CXX_COMPILER=g++-9 CC_COMPILER=gcc-9
|
||||
- <<: *linux
|
||||
env: CONAN_GCC_VERSIONS=9 CONAN_DOCKER_IMAGE=conanio/gcc9
|
||||
|
||||
- os: linux
|
||||
compiler: clang++
|
||||
addons:
|
||||
apt:
|
||||
sources:
|
||||
- ubuntu-toolchain-r-test
|
||||
- llvm-toolchain-xenial-5.0
|
||||
packages:
|
||||
- clang-5.0
|
||||
env:
|
||||
- CXX_COMPILER=clang++-5.0 CC_COMPILER=clang-5.0
|
||||
- <<: *linux
|
||||
env: CONAN_CLANG_VERSIONS=5.0 CONAN_DOCKER_IMAGE=conanio/clang50
|
||||
|
||||
- os: linux
|
||||
compiler: clang++
|
||||
addons:
|
||||
apt:
|
||||
sources:
|
||||
- ubuntu-toolchain-r-test
|
||||
- llvm-toolchain-xenial-6.0
|
||||
packages:
|
||||
- clang-6.0
|
||||
env:
|
||||
- CXX_COMPILER=clang++-6.0 CC_COMPILER=clang-6.0
|
||||
- <<: *linux
|
||||
env: CONAN_CLANG_VERSIONS=6.0 CONAN_DOCKER_IMAGE=conanio/clang60
|
||||
|
||||
- os: linux
|
||||
compiler: clang++
|
||||
addons:
|
||||
apt:
|
||||
sources:
|
||||
- ubuntu-toolchain-r-test
|
||||
- llvm-toolchain-xenial-7
|
||||
packages:
|
||||
- clang-7
|
||||
env:
|
||||
- CXX_COMPILER=clang++-7 CC_COMPILER=clang-7
|
||||
- <<: *linux
|
||||
env: CONAN_CLANG_VERSIONS=7.0 CONAN_DOCKER_IMAGE=conanio/clang7
|
||||
|
||||
- os: linux
|
||||
compiler: clang++
|
||||
addons:
|
||||
apt:
|
||||
sources:
|
||||
- ubuntu-toolchain-r-test
|
||||
- llvm-toolchain-xenial-8
|
||||
packages:
|
||||
- clang-8
|
||||
env:
|
||||
- CXX_COMPILER=clang++-8 CC_COMPILER=clang-8
|
||||
- <<: *linux
|
||||
env: CONAN_CLANG_VERSIONS=8 CONAN_DOCKER_IMAGE=conanio/clang8
|
||||
|
||||
- os: osx
|
||||
compiler: clang++
|
||||
- <<: *osx
|
||||
osx_image: xcode9.2
|
||||
env: CONAN_APPLE_CLANG_VERSIONS=9.0
|
||||
|
||||
- <<: *osx
|
||||
osx_image: xcode9.4
|
||||
env:
|
||||
- CXX_COMPILER=clang++ CC_COMPILER=clang
|
||||
env: CONAN_APPLE_CLANG_VERSIONS=9.1
|
||||
|
||||
- os: osx
|
||||
compiler: clang++
|
||||
- <<: *osx
|
||||
osx_image: xcode10.1
|
||||
env: CONAN_APPLE_CLANG_VERSIONS=10.0
|
||||
|
||||
- <<: *osx
|
||||
osx_image: xcode10.2
|
||||
env:
|
||||
- CXX_COMPILER=clang++ CC_COMPILER=clang
|
||||
env: CONAN_APPLE_CLANG_VERSIONS=10.0
|
||||
|
||||
- <<: *osx
|
||||
osx_image: xcode11
|
||||
env: CONAN_APPLE_CLANG_VERSIONS=11.0
|
||||
|
||||
install:
|
||||
- export CC=${CC_COMPILER}
|
||||
- export CXX=${CXX_COMPILER}
|
||||
- JOBS=2 # Travis machines have 2 cores.
|
||||
- |
|
||||
# getting Catch2 library
|
||||
git clone https://github.com/catchorg/Catch2.git
|
||||
cd Catch2
|
||||
git checkout v2.9.1
|
||||
mkdir build
|
||||
cd build
|
||||
pwd
|
||||
cmake -DCATCH_BUILD_TESTING=OFF -DCATCH_INSTALL_DOCS=OFF -DCATCH_INSTALL_HELPERS=OFF -DCMAKE_INSTALL_PREFIX=../installed ..
|
||||
cmake --build . --target install --config Release
|
||||
cd ../..
|
||||
|
||||
# If linux and clang install the right version of libc++.
|
||||
if [[ "${TRAVIS_OS_NAME}" == "linux" && "${CXX%%+*}" == "clang" && -n "$(ls -A ${LLVM_INSTALL})" ]]; then
|
||||
LLVM_INSTALL=${DEPS_DIR}/llvm/install
|
||||
if [[ "${CXX}" == "clang++-3.5" ]]; then LLVM_VERSION="3.5.2";
|
||||
elif [[ "${CXX}" == "clang++-3.6" ]]; then LLVM_VERSION="3.6.2";
|
||||
elif [[ "${CXX}" == "clang++-3.7" ]]; then LLVM_VERSION="3.7.1";
|
||||
elif [[ "${CXX}" == "clang++-3.8" ]]; then LLVM_VERSION="3.8.1";
|
||||
elif [[ "${CXX}" == "clang++-3.9" ]]; then LLVM_VERSION="3.9.1";
|
||||
elif [[ "${CXX}" == "clang++-4.0" ]]; then LLVM_VERSION="4.0.1";
|
||||
elif [[ "${CXX}" == "clang++-5.0" ]]; then LLVM_VERSION="5.0.2";
|
||||
elif [[ "${CXX}" == "clang++-6.0" ]]; then LLVM_VERSION="6.0.1";
|
||||
elif [[ "${CXX}" == "clang++-7" ]]; then LLVM_VERSION="7.0.1";
|
||||
elif [[ "${CXX}" == "clang++-8" ]]; then LLVM_VERSION="8.0.0";
|
||||
fi
|
||||
LLVM_URL="http://llvm.org/releases/${LLVM_VERSION}/llvm-${LLVM_VERSION}.src.tar.xz"
|
||||
LIBCXX_URL="http://llvm.org/releases/${LLVM_VERSION}/libcxx-${LLVM_VERSION}.src.tar.xz"
|
||||
LIBCXXABI_URL="http://llvm.org/releases/${LLVM_VERSION}/libcxxabi-${LLVM_VERSION}.src.tar.xz"
|
||||
mkdir -p llvm llvm/build llvm/projects/libcxx llvm/projects/libcxxabi
|
||||
travis_retry wget -O - ${LLVM_URL} | tar --strip-components=1 -xJ -C llvm
|
||||
travis_retry wget -O - ${LIBCXX_URL} | tar --strip-components=1 -xJ -C llvm/projects/libcxx
|
||||
travis_retry wget -O - ${LIBCXXABI_URL} | tar --strip-components=1 -xJ -C llvm/projects/libcxxabi
|
||||
(cd llvm/build && cmake .. -DCMAKE_INSTALL_PREFIX=${LLVM_INSTALL})
|
||||
(cd llvm/build/projects/libcxx && sudo make install -j${JOBS})
|
||||
(cd llvm/build/projects/libcxxabi && sudo make install -j${JOBS})
|
||||
export CXXFLAGS="-isystem ${LLVM_INSTALL}/include/c++/v1"
|
||||
export LDFLAGS="-L ${LLVM_INSTALL}/lib -l c++ -l c++abi"
|
||||
export LD_LIBRARY_PATH="${LD_LIBRARY_PATH}:${LLVM_INSTALL}/lib"
|
||||
fi
|
||||
|
||||
before_script:
|
||||
- rm -rf build
|
||||
- mkdir -p build
|
||||
- cd build
|
||||
- pwd
|
||||
- cmake -G "Unix Makefiles" -DCMAKE_PREFIX_PATH=../Catch2/installed ..
|
||||
- chmod +x .ci/install.sh
|
||||
- ./.ci/install.sh
|
||||
|
||||
script:
|
||||
- cmake --build . -- -j${JOBS}
|
||||
- ctest --output-on-failure -j${JOBS}
|
||||
- chmod +x .ci/run.sh
|
||||
- ./.ci/run.sh
|
||||
|
||||
notifications:
|
||||
email: false
|
||||
|
|
83
conanfile.py
Normal file
83
conanfile.py
Normal file
|
@ -0,0 +1,83 @@
|
|||
#!/usr/bin/env python
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
from conans import ConanFile, tools, CMake
|
||||
from conans.model.version import Version
|
||||
from conans.errors import ConanInvalidConfiguration
|
||||
|
||||
class NameofConan(ConanFile):
|
||||
name = 'nameof'
|
||||
version = '0.9.0'
|
||||
description = 'Header-only C++17 library provides nameof macros and functions to obtain simple name of variable, type, function, macro, and enum.'
|
||||
topics = (
|
||||
'conan',
|
||||
'nameof',
|
||||
'cplusplus',
|
||||
'enum-to-string',
|
||||
'serialization',
|
||||
'reflection',
|
||||
'header-only',
|
||||
'introspection',
|
||||
'compile-time'
|
||||
)
|
||||
url = 'https://github.com/Neargye/nameof'
|
||||
author = 'Daniil Goncharov <neargye@gmail.com>'
|
||||
license = 'MIT'
|
||||
generators = 'cmake_find_package'
|
||||
exports_sources = ['example/*', 'include/*', 'test/*', 'CMakeLists.txt', 'LICENSE']
|
||||
exports = ['LICENSE.md']
|
||||
_build_subfolder = 'build_subfolder'
|
||||
build_requires = []
|
||||
settings = ('os', 'compiler', 'build_type', 'arch')
|
||||
options = {
|
||||
'build_tests': [True, False],
|
||||
'build_examples': [True, False],
|
||||
}
|
||||
default_options = {
|
||||
'build_tests': False,
|
||||
'build_examples': False,
|
||||
}
|
||||
|
||||
@property
|
||||
def supports_string_view(self):
|
||||
compiler = str(self.settings.compiler)
|
||||
version = Version(str(self.settings.compiler.version))
|
||||
if compiler == 'Visual Studio' and version >= Version('15'):
|
||||
return True
|
||||
if compiler == 'gcc' and version >= Version('7'):
|
||||
return True
|
||||
if compiler == 'icc' and version >= Version('19'):
|
||||
return True
|
||||
if compiler == 'clang' and version >= Version('5'):
|
||||
return True
|
||||
if compiler == 'apple-clang' and version >= Version('9'):
|
||||
return True
|
||||
return False
|
||||
|
||||
def requirements(self):
|
||||
if self.options.build_tests:
|
||||
self.build_requires.append('Catch2/2.9.1@catchorg/stable')
|
||||
|
||||
def configure(self):
|
||||
if not self.supports_string_view:
|
||||
raise ConanInvalidConfiguration('The specified compiler must support C++17')
|
||||
|
||||
def configure_cmake(self):
|
||||
cmake = CMake(self)
|
||||
cmake.definitions['NAMEOF_OPT_BUILD_TESTS'] = self.options.build_tests
|
||||
cmake.definitions['NAMEOF_OPT_BUILD_EXAMPLES'] = self.options.build_examples
|
||||
cmake.configure(build_folder=self._build_subfolder)
|
||||
return cmake
|
||||
|
||||
def build(self):
|
||||
cmake = self.configure_cmake()
|
||||
cmake.build()
|
||||
if self.options.build_tests and not tools.cross_building(self.settings):
|
||||
cmake.test()
|
||||
|
||||
def package(self):
|
||||
cmake = self.configure_cmake()
|
||||
cmake.install()
|
||||
|
||||
def package_id(self):
|
||||
self.info.header_only()
|
11
test_package/CMakeLists.txt
Normal file
11
test_package/CMakeLists.txt
Normal file
|
@ -0,0 +1,11 @@
|
|||
cmake_minimum_required(VERSION 2.8.12)
|
||||
project(test_package CXX)
|
||||
|
||||
set(CMAKE_VERBOSE_MAKEFILE TRUE)
|
||||
|
||||
include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake)
|
||||
conan_basic_setup()
|
||||
|
||||
add_executable(test_package test_package.cpp)
|
||||
target_link_libraries(test_package ${CONAN_LIBS})
|
||||
set_target_properties(test_package PROPERTIES CXX_STANDARD 17)
|
19
test_package/conanfile.py
Normal file
19
test_package/conanfile.py
Normal file
|
@ -0,0 +1,19 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
|
||||
from conans import ConanFile, CMake, tools
|
||||
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):
|
||||
if not tools.cross_building(self.settings):
|
||||
bin_path = os.path.join("bin", "test_package")
|
||||
self.run(bin_path, run_environment=True)
|
27
test_package/test_package.cpp
Normal file
27
test_package/test_package.cpp
Normal file
|
@ -0,0 +1,27 @@
|
|||
#include <nameof.hpp>
|
||||
|
||||
#include <cstdlib>
|
||||
#include <iostream>
|
||||
#include <string_view>
|
||||
|
||||
struct SomeStruct {};
|
||||
|
||||
SomeStruct structvar;
|
||||
|
||||
int main() {
|
||||
// Compile-time.
|
||||
constexpr auto name = NAMEOF(structvar);
|
||||
static_assert("structvar" == name);
|
||||
|
||||
// Nameof.
|
||||
std::string_view res1 = NAMEOF(structvar);
|
||||
std::string_view res2 = NAMEOF(::structvar);
|
||||
|
||||
std::cout << res1 << '\n' << res2 << '\n';
|
||||
|
||||
using std::literals::string_view_literals::operator""sv;
|
||||
|
||||
bool success = (res1 == "structvar"sv) && (res2 == "structvar"sv);
|
||||
|
||||
return success ? EXIT_SUCCESS : EXIT_FAILURE;
|
||||
}
|
Loading…
Reference in a new issue