version: 0.2
#this buildspec assumes the ubuntu aws/codebuild/java:openjdk-8 image
phases:
  install:
    commands:
      - wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key | sudo apt-key add -
      - sudo add-apt-repository ppa:ubuntu-toolchain-r/test
      - sudo apt-add-repository "deb http://apt.llvm.org/trusty/ llvm-toolchain-trusty-6.0 main"
      - sudo apt-get update -y
      - sudo apt-get install clang-6.0 cmake3 cppcheck clang-format-6.0 ninja-build -y -f
  pre_build:
    commands:
      - export CC=clang-6.0
      - export CLANG_FORMAT=clang-format-6.0
  build:
    commands:
      - echo Build started on `date`
      - $CODEBUILD_SRC_DIR/codebuild/common-linux.sh -DCMAKE_EXPORT_COMPILE_COMMANDS=ON
      - $CODEBUILD_SRC_DIR/format-check.sh
  post_build:
    commands:
      - echo Build completed on `date`

artifacts:
  discard-paths: yes
  files: 
    - 'target/surefire-reports/**'
    - 'hs_err_pid*'
    - 'core*'
