From 9b454b7a9bc2ff2c608dcb66c4dfccdc1c40e150 Mon Sep 17 00:00:00 2001 From: Tamas Kenez Date: Wed, 23 Sep 2015 17:43:36 +0200 Subject: [PATCH] add travis testing (gcc5, clang36) - also relaxed CMake version to 2.8.7, the version default in travis --- .travis.yml | 67 ++++++++++++++++++++++++++++++++++++++++++++ CMakeLists.txt | 6 ++-- README.md | 18 ++++++------ tests/CMakeLists.txt | 10 +++---- 4 files changed, 84 insertions(+), 17 deletions(-) create mode 100644 .travis.yml diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..524f1fb --- /dev/null +++ b/.travis.yml @@ -0,0 +1,67 @@ +# Based on https://github.com/ldionne/hana/blob/master/.travis.yml + +language: cpp +sudo: false + +matrix: + include: + - env: COMPILER=clang++-3.6 BUILD_TYPE=Debug CLANG=1 + compiler: clang + addons: &clang36 + apt: + packages: + - clang-3.6 + - cmake + sources: &sources + - ubuntu-toolchain-r-test + - llvm-toolchain-precise-3.6 + - kalakris-cmake + - env: COMPILER=clang++-3.6 BUILD_TYPE=Release CLANG=1 + compiler: clang + addons: *clang36 + - env: COMPILER=g++-5 BUILD_TYPE=Debug + compiler: gcc + addons: &gcc5 + apt: + packages: g++-5 + sources: *sources + - env: COMPILER=g++-5 BUILD_TYPE=Release + compiler: gcc + addons: *gcc5 + +install: + - which $COMPILER + - DEPS_DIR="${TRAVIS_BUILD_DIR}/deps" + - mkdir ${DEPS_DIR} && cd ${DEPS_DIR} + - | + if [[ "$CLANG" == 1 && "${TRAVIS_OS_NAME}" == "linux" && "${STDLIB}" != "libstdc++" ]]; then + if [[ "${COMPILER}" == "clang++-3.5" ]]; then LLVM_VERSION="3.5.2"; fi + if [[ "${COMPILER}" == "clang++-3.6" ]]; then LLVM_VERSION="3.6.2"; fi + if [[ "${COMPILER}" == "clang++-3.7" ]]; then LLVM_VERSION="3.7.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 --quiet -O - ${LLVM_URL} | tar --strip-components=1 -xJ -C llvm + travis_retry wget --quiet -O - ${LIBCXX_URL} | tar --strip-components=1 -xJ -C llvm/projects/libcxx + travis_retry wget --quiet -O - ${LIBCXXABI_URL} | tar --strip-components=1 -xJ -C llvm/projects/libcxxabi + (cd llvm/build && cmake .. -DCMAKE_INSTALL_PREFIX=${DEPS_DIR}/llvm/install -DCMAKE_CXX_COMPILER=clang++) + (cd llvm/build/projects/libcxx && make install -j2) + (cd llvm/build/projects/libcxxabi && make install -j2) + export CXXFLAGS="-I ${DEPS_DIR}/llvm/install/include/c++/v1" + export LDFLAGS="-L ${DEPS_DIR}/llvm/install/lib -l c++ -l c++abi" + export LD_LIBRARY_PATH="${LD_LIBRARY_PATH}:${DEPS_DIR}/llvm/install/lib" + fi + +before_script: + - cd ${TRAVIS_BUILD_DIR} + - git clone --depth 1 https://github.com/Microsoft/unittest-cpp tests/unittest-cpp + - cmake -H. -Bb -DCMAKE_CXX_COMPILER=$COMPILER -DCMAKE_INSTALL_PREFIX=$PWD/o -DCMAKE_BUILD_TYPE=$BUILD_TYPE + - cmake --build b + +script: + - cd b + - ctest + +notifications: + email: false diff --git a/CMakeLists.txt b/CMakeLists.txt index 2125f7b..f8145d6 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,6 +1,6 @@ -cmake_minimum_required(VERSION 3.2.2) +cmake_minimum_required(VERSION 2.8.7) -project(GSL) +project(GSL CXX) include_directories( ${CMAKE_CURRENT_BINARY_DIR} @@ -8,4 +8,4 @@ include_directories( enable_testing() -add_subdirectory(tests) \ No newline at end of file +add_subdirectory(tests) diff --git a/README.md b/README.md index e34948a..300b103 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ -# GSL: Guidelines Support Library +# GSL: Guidelines Support Library [![Build Status](https://travis-ci.org/Microsoft/GSL.svg?branch=master)](https://travis-ci.org/Microsoft/GSL) The Guidelines Support Library (GSL) contains functions and types that are suggested for use by the -[C++ Core Guidelines](https://github.com/isocpp/CppCoreGuidelines) maintained by the [Standard C++ Foundation](https://isocpp.org). +[C++ Core Guidelines](https://github.com/isocpp/CppCoreGuidelines) maintained by the [Standard C++ Foundation](https://isocpp.org). This repo contains Microsoft's implementation of GSL. The library includes types like `array_view<>`, `string_view<>`, `owner<>` and others. @@ -12,7 +12,7 @@ While some types have been broken out into their own headers (e.g. [include/arra it is simplest to just include [gsl.h](./include/gsl.h) and gain access to the entire library. > NOTE: We encourage contributions that improve or refine any of the types in this library as well as ports to -other platforms. Please see [CONTRIBUTING.md](./CONTRIBUTING.md) for more information about contributing. +other platforms. Please see [CONTRIBUTING.md](./CONTRIBUTING.md) for more information about contributing. # Quick Start ## Supported Platforms @@ -27,13 +27,13 @@ The test suite that exercises GSL has been built and passes successfully on the * Mac OS Yosemite using XCode with AppleClang 7.0.0.7000072 * Mac OS Yosemite using GCC-5.2.0 -> If you successfully port GSL to another platform, we would love to hear from you. Please submit an issue to let us know. Also please consider -contributing any changes that were necessary back to this project to benefit the wider community. +> If you successfully port GSL to another platform, we would love to hear from you. Please submit an issue to let us know. Also please consider +contributing any changes that were necessary back to this project to benefit the wider community. ## Building the tests To build the tests, you will require the following: -* [CMake](http://cmake.org), version 3.3 or later to be installed and in your PATH. +* [CMake](http://cmake.org), version 2.8.7 or later to be installed and in your PATH. * [UnitTest-cpp](https://github.com/Microsoft/unittest-cpp), to be cloned under the [tests/unittest-cpp](./tests/unittest-cpp) directory of your GSL source. @@ -46,13 +46,13 @@ These steps assume the source code of this repository has been cloned into a dir cd build-x86 2. Configure CMake to use the compiler of your choice (you can see a list by running `cmake --help`). - + cmake -G "Visual Studio 14 2015" c:\GSL - + 3. Build the test suite (in this case, in the Debug configuration, Release is another good choice). cmake --build . --config Debug - + 4. Run the test suite. ctest -C Debug diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index ad7a38c..0415db3 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -1,6 +1,6 @@ -cmake_minimum_required(VERSION 3.2.2) +cmake_minimum_required(VERSION 2.8.7) -project(GSLTests) +project(GSLTests CXX) add_subdirectory(unittest-cpp) @@ -23,7 +23,7 @@ else() elseif(COMPILER_SUPPORTS_CXX11) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11") else() - message(STATUS "The compiler ${CMAKE_CXX_COMPILER} has no C++11 support. Please use a different C++ compiler.") + message(STATUS "The compiler ${CMAKE_CXX_COMPILER} has no C++11 support. Please use a different C++ compiler.") endif() endif() @@ -38,8 +38,8 @@ function(add_gsl_test name) RUNTIME DESTINATION bin ) add_test( - NAME ${name} - COMMAND ${name} + ${name} + ${name} ) endfunction()