From 15616e46cb01d3e695448f0ca59cb47c6741c3e7 Mon Sep 17 00:00:00 2001 From: "A.Olokhtonov" Date: Tue, 27 Jul 2021 15:12:00 +0300 Subject: [PATCH] Funny build script go brrrrr --- build.sh | 43 ++++++++++++++++++++++++++++--------------- 1 file changed, 28 insertions(+), 15 deletions(-) diff --git a/build.sh b/build.sh index 41f5cb4..8b411e8 100755 --- a/build.sh +++ b/build.sh @@ -1,33 +1,46 @@ #!/bin/bash set -e -set -x SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )" -pushd $SCRIPT_DIR +echo "Entering project directory: $SCRIPT_DIR" +pushd $SCRIPT_DIR >/dev/null if [[ $# = 0 ]]; then - pushd src + echo "Entering directory: src" + pushd src >/dev/null mkdir -p ../build + echo -n "Compiling main.c..." gcc main.c -g -O0 -o ../build/trace -Wall -Wextra -Wno-unused-variable -Wno-unused-function -Wno-switch # -fsanitize=address - popd + echo " Done. Built ../build/trace" + echo "Leaving directory: src" + popd >/dev/null elif [[ $1 = "examples" ]]; then - pushd res - gcc -g -o 001-simple 001-simple.c - gcc -g -o 002-compilation-units 002-compilation-units.c 002-compilation-units-impl.c - gcc -g -o 003-recursion 003-recursion.c - gcc -g -o 004-scoped-variables 004-scoped-variables.c - gcc -g -o 005-base-types 005-base-types.c - gcc -g -o 006-composite-types 006-composite-types.c - popd + echo "Entering directory: res" + pushd res >/dev/null + echo -n "Compiling examples" + gcc -g -o 001-simple 001-simple.c && echo -n "." + gcc -g -o 002-compilation-units 002-compilation-units.c 002-compilation-units-impl.c && echo -n "." + gcc -g -o 003-recursion 003-recursion.c && echo -n "." + gcc -g -o 004-scoped-variables 004-scoped-variables.c && echo -n "." + gcc -g -o 005-base-types 005-base-types.c && echo -n "." + gcc -g -o 006-composite-types 006-composite-types.c && echo -n "." + echo " Done" + echo "Leaving directory: res" + popd >/dev/null elif [[ $1 = "tests" ]]; then - pushd test/ + echo "Entering directory: test" + pushd test >/dev/null + echo -n "Compiling test_main.c..." gcc test_main.c -g -o ../build/test -Wall -Wextra -Wno-unused-function -Wno-unused-variable - popd + echo " Done. Built ../build/test" + echo "Leaving directory: test" + popd >/dev/null elif [[ $1 = "clean" ]]; then rm build/* else echo "No such target '$1'" fi -popd \ No newline at end of file +echo "Leaving project directory" +popd >/dev/null \ No newline at end of file