#!/bin/bash
set -e
tool=build/clang-x86_64-pc-windows-msvc/Release/r3_gh_tool
cmake --build build/clang-x86_64-pc-windows-msvc/Release --target r3_gh_tool

types=(auto ref fix stub)
for type in "${types[@]}"; do
    file_list="files_${type}.txt"
    rm -f "$file_list"

    if [ -d "tmps/gh_${type}" ]; then
        for file in "tmps/gh_${type}"/*.cxx; do
            echo "$file" >>"$file_list"
        done
        $tool "@$file_list" -v --type=$type --log-file=log-functions.txt
    fi
done

$tool tmps/gh_global.h -mglobals -v --log-file=log-globals.txt
$tool -mduplicates -v --log-file=log-duplicates.txt
