Add compile script

This commit is contained in:
ItsDrike 2021-08-16 03:18:07 +02:00
parent bfebb33b29
commit 49b1fb917e
No known key found for this signature in database
GPG key ID: B5F6B41F708C3ADD

13
home/.local/bin/scripts/comp Executable file
View file

@ -0,0 +1,13 @@
#!/bin/sh
# Compile given file
file=$(readlink -f "$1")
base="$(dirname "$file")/$(basename "$file" | sed 's/\..*//')"
case "$file" in
*.md) pandoc --filter pandoc-crossref "$file" -o "$base".pdf ;;
*.asm) nasm -f elf64 "$file" -o "$base".o && ld "$base".o -o "$base" ;;
*.c) gcc "$file" -o "$base" ;;
*.cpp) g++ "$file" -o "$base" ;;
*) echo "Can't compile!" && exit 1 ;;
esac