summaryrefslogtreecommitdiff
path: root/compile
diff options
context:
space:
mode:
Diffstat (limited to 'compile')
-rwxr-xr-xcompile35
1 files changed, 31 insertions, 4 deletions
diff --git a/compile b/compile
index 3c78508..fa2b74a 100755
--- a/compile
+++ b/compile
@@ -3,21 +3,48 @@
RED='\033[0;31m\033[1m'
NC='\033[0m' # No Color
+function iferrorcomp () {
+ if [[ error -eq 1 ]]; then
+ printf "$RED\nCrit: ERROR had occured during compile!!\n"
+ fi
+}
+
+if [[ ! -f $1 || ! $1 && ! -f Makefile ]]; then
+ printf "$RED No file/arguments given.\n"
+ exit 1
+fi
+
if [[ ${1##*.} == "asm" ]]; then
printf "\$ nasm -f elf64 -g -F dwarf $1 -l ${1%.*}.lst -o ${1%.*}.o\n"
- nasm -f elf64 -g -F dwarf $1 -l ${1%.*}.lst -o ${1%.*}.o
+ nasm -f elf64 -g -F dwarf $1 -l ${1%.*}.lst -o ${1%.*}.o || error=1
+ if [[ error -eq 1 ]]; then
+ printf "\n\$ nasm -f elf64 -g -F dwarf $1 -; ${1%.*}.lst -o ${1%.*}.o: $RED\error had occured\n"
+ exit 1
+ fi
printf "compiled into ${1%.*}.o\n"
- printf "\$ ld ${1%.*}.o -o ${1%.*}"
+ printf "\$ ld ${1%.*}.o -o ${1%.*}" || error=1
+ if [[ error -eq 1 ]]; then
+ printf "\n\$ ld ${1%.*}.o -o ${1%.*}" || error=1
+ exit 1
+ fi
ld ${1%.*}.o -o ${1%.*}
printf "linked into ${1%.*}\n"
printf "compiled into executable"
elif [[ ${1##*.} == "c" || ${1##*.} == "cc" ]]; then
printf "\$ gcc $1 -o ${1%.*}\n"
- gcc $1 -o ${1%.*}
+ gcc $1 -o ${1%.*} || error=1
+ if [[ error -eq 1 ]]; then
+ printf "\n\$ gcc $1 -o ${1%.*}: $RED\error had occured\n"
+ exit 1
+ fi
printf "compiled into ${1%.*}\n"
elif [[ ${1##*.} == "cpp" ]]; then
printf "\$ g++ $1 -o ${1%.*}\n"
- g++ $1 -o ${1%.*}
+ g++ $1 -o ${1%.*} || error=1
+ if [[ error -eq 1 ]]; then
+ printf "\n\$ g++ $1 -o ${1%.*}: $RED\error had occured\n"
+ exit 1
+ fi
printf "compiled into ${1%.*}\n"
elif [[ ${1##*.} == "go" ]]; then
printf "\$ go build $1\n"