language: cpp

compiler:
 - clang
 - gcc

env:
  matrix:
    - CONF=debug   BITS=64
    - CONF=release BITS=64
    - CONF=debug   BITS=32
    - CONF=release BITS=32
  global:
    - GITHUB_REPO='miloyip/rapidjson'
    - DEFINES='-DRAPIDJSON_HAS_STDSTRING'
    - secure: "HrsaCb+N66EG1HR+LWH1u51SjaJyRwJEDzqJGYMB7LJ/bfqb9mWKF1fLvZGk46W5t7TVaXRDD5KHFx9DPWvKn4gRUVkwTHEy262ah5ORh8M6n/6VVVajeV/AYt2C0sswdkDBDO4Xq+xy5gdw3G8s1A4Inbm73pUh+6vx+7ltBbk="

before_install:
  - sudo add-apt-repository -y ppa:codegear/release
  - sudo apt-get update -qq
  - sudo apt-get install -qq premake4 valgrind
  - if [ "$BITS" = 32 ]; then sudo apt-get install -qq g++-multilib libc6-dbg:i386; fi

install: true

before_script:
  - (cd build && premake4 'gmake')
#   hack to avoid Valgrind bug (https://bugs.kde.org/show_bug.cgi?id=326469),
#   exposed by merging PR#163 (using -march=native)
  - (cd build/gmake && sed -i 's/march=native/msse4.2/' *.make)

script:
  - make -C build/gmake -f test.make    config=${CONF}${BITS}
  - make -C build/gmake -f example.make config=${CONF}${BITS}
  - if [ "$CONF" = "debug" ] && ( objdump -t -C intermediate/${CONF}/gmake/unittest/x${BITS}/namespacetest.o | grep rapidjson ) ; then echo "Symbol check failed!" ; false; fi
  - pushd bin
  -  ./unittest_${CONF}_x${BITS}_gmake
  - valgrind --leak-check=full --error-exitcode=1 ./unittest_${CONF}_x${BITS}_gmake
  - if [ "$CONF" = "release" ]; then ./perftest_${CONF}_x${BITS}_gmake; fi
  - popd
  - ./build/travis-doxygen.sh;
