From 24bcdf9dd884749971592429a8d8192f80818263 Mon Sep 17 00:00:00 2001 From: julian Date: Fri, 15 Mar 2024 20:16:26 +0100 Subject: [PATCH] update compile.sh to use relative paths --- compile.sh | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/compile.sh b/compile.sh index 1770f747..1fe9a93e 100755 --- a/compile.sh +++ b/compile.sh @@ -1,9 +1,9 @@ #!/bin/bash -SRCDIR="/home/julian/Dokumente/Programming/Java/Studienarbeit/JavaTXCompilerInJavaTX/javatx-src/main/java" -DESTDIR="/home/julian/Dokumente/Programming/Java/Studienarbeit/JavaTXCompilerInJavaTX/out" +SRCDIR="javatx-src/main/java" +DESTDIR="out" JAVAC_FLAGS="-g:none -nowarn" -JAVATX_COMPILER_PATH="/home/julian/Dokumente/Programming/Java/Studienarbeit/JavaTXCompilerInJavaTX/JavaTXcompiler-1.1-jar-with-dependencies.jar" +JAVATX_COMPILER_PATH="JavaTXcompiler-1.1-jar-with-dependencies.jar" #remove all files, if the script is called with parameter "clear" if [ "$1" = "clear" ]; then @@ -11,7 +11,7 @@ if [ "$1" = "clear" ]; then exit 0 fi -#find all .java/.jav files recursively and store them i an array +#find all .java/.jav files recursively and store them in an array JAVA_FILES=($(find "$SRCDIR" -name "*.java")) JAV_FILES=($(find "$SRCDIR" -name "*.jav")) @@ -26,8 +26,11 @@ mkdir -p $DESTDIR #fill class files arrays by subsituting .java/.jav -> .class for each file for file in "${JAVA_FILES[@]}"; do + #substitute destination dir with source dir class_name="$DESTDIR${file#$SRCDIR}" + #substitute *.java -> *.class class_name="${class_name%.java}.class" + #if .class file does not exists or .class file older than .java file if [ ! -f "$class_name" ] || [ "$(stat -c "%Y" "$file")" -gt "$(stat -c "%Y" "$class_name")" ]; then JAVA_CHANGED+=("$file") JAVA_CLASSES+=("$class_name") @@ -36,8 +39,11 @@ done for file in "${JAV_FILES[@]}"; do + #substitute destination dir with source dir class_name="$DESTDIR${file#$SRCDIR}" + #substitute *.jav -> *.class class_name="${class_name%.jav}.class" + #if .class file does not exists or .class file older than .jav file if [ ! -f "$class_name" ] || [ "$(stat -c "%Y" "$file")" -gt "$(stat -c "%Y" "$class_name")" ]; then JAV_CHANGED+=("$file") JAV_CLASSES+=("$class_name") @@ -47,12 +53,12 @@ done if [ "${#JAV_CHANGED[@]}" -ne 0 ]; then for ((i = 0; i < "${#JAV_CHANGED[@]}"; i++)); do - java -jar $JAVATX_COMPILER_PATH -d "${JAV_CLASSES[i]%/*}" -cp "$SRCDIR:$DESTDIR:target/dependencies/" ${JAV_CHANGED[i]} + java -jar $JAVATX_COMPILER_PATH -d "${JAV_CLASSES[i]%/*}" -cp "$SRCDIR:$DESTDIR:target/dependencies/" "${JAV_CHANGED[i]}" done fi if [ "${#JAVA_CHANGED[@]}" -ne 0 ]; then - javac -d $DESTDIR -cp "$SRCDIR:$DESTDIR:target/dependencies/*" $JFLAGS ${JAVA_CHANGED[@]} + javac -d $DESTDIR -cp "$SRCDIR:$DESTDIR:target/dependencies/*" $JFLAGS "${JAVA_CHANGED[@]}" fi