diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..f6552f0 --- /dev/null +++ b/.gitignore @@ -0,0 +1,11 @@ + +.local/ + +# The build script's working files +.build/ + +# Executable-/ Object files +*.a +*.elf +*.o +*.so \ No newline at end of file diff --git a/build.bash b/build.bash new file mode 100755 index 0000000..6325aae --- /dev/null +++ b/build.bash @@ -0,0 +1,77 @@ +#!/usr/bin/env bash + +INCLUDE_STATEMENTS="-I code/inc/ -I code/exports/" +INVOCATION_PATH=`pwd` + +function build_checks() { + if [[ ! -f $INVOCATION_PATH/.build/libparcel.a ]] then + build_debug + fi + cd checks/ + for check_folder in $(ls) + do + if [[ -f $check_folder ]] then + continue + fi + + cd $check_folder + gcc src/*.c $INVOCATION_PATH/.build/libparcel.a -o check.elf -I $INVOCATION_PATH/code/inc/ + done +} + +function create_archive() { + ar -rvs .build/libparcel.a .build/objects/*.o +} + +function compile_sources() { + + rm -r .build/objects/ + rm .build/libparcel.a + mkdir -p .build/objects + for source_file in $(find "code/src/") + do + if [[ ! -f $source_file ]] then + continue + fi + + # Cut out the prefix (code/src/) + BASENAME=`echo $source_file | cut -c '10-'` + echo "==== COMPILING $source_file ====" + gcc -c $COMPILATION_FLAGS -o .build/objects/$BASENAME.o $source_file $INCLUDE_STATEMENTS + done +} + +function build_debug() { + COMPILATION_FLAGS="-g2 -Wall -Wextra -D__PAC_DEBUG__" + compile_sources + create_archive +} + +function build_release() { + COMPILATION_FLAGS="-O2 -Wall -D__PAC_RELEASE__" + compile_sources + create_archive +} + +function clean() { + rm -R .build/objects/*.o + rm .build/libparcel.a +} + +case $1 in + "clean") + clean + ;; + "debug") + build_debug + ;; + "release") + build_release + ;; + "checks") + build_checks + ;; + *) + echo "Unknown action '$1'. Possible Actions are:" + echo "[ clean | debug | release | checks ]" +esac diff --git a/code/src/main.c b/checks/print-grammar/src/main.c similarity index 100% rename from code/src/main.c rename to checks/print-grammar/src/main.c