diff options
| author | littleblack111 <littleblack11111@gmail.com> | 2023-07-22 10:38:04 +0800 |
|---|---|---|
| committer | littleblack111 <littleblack11111@gmail.com> | 2023-07-22 10:38:04 +0800 |
| commit | 9f23df11c0cb686b31d75aa02dc234d755c796a1 (patch) | |
| tree | 1978813b1d01cdf69f99a3312c6df832c065f6e3 /compile | |
| parent | baf65e6e3fea72d3225323b37ab1a4447c8a6a1c (diff) | |
initmain
Diffstat (limited to 'compile')
| -rwxr-xr-x | compile | 91 |
1 files changed, 91 insertions, 0 deletions
@@ -0,0 +1,91 @@ +#!/usr/bin/env bash + +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 || 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%.*}" || 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%.*} || 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%.*} || 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" + go build $1 + printf "compiled into ${1%.*}\n" +elif [[ ${1##*.} == "cs" ]]; then + printf "\$ csc $1\n" + csc $1 + printf "compiled into ${1%.*}.exe\n" +elif [[ ${1##*.} == "java" ]]; then + printf "\$ javac $1\n" + javac $1 + printf "compiled into ${1%.*}.class\n" +elif [[ ${1##*.} == "py" ]]; then + printf "\$ pyinstaller -F $1\n" + #python -m py_compile $1 + pyinstaller -F $1 + printf "compiled into dist/${1%.*}\n" +elif [[ ${1##*.} == "rb" ]]; then + printf "\$ ruby -wc $1\n" + ruby -wc $1 + printf "compiled into ${1%.*}\n" +elif [[ ${1##*.} == "js" ]]; then + printf "\$ node $1\n" + node $1 + printf "compiled into ${1%.*}\n" +elif [[ ${1##*.} == "ts" ]]; then + printf "\$ tsc $1\n" + tsc $1 + printf "compiled into ${1%.*}.js\n" +elif [[ ${1##*.} == "dart" ]]; then + printf "\$ dart compile exe $1\n" + dart compile exe $1 + printf "compiled into ${1%.*}\n" +elif [[ ${1##*.} == "rs" ]]; then + printf "\$ rustc $1\n" + rustc $1 + printf "compiled into ${1%.*}\n" +elif [ -e "Makefile" ]; then + make + sudo make install +else + printf "${RED}ERROR: nothing compiled.\n" +fi |
