#!/bin/bash set -e clear cd $(dirname $0) printHelpExit() { echo "$0 clean | remove build results" echo "$0 build | build everything" echo "$0 install | move build results into the install folder" 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=$1 if [ -z "$task" ]; then printHelpExit fi # tasks build=false test=false performance=false time=false install=false # parsing if [ "$task" = "clean" ]; then rm -rf build install exit 0 elif [ "$task" = "build" ]; then build=true elif [ "$task" = "install" ]; then build=true install=true elif [ "$task" = "test" ]; then build=true test=true elif [ "$task" = "performance" ]; then build=true performance=true elif [ "$task" = "time" ]; then build=true time=true elif [ "$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 0 elif [ "$task" = "macro" ]; then grep -r "#define" src | grep -v " CORE" || true exit 0 elif [ "$task" = "include" ]; then grep -r "#include <" src | grep "\.hpp" || true exit 0 else echo "unknown task" printHelpExit fi # task execution if $build; then if [ ! -e build ]; then cmake -B build -S . -G Ninja -DCMAKE_INSTALL_PREFIX=./install fi ninja -C build fi if $install; then ninja -C build install fi if $test; then cd build ./test fi if $performance; then cd build ./performance fi if $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 -n fi