| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495 | #!/bin/bashset -eclearcd $(dirname $0)printHelpExit() {    echo "$0 clean       | remove build results"    echo "$0 build       | build everything"    echo "$0 test        | run the tests"    echo "$0 performance | run the performance tests"    echo "$0 final       | find classes / structs which are not final"    echo "$0 macro       | find macros without CORE"     echo "$0 include     | find system includes in header files"     echo "$0 time        | check build time"    exit 0}task=$1if [ -z "$task" ]; then    printHelpExitfi# tasksbuild=falsetest=falseperformance=falsetime=false# parsingif [ "$task" = "clean" ]; then    rm -rf build    exit 0elif [ "$task" = "build" ]; then    build=trueelif [ "$task" = "test" ]; then    build=true    test=trueelif [ "$task" = "performance" ]; then    build=true    performance=trueelif [ "$task" = "time" ]; then    build=true    time=trueelif [ "$task" = "final" ]; then    grep -r " class" src | grep -v -E 'final|enum|.git' || true    grep -r " struct" src | grep -v -E 'final|enum|.git' || true    exit 0elif [ "$task" = "macro" ]; then    grep -r "#define" src | grep -v " CORE" || true    exit 0elif [ "$task" = "include" ]; then    grep -r "#include <" src | grep "\.hpp" || true    exit 0else    echo "unknown task"    printHelpExitfi# task executionif $build; then    if [ ! -e build ]; then         cmake -B build -S src -G Ninja    fi    ninja -C buildfiif $test; then    cd build    ./testfiif $performance; then    cd build    ./performancefiif $time; then    lines=$(cat build/.ninja_log | grep "^[0-9]")    startMillis=0    endMillis=0    name=""    i=0    output=""    for arg in $lines; do        if [ $i == 0 ]; then            startMillis=$arg        elif [ $i == 1 ]; then            endMillis=$arg        elif [ $i == 3 ]; then            name=$arg            diff=$(expr $endMillis - $startMillis)            output="${output}\n$diff $name"        fi        i=$(expr $(expr $i + 1) % 5) && true    done    printf "$output" | sort -nfi
 |