Workaround for bug in older version of the UCRT on Windows XP: Explicitly link UCRT...
[slunkcrypt.git] / mk-profiled.sh
blobe6676717b618a6510b5699045344b5690a1b3093
1 #!/bin/bash
2 set -e
3 cd -- "$(dirname -- "${BASH_SOURCE[0]}")"
5 readonly USE_LTO=1
7 PLATFORM="$(uname -a)"
8 unset SUFFIX
9 if [[ "${PLATFORM}" == MINGW* || "${PLATFORM}" == CYGWIN* ]]; then
10 SUFFIX=".exe"
13 [ -e /dev/urandom ] && RANDOM_SOURCE="/dev/urandom" || RANDOM_SOURCE="/dev/random"
14 TMP_NAME="$(tr -dc 'a-zA-Z0-9' < ${RANDOM_SOURCE} | fold -w 12 | head -n 1)"
15 PGO_PATH="$(tr -dc 'a-zA-Z0-9' < ${RANDOM_SOURCE} | fold -w 12 | head -n 1)"
16 trap "printf \"\033[1;31m\nBuild has failed !!!\033[0m\n\n\"" ERR
17 trap "rm -rf /tmp/${TMP_NAME}.dat /tmp/${TMP_NAME}.enc /tmp/${TMP_NAME}.out /tmp/${PGO_PATH}" EXIT
19 printf "\033[1;36m\n------------------------------------------------------------------------------\033[0m\n"
20 printf "\033[1;36mClean\n"
21 printf "\033[1;36m------------------------------------------------------------------------------\033[0m\n\n"
23 make clean
25 printf "\033[1;36m\n------------------------------------------------------------------------------\033[0m\n"
26 printf "\033[1;36mInstrument\n"
27 printf "\033[1;36m------------------------------------------------------------------------------\033[0m\n\n"
29 make FLTO=${USE_LTO} FPGO="generate=/tmp/${PGO_PATH}" -B "$@"
31 printf "\033[1;36m\n------------------------------------------------------------------------------\033[0m\n"
32 printf "\033[1;36mProfiling\n"
33 printf "\033[1;36m------------------------------------------------------------------------------\033[0m\n\n"
35 dd bs=1024 count=102400 < ${RANDOM_SOURCE} > /tmp/${TMP_NAME}.dat
36 printf "\n"
37 PASSWRD="$(./frontend/bin/slunkcrypt${SUFFIX} --make-pw)"
39 ./frontend/bin/slunkcrypt${SUFFIX} --self-test
40 ./frontend/bin/slunkcrypt${SUFFIX} --encrypt pass:"${PASSWRD}" /tmp/${TMP_NAME}.dat /tmp/${TMP_NAME}.enc
41 ./frontend/bin/slunkcrypt${SUFFIX} --decrypt pass:"${PASSWRD}" /tmp/${TMP_NAME}.enc /tmp/${TMP_NAME}.out
43 printf "\033[1;36m\n------------------------------------------------------------------------------\033[0m\n"
44 printf "\033[1;36mRe-compile\n"
45 printf "\033[1;36m------------------------------------------------------------------------------\033[0m\n\n"
47 make FLTO=${USE_LTO} FPGO="use=/tmp/${PGO_PATH}" STRIP=1 -B "$@"
49 printf "\033[1;32m\nBuild completed successfully.\033[0m\n\n"