kos/scripts/test/noroot.lib.sh
Ari Archer cbcc1346d7
Pre-42: Security notices, removal, abstraction, fixes and documentation
- Add a notice for security of authentication storing
    - Add a TODO for it
- Remove flags
- Add a config option to disable effective ID setting
- Add a `WERRORIF_COND` macro for the `ERRORIF_COND(WSTRERRNO(x), y)` pattern
- Fix the way if `cin` is EOF it'd exit with `EXIT_FAILURE` rather than `EXIT_STDIN`
- Fix the formatting of some errors
- Added some notes for developers

Signed-off-by: Ari Archer <ari.web.xyz@gmail.com>
2022-10-15 23:29:25 +03:00

43 lines
763 B
Bash

#!/usr/bin/env bash
COMPILERS=(g++ clang++)
OPTIMISE_FLAGS=(-O0 -Og -Os -O2 -O3 -Ofast -flto)
CXXFLAGS="${CXXFLAGS:-}"
log() {
echo -e " * $1" >&2
}
run() {
log "$1"
eval "$2"
printf ' >>> '
ls --color=auto -lahF kos
echo
}
compile() {
flags="$CXXFLAGS $_CXXFLAGS"
for compiler in "${COMPILERS[@]}"; do
run "Compiling with $compiler (CXXFLAGS = ${flags})" \
"CXX='$compiler' CXXFLAGS='$flags' ./scripts/build.sh"
[ "$1" ] && eval "$1"
./kos
if [ "$?" -ne 1 ]; then
log 'Failed to execute -- aborting'
exit 1
fi
done
}
optimising() {
for flag in "${OPTIMISE_FLAGS[@]}"; do
export _CXXFLAGS="$flag"
compile "$1"
done
}