Build scripts

This commit is contained in:
Abdelrahman Said 2023-10-21 18:59:20 +01:00
parent 945bb3ff51
commit 9451c7d4db
2 changed files with 75 additions and 0 deletions

3
build Executable file
View File

@ -0,0 +1,3 @@
#!/bin/bash
bear -- ./compile "$@"

72
compile Executable file
View File

@ -0,0 +1,72 @@
#!/bin/bash
#ESCAPE SEQUENCES
CLEAR="\033[0m"
BOLD="\033[1"
FG_BLACK="\033[30"
FG_RED="\033[31"
FG_GREEN="\033[32"
FG_YELLOW="\033[33"
FG_BLUE="\033[34"
FG_MAGENTA="\033[35"
FG_CYAN="\033[36"
FG_WHITE="\033[37"
FG_BR_BLACK="\033[90"
FG_BR_RED="\033[91"
FG_BR_GREEN="\033[92"
FG_BR_YELLOW="\033[93"
FG_BR_BLUE="\033[94"
FG_BR_MAGENTA="\033[95"
FG_BR_CYAN="\033[96"
FG_BR_WHITE="\033[97"
CC=clang
CFLAGS="-Wall -Werror -pedantic -Iinclude "
PCKR_SRC="\
src/path_utils.c \
src/argparse.c \
src/io.c \
src/darr.c \
src/pak.c \
src/pckr.c \
src/main.c"
PCKR_TEST_SRC="\
src/path_utils.c \
src/io.c \
src/pckr_test.c"
PCKR_TEST_OUT="pckr_test"
BUILD_TYPE="debug"
while [[ $# -gt 0 ]]; do
case $1 in
-r|--release)
BUILD_TYPE="release"
shift # past argument
;;
-*|--*|*)
echo "Usage: build [-r | --release]"
exit 1
;;
esac
done
if [[ $BUILD_TYPE == "debug" ]]; then
CFLAGS+="-g "
PCKR_OUT="pckr"
else
CFLAGS+="-O3 "
PCKR_OUT="../proj/pckr"
fi
# Build pckr executable
(set -x ; $CC $CFLAGS $PCKR_SRC -o $PCKR_OUT)
# Build pckr_test executable
(set -x ; $CC $CFLAGS $PCKR_TEST_SRC -o $PCKR_TEST_OUT)
# Run pckr test
./pckr ./test_assets ./assets
(./$PCKR_TEST_OUT && echo -e "\npckr_test [${FG_BR_GREEN}m${BOLD}m SUCCESS $CLEAR]") || echo -e "\npckr_test [${FG_BR_RED}m${BOLD}m FAILURE $CLEAR]"
rm ./assets.pak
rm pckr_test