From 7433e7865d9274199798203da5f0370ab789c0d7 Mon Sep 17 00:00:00 2001 From: franchuti688 Date: Mon, 9 Feb 2015 10:31:22 +0100 Subject: [PATCH] adapted to biicode via biicode.conf, ignore.bii and CMakeLists.txt; mixed Travis (original and biicode building); added biicode folder with biicode.cmake and a simple cppformat example --- .travis.yml | 30 +++++++++++++++++++++++++++--- CMakeLists.txt | 5 +++++ biicode.conf | 16 ++++++++++++++++ biicode/cmake/biicode.cmake | 18 ++++++++++++++++++ biicode/samples/basic.cpp | 18 ++++++++++++++++++ ignore.bii | 3 +++ 6 files changed, 87 insertions(+), 3 deletions(-) create mode 100644 biicode.conf create mode 100644 biicode/cmake/biicode.cmake create mode 100644 biicode/samples/basic.cpp create mode 100644 ignore.bii diff --git a/.travis.yml b/.travis.yml index eeb50ce0de713..05d6a4e82b5ba 100644 --- a/.travis.yml +++ b/.travis.yml @@ -5,19 +5,43 @@ os: - osx before_install: - - if [ $TRAVIS_OS_NAME == osx ]; then curl http://www.cmake.org/files/v2.8/cmake-2.8.12.2-Darwin64-universal.tar.gz -o cmake.tar.gz; fi + - if [ $TRAVIS_OS_NAME == osx ]; then curl http://www.cmake.org/files/v3.0/cmake-3.0.2-Darwin64-universal.tar.gz -o cmake.tar.gz; fi - if [ $TRAVIS_OS_NAME == osx ]; then tar xzf cmake.tar.gz; fi - - if [ $TRAVIS_OS_NAME == osx ]; then export PATH=$PATH:"cmake-2.8.12.2-Darwin64-universal/CMake 2.8-12.app/Contents/bin"; fi + - if [ $TRAVIS_OS_NAME == osx ]; then export PATH=$PATH:"cmake-3.0.2-Darwin64-universal/CMake.app/Contents/bin"; fi - git submodule update --init +# Preparing all the necessary tools to try cppformat with biicode +install: + - if [ $TRAVIS_OS_NAME == linux ]; then sudo apt-get install libglu1-mesa-dev xorg-dev; fi + - if [ $TRAVIS_OS_NAME == linux ]; then wget http://www.biicode.com/downloads/latest/ubuntu64; elif [ $TRAVIS_OS_NAME == osx ]; then wget http://www.biicode.com/downloads/latest/macos; fi + - if [ $TRAVIS_OS_NAME == linux ]; then mv ubuntu64 bii-ubuntu64.deb; elif [ $TRAVIS_OS_NAME == osx ]; then mv macos macos.pkg; fi + - if [ $TRAVIS_OS_NAME == linux ]; then (sudo dpkg -i bii-ubuntu64.deb) && sudo apt-get -f install; elif [ $TRAVIS_OS_NAME == osx ]; then sudo installer -pkg macos.pkg -target /; fi + - if [ $TRAVIS_OS_NAME == linux ]; then rm bii-ubuntu64.deb; elif [ $TRAVIS_OS_NAME == osx ]; then rm macos.pkg; fi + - if [ $TRAVIS_OS_NAME == linux ]; then wget https://s3.amazonaws.com/biibinaries/thirdparty/cmake-3.0.2-Linux-64.tar.gz; fi + - if [ $TRAVIS_OS_NAME == linux ]; then tar -xzf cmake-3.0.2-Linux-64.tar.gz; fi + - if [ $TRAVIS_OS_NAME == linux ]; then sudo cp -fR cmake-3.0.2-Linux-64/* /usr; fi + - if [ $TRAVIS_OS_NAME == linux ]; then rm -rf cmake-3.0.2-Linux-64; fi + - if [ $TRAVIS_OS_NAME == linux ]; then rm cmake-3.0.2-Linux-64.tar.gz; fi + env: - BUILD_TYPE=Debug - BUILD_TYPE=Release script: - - cmake -DCMAKE_BUILD_TYPE=$BUILD_TYPE -DFMT_EXTRA_TESTS=ON . + # Original building + - mkdir build && cd build + - cmake -DCMAKE_BUILD_TYPE=$BUILD_TYPE -DFMT_EXTRA_TESTS=ON .. - make -j4 - CTEST_OUTPUT_ON_FAILURE=1 make test + # Building with biicode + - cd .. && rm -rf build/ && bii init biicode_project + - mkdir -p ./biicode_project/blocks/vitaut/cppformat + - mv !(biicode_project) ./biicode_project/blocks/vitaut/cppformat + - cd biicode_project + - bii cpp:build + - ls bin/* + - ./bin/vitaut_cppformat_biicode_samples_basic + after_failure: - cat Testing/Temporary/LastTest.log diff --git a/CMakeLists.txt b/CMakeLists.txt index b73f5979c51f0..bf3de71839862 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -61,6 +61,11 @@ if (CPP11_FLAG) set(CMAKE_REQUIRED_FLAGS ${CPP11_FLAG}) endif () +if(BIICODE) + include(biicode/cmake/biicode.cmake) + return() +endif(BIICODE) + add_library(format ${FMT_SOURCES}) if (CMAKE_COMPILER_IS_GNUCXX) set_target_properties(format PROPERTIES COMPILE_FLAGS diff --git a/biicode.conf b/biicode.conf new file mode 100644 index 0000000000000..f4fd4bce2d619 --- /dev/null +++ b/biicode.conf @@ -0,0 +1,16 @@ +# Biicode configuration file + +[paths] + # Local directories to look for headers (within block) + / + +[dependencies] + # Manual adjust file implicit dependencies, add (+), remove (-), or overwrite (=) + CMakeLists.txt + cmake/FindSetEnv.cmake + format.h = format.cc + format.cc - test/* posix.cc + biicode/samples/basic.cpp - test/* + +[mains] + # Manual adjust of files that define an executable + !test/test-main.cc diff --git a/biicode/cmake/biicode.cmake b/biicode/cmake/biicode.cmake new file mode 100644 index 0000000000000..02d6ee2465c61 --- /dev/null +++ b/biicode/cmake/biicode.cmake @@ -0,0 +1,18 @@ +# Initializes block variables +INIT_BIICODE_BLOCK() + +# Actually create targets: EXEcutables and libraries. +ADD_BIICODE_TARGETS() + +target_include_directories(${BII_BLOCK_TARGET} INTERFACE ${CMAKE_CURRENT_SOURCE_DIR}) + +if (HAVE_OPEN) + target_compile_definitions(${BII_BLOCK_TARGET} INTERFACE -DFMT_USE_FILE_DESCRIPTORS=1) +endif () + +if (CMAKE_COMPILER_IS_GNUCXX) + target_compile_options(${BII_BLOCK_TARGET} INTERFACE -Wall -Wextra -Wshadow -pedantic) +endif () +if (CPP11_FLAG AND FMT_EXTRA_TESTS) + target_compile_options(${BII_BLOCK_TARGET} INTERFACE ${CPP11_FLAG}) +endif () diff --git a/biicode/samples/basic.cpp b/biicode/samples/basic.cpp new file mode 100644 index 0000000000000..727ed013690d8 --- /dev/null +++ b/biicode/samples/basic.cpp @@ -0,0 +1,18 @@ +#include "vitaut/cppformat/format.h" + +class Date { + int year_, month_, day_; + public: + Date(int year, int month, int day) : year_(year), month_(month), day_(day) {} + + friend std::ostream &operator<<(std::ostream &os, const Date &d) { + return os << d.year_ << '-' << d.month_ << '-' << d.day_; + } +}; + +int main(int argc, char *argv[]){ + std::string s = fmt::format("The date is {}", Date(2012, 12, 9)); + fmt::print("Hello, {}!", "world"); // uses Python-like format string syntax + fmt::printf("\n%s", s); // uses printf format string syntax + return 0; +} diff --git a/ignore.bii b/ignore.bii new file mode 100644 index 0000000000000..8944b6194d651 --- /dev/null +++ b/ignore.bii @@ -0,0 +1,3 @@ +doc/* +breathe/* +gmock/*