#!/usr/bin/env bash

BUILD_DIR=$1

analyse_file () {
  DIRNAME=`dirname $1`
  echo "Analyse directory: $DIRNAME"
  cd $DIRNAME
  pvs-studio-analyzer analyze -o analyse.log --compiler gcc --compiler g++
  plog-converter -a GA:1,2 -t tasklist -o report.tasks analyse.log
  echo -e "\n**********************************\n"
  cat report.tasks
  echo -e "\n**********************************\n"
}

# Main
find ${BUILD_DIR} -name compile_commands.json | while read file; do analyse_file $file; done
