image: irmb/virtualfluids-deps:latest

stages:
  - build
  - test
  - deploy

build:
  stage: build

  artifacts:
    paths:
      - build/

  before_script:
    - export DEBIAN_FRONTEND=noninteractive
    - apt-get update

  script:
    - cmake -S . -B build -DBUILD_VF_CPU:BOOL=ON -DBUILD_VF_UNIT_TESTS:BOOL=ON
    - cmake --build build --target VirtualFluidsCore
    - cmake --build build --target basicsTests


test:
  stage: test

  before_script:
    - export DEBIAN_FRONTEND=noninteractive

  script:
    - build/bin/basicsTests



benchmark_ClangBuildAnalyzer:
  stage: deploy

  before_script:
    - export DEBIAN_FRONTEND=noninteractive
    - apt-get update
    - cmake --version
    - mpirun --version
    - export CC=clang
    - export CXX=clang++
    - $CXX --version
    - cd /tmp
    - git clone https://github.com/aras-p/ClangBuildAnalyzer.git
    - cd ClangBuildAnalyzer
    - cmake .
    - make
    - export PATH+=:$(pwd)

  script:
    - mkdir $CI_PROJECT_DIR/build
    - cd $CI_PROJECT_DIR/build
    - cmake .. -DBUILD_VF_CPU=ON -DUSE_OPENMP=OFF -DCMAKE_CXX_FLAGS=-ftime-trace
    - ClangBuildAnalyzer --start .
    - make
    - ClangBuildAnalyzer --stop . CBA
    - ClangBuildAnalyzer --analyze CBA