Browse Source

Funny build script go brrrrr

master
A.Olokhtonov 3 years ago
parent
commit
15616e46cb
  1. 43
      build.sh

43
build.sh

@ -1,33 +1,46 @@
#!/bin/bash #!/bin/bash
set -e set -e
set -x
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )" 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 if [[ $# = 0 ]]; then
pushd src echo "Entering directory: src"
pushd src >/dev/null
mkdir -p ../build 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 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 elif [[ $1 = "examples" ]]; then
pushd res echo "Entering directory: res"
gcc -g -o 001-simple 001-simple.c pushd res >/dev/null
gcc -g -o 002-compilation-units 002-compilation-units.c 002-compilation-units-impl.c echo -n "Compiling examples"
gcc -g -o 003-recursion 003-recursion.c gcc -g -o 001-simple 001-simple.c && echo -n "."
gcc -g -o 004-scoped-variables 004-scoped-variables.c gcc -g -o 002-compilation-units 002-compilation-units.c 002-compilation-units-impl.c && echo -n "."
gcc -g -o 005-base-types 005-base-types.c gcc -g -o 003-recursion 003-recursion.c && echo -n "."
gcc -g -o 006-composite-types 006-composite-types.c gcc -g -o 004-scoped-variables 004-scoped-variables.c && echo -n "."
popd 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 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 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 elif [[ $1 = "clean" ]]; then
rm build/* rm build/*
else else
echo "No such target '$1'" echo "No such target '$1'"
fi fi
popd echo "Leaving project directory"
popd >/dev/null
Loading…
Cancel
Save