From 26fabd91b9bf17874a4938bbb1726c6588e9fe8e Mon Sep 17 00:00:00 2001 From: Abdelrahman Date: Tue, 25 Jul 2023 09:00:11 +0100 Subject: [PATCH] Ensure build scripts fail if attempting to run them from different directory --- compile | 29 ++++++++++++++--------------- 1 file changed, 14 insertions(+), 15 deletions(-) diff --git a/compile b/compile index 5230824..0e7f09f 100755 --- a/compile +++ b/compile @@ -1,29 +1,28 @@ #!/bin/bash -SCRIPT_DIR="$(dirname $0)" CC=clang -CFLAGS="-g -Wall -Werror -pedantic -I$SCRIPT_DIR/include" -SRC="$SCRIPT_DIR/src/main.c" -OUT=$SCRIPT_DIR/main +CFLAGS="-g -Wall -Werror -pedantic -I./include" +SRC="./src/main.c" +OUT=./main # STATE_TABLE -$CC $CFLAGS -I$SCRIPT_DIR/include/lexer $SCRIPT_DIR/generate_state_table.c -o $SCRIPT_DIR/gentable -$SCRIPT_DIR/gentable +(set -x;$CC $CFLAGS -I./include/lexer ./generate_state_table.c -o ./gentable) +./gentable # DSTRING -CFLAGS+=" -I$SCRIPT_DIR/include/dstring" -SRC+=" $SCRIPT_DIR/src/dstring/*.c" +CFLAGS+=" -I./include/dstring" +SRC+=" ./src/dstring/*.c" # JSON_ENTITIES -CFLAGS+=" -I$SCRIPT_DIR/include/json_entities" -SRC+=" $SCRIPT_DIR/src/json_entities/*.c" +CFLAGS+=" -I./include/json_entities" +SRC+=" ./src/json_entities/*.c" # LEXER -CFLAGS+=" -I$SCRIPT_DIR/include/lexer" -SRC+=" $SCRIPT_DIR/src/lexer/*.c" +CFLAGS+=" -I./include/lexer" +SRC+=" ./src/lexer/*.c" # PARSER -CFLAGS+=" -I$SCRIPT_DIR/include/parser" -SRC+=" $SCRIPT_DIR/src/parser/*.c" +CFLAGS+=" -I./include/parser" +SRC+=" ./src/parser/*.c" -$CC $CFLAGS $SRC -o $OUT +(set -x;$CC $CFLAGS $SRC -o $OUT)