|  | 
|  | 1 | +#!/bin/bash | 
|  | 2 | + | 
|  | 3 | +RED='033円[0;31m' | 
|  | 4 | +YEL='033円[0;33m' | 
|  | 5 | +NORMAL='033円[0m' | 
|  | 6 | +COL=12 | 
|  | 7 | + | 
|  | 8 | +exit_status=0 | 
|  | 9 | + | 
|  | 10 | +# from: https://stackoverflow.com/a/4024263 | 
|  | 11 | +function version_less() { | 
|  | 12 | + [ "1ドル" = "`echo -e "1ドル\n2ドル" | sort -V | head -n1`" ] | 
|  | 13 | +} | 
|  | 14 | + | 
|  | 15 | +function check_tool() { | 
|  | 16 | + min_version=2ドル || "0" | 
|  | 17 | + required=3ドル || true | 
|  | 18 | + if [ -x "$(command -v 1ドル)" ] | 
|  | 19 | + then | 
|  | 20 | + version=$(1ドル --version | grep -o -E "[0-9]+.[0-9]+(.[0-9]+)?" | head -1) | 
|  | 21 | + if version_less $version $min_version | 
|  | 22 | + then | 
|  | 23 | + printf "%-${COL}s found, ${RED}version: ${version}, need at least: ${min_version}${NORMAL}\n" 1ドル | 
|  | 24 | + else | 
|  | 25 | + printf "%-${COL}s found, version: ${version}\n" 1ドル | 
|  | 26 | + return 0 | 
|  | 27 | + fi | 
|  | 28 | + elif $required | 
|  | 29 | + then | 
|  | 30 | + printf "${RED}%-${COL}s not found, but required${NORMAL}\n" 1ドル | 
|  | 31 | + exit_status=1 | 
|  | 32 | + else | 
|  | 33 | + printf "${YEL}%-${COL}s not found, but optional${NORMAL}\n" 1ドル | 
|  | 34 | + fi | 
|  | 35 | + return 1 | 
|  | 36 | +} | 
|  | 37 | + | 
|  | 38 | +# compiler | 
|  | 39 | +check_tool g++ 10.0.0 false || check_tool clang++ 11.0.0 false || { echo -e "${RED}No supported compiler found${NORMAL}"; exit_status=1; } # clang does not work for header_units exercise | 
|  | 40 | + | 
|  | 41 | +# build tools | 
|  | 42 | +check_tool make | 
|  | 43 | +check_tool cmake 3.12.0 | 
|  | 44 | +check_tool ccmake 3.12.0 false | 
|  | 45 | + | 
|  | 46 | +# debugger | 
|  | 47 | +check_tool gdb 10.0.0 false || check_tool lldb 11.0.0 false || { echo -e "${RED}No supported debugger found${NORMAL}"; exit_status=1; } | 
|  | 48 | + | 
|  | 49 | +# utils | 
|  | 50 | +check_tool nm | 
|  | 51 | +check_tool ldd 0.0 false || check_tool otool 0.0 false || { echo -e "${RED}Missing ldd or otool${NORMAL}"; exit_status=1; } | 
|  | 52 | + | 
|  | 53 | +# tools | 
|  | 54 | +check_tool valgrind | 
|  | 55 | +check_tool kcachegrind | 
|  | 56 | +check_tool cppcheck | 
|  | 57 | +check_tool clang-format | 
|  | 58 | +check_tool clang-tidy | 
|  | 59 | +check_tool python3 | 
|  | 60 | + | 
|  | 61 | +exit $exit_status | 
0 commit comments