2020-10-29 18:12:21 +01:00
|
|
|
#!/bin/bash
|
|
|
|
set -e
|
2021-03-15 23:08:16 +01:00
|
|
|
cd -- "$(dirname -- "${BASH_SOURCE[0]}")"
|
|
|
|
|
2020-11-01 22:46:25 +01:00
|
|
|
readonly USE_LTO=1
|
2020-10-29 18:12:21 +01:00
|
|
|
|
2020-10-31 16:33:53 +01:00
|
|
|
PLATFORM="$(uname -a)"
|
2020-10-29 18:12:21 +01:00
|
|
|
unset SUFFIX
|
|
|
|
if [[ "${PLATFORM}" == MINGW* || "${PLATFORM}" == CYGWIN* ]]; then
|
|
|
|
SUFFIX=".exe"
|
|
|
|
fi
|
|
|
|
|
2020-10-31 16:33:53 +01:00
|
|
|
[ -e /dev/urandom ] && RANDOM_SOURCE="/dev/urandom" || RANDOM_SOURCE="/dev/random"
|
|
|
|
TMP_NAME="$(tr -dc 'a-zA-Z0-9' < ${RANDOM_SOURCE} | fold -w 12 | head -n 1)"
|
|
|
|
PGO_PATH="$(tr -dc 'a-zA-Z0-9' < ${RANDOM_SOURCE} | fold -w 12 | head -n 1)"
|
|
|
|
trap "printf \"\033[1;31m\nBuild has failed !!!\033[0m\n\n\"" ERR
|
|
|
|
trap "rm -rf /tmp/${TMP_NAME}.dat /tmp/${TMP_NAME}.enc /tmp/${TMP_NAME}.out /tmp/${PGO_PATH}" EXIT
|
|
|
|
|
|
|
|
printf "\033[1;36m\n------------------------------------------------------------------------------\033[0m\n"
|
|
|
|
printf "\033[1;36mClean\n"
|
|
|
|
printf "\033[1;36m------------------------------------------------------------------------------\033[0m\n\n"
|
2020-10-29 18:12:21 +01:00
|
|
|
|
|
|
|
make clean
|
|
|
|
|
2020-10-31 16:33:53 +01:00
|
|
|
printf "\033[1;36m\n------------------------------------------------------------------------------\033[0m\n"
|
|
|
|
printf "\033[1;36mInstrument\n"
|
|
|
|
printf "\033[1;36m------------------------------------------------------------------------------\033[0m\n\n"
|
|
|
|
|
2020-11-01 22:46:25 +01:00
|
|
|
make FLTO=${USE_LTO} FPGO="generate=/tmp/${PGO_PATH}" -B "$@"
|
2020-10-31 16:33:53 +01:00
|
|
|
|
|
|
|
printf "\033[1;36m\n------------------------------------------------------------------------------\033[0m\n"
|
|
|
|
printf "\033[1;36mProfiling\n"
|
|
|
|
printf "\033[1;36m------------------------------------------------------------------------------\033[0m\n\n"
|
|
|
|
|
2020-11-03 23:19:00 +01:00
|
|
|
dd bs=1024 count=102400 < ${RANDOM_SOURCE} > /tmp/${TMP_NAME}.dat
|
|
|
|
printf "\n"
|
2020-12-01 17:28:32 +01:00
|
|
|
PASSWRD="$(./frontend/bin/slunkcrypt${SUFFIX} --make-pw)"
|
2020-10-31 16:33:53 +01:00
|
|
|
|
2021-03-21 22:10:34 +01:00
|
|
|
./frontend/bin/slunkcrypt${SUFFIX} --encrypt pass:"${PASSWRD}" /tmp/${TMP_NAME}.dat /tmp/${TMP_NAME}.enc
|
|
|
|
./frontend/bin/slunkcrypt${SUFFIX} --decrypt pass:"${PASSWRD}" /tmp/${TMP_NAME}.enc /tmp/${TMP_NAME}.out
|
2020-10-29 18:12:21 +01:00
|
|
|
|
2020-10-31 16:33:53 +01:00
|
|
|
printf "\033[1;36m\n------------------------------------------------------------------------------\033[0m\n"
|
|
|
|
printf "\033[1;36mRe-compile\n"
|
|
|
|
printf "\033[1;36m------------------------------------------------------------------------------\033[0m\n\n"
|
2020-10-29 18:12:21 +01:00
|
|
|
|
2020-11-01 22:46:25 +01:00
|
|
|
make FLTO=${USE_LTO} FPGO="use=/tmp/${PGO_PATH}" STRIP=1 -B "$@"
|
2020-10-29 18:12:21 +01:00
|
|
|
|
2020-10-31 16:33:53 +01:00
|
|
|
printf "\033[1;32m\nBuild completed successfully.\033[0m\n\n"
|