diff options
| author | littleblack111 <jerrylam110209@gmail.com> | 2023-03-27 21:25:48 +0800 |
|---|---|---|
| committer | littleblack111 <jerrylam110209@gmail.com> | 2023-03-27 21:25:48 +0800 |
| commit | e1e366d8a401ff6cb6906af0e0fa756932c798ec (patch) | |
| tree | b375dcb4f88d436c5ed5c5b66f3aa7433d7d4f8a /compilerun | |
| parent | 6a731444376c853ff8831ab4e0575302049ed27b (diff) | |
added compile script apply for most languages
Diffstat (limited to 'compilerun')
| -rwxr-xr-x | compilerun | 83 |
1 files changed, 83 insertions, 0 deletions
diff --git a/compilerun b/compilerun new file mode 100755 index 0000000..508b838 --- /dev/null +++ b/compilerun @@ -0,0 +1,83 @@ +#!/usr/bin/env bash + +RED='\033[0;31m' +NC='\033[0m' # No Color + +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 + printf "compiled into ${1%.*}.o\n" + printf "\$ ld ${1%.*}.o -o ${1%.*}" + ld ${1%.*}.o -o ${1%.*} + printf "linked into ${1%.*}\n" + printf "compiled into executable ${1%.*}" + printf "Running \"${1%.*}\"\n\n" + ./${1%.*} +elif [[ ${1##*.} == "c" || ${1##*.} == "cc" ]]; then + printf "\$ gcc $1 -o ${1%.*}\n" + gcc $1 -o ${1%.*} + printf "compiled into ${1%.*}\n" + printf "Running \"${1%.*}\"\n\n" + ./${1%.*} +elif [[ ${1##*.} == "cpp" ]]; then + printf "\$ g++ $1 -o ${1%.*}\n" + g++ $1 -o ${1%.*} + printf "compiled into ${1%.*}\n" + printf "Running \"${1%.*}\"\n\n" + ./${1%.*} +elif [[ ${1##*.} == "go" ]]; then + printf "\$ go build $1\n" + go build $1 + printf "compiled" + printf "Running \$ go run $1" + go run $1 +elif [[ ${1##*.} == "cs" ]]; then + printf "\$ csc $1\n" + csc $1 + printf "compiled into ${1%.*}.exe\n" + printf "Running \"${1%.*}\"\n\n" + mono ${1%.*}.exe +elif [[ ${1##*.} == "java" ]]; then + printf "\$ javac $1\n" + javac $1 + printf "compiled into ${1%.*}.class\n" + printf "Running \"${1%.*}\"\n\n" + java ${1%.*} +elif [[ ${1##*.} == "py" ]]; then + printf "\$ pyinstaller -F $1\n" + pyinstaller -F $1 + printf "Running \"./dist/${1%.*}\"" + ./dist/${1%.*} +#elif [[ ${1##*.} == "rb" ]]; then + #printf "\$ ruby -wc $1\n" + #ruby -wc $1 + #printf "compiled into ${1%.*}\n" + #printf "Running ${1%.*}" + #ruby $1 +elif [[ ${1##*.} == "js" ]]; then + printf "\$ node $1\n" + node $1 + printf "Running $1" +elif [[ ${1##*.} == "ts" ]]; then + printf "\$ tsc $1\n" + tsc $1 + printf "compiled into ${1%.*}.js\n" + printf "Running \$ ts-node $1" + ts-node $1 +elif [[ ${1##*.} == "dart" ]]; then + printf "\$ dart compile exe $1\n" + dart compile exe $1 + printf "compiled into ${1%.*}\n" + printf "Running \$ dart $1" + dart $1 +elif [[ ${1##*.} == "rs" ]]; then + printf "\$ rustc $1\n" + rustc $1 + printf "compiled into ${1%.*}\n" + printf "Running \$ ./${1%.*}" +elif [ -e "Makefile" ]; then + make + sudo make install +else + printf "${RED}ERROR: nothing compiled or runed.\n" +fi |
