100 lines
3.0 KiB
Bash
Executable File
100 lines
3.0 KiB
Bash
Executable File
#!/bin/bash
|
|
# build source code and run
|
|
|
|
Term=urxvt
|
|
|
|
RelSrcName=${1##[^ ]*/}
|
|
|
|
# C++ make and run
|
|
if [ "`expr match "$1" ".*\(.[Cc][Pp][Pp]$\)"`" != "" ]; then
|
|
RelProgName=${RelSrcName%.[Cc][Pp][Pp]}
|
|
if [ "`echo $1| grep /`" != "" ]; then
|
|
DirName=${1%/*.[Cc][Pp][Pp]}
|
|
cd "$DirName"
|
|
fi
|
|
rm -f "$RelProgName"
|
|
g++ "$RelSrcName" -o "$RelProgName" -lglut
|
|
echo ---------------- C++ -------------------------
|
|
#"./$RelProgName"
|
|
$Term -e sh -c "./$RelProgName;read"
|
|
echo ----------------------------------------------
|
|
rm -f "$RelProgName"
|
|
|
|
# C make and run
|
|
elif [ "`expr match "$1" ".*\(.[Cc]$\)"`" != "" ]; then
|
|
RelProgName=${RelSrcName%.[Cc]}
|
|
if [ "`echo $1| grep /`" != "" ]; then
|
|
DirName=${1%/*.[Cc]}
|
|
cd "$DirName"
|
|
fi
|
|
rm -f "$RelProgName"
|
|
gcc "$RelSrcName" -o "$RelProgName" -lglut
|
|
echo ------------------ C -------------------------
|
|
$Term -e sh -c "./$RelProgName;read"
|
|
echo ----------------------------------------------
|
|
rm -f "$RelProgName"
|
|
|
|
# Java make and run
|
|
elif [ "`expr match "$1" ".*\(.[Jj][Aa][Vv][Aa]$\)"`" != "" ]; then
|
|
RelProgName=${RelSrcName%.[Jj][Aa][Vv][Aa]}
|
|
if [ "`echo $1| grep /`" != "" ]; then
|
|
DirName=${1%/*.[Jj][Aa][Vv][Aa]}
|
|
cd "$DirName"
|
|
fi
|
|
rm -f "$RelProgName"
|
|
javac "$RelSrcName" >/dev/null
|
|
echo ---------------- Java ------------------------
|
|
$Term -e sh -c "java ./$RelProgName;read"
|
|
echo ----------------------------------------------
|
|
rm -f "$RelProgName"
|
|
|
|
# Free Pascal make and run
|
|
elif [ "`expr match "$1" ".*\(.[Pp][Aa][Ss]$\)"`" != "" ]; then
|
|
RelProgName=${RelSrcName%.[Pp][Aa][Ss]}
|
|
if [ "`echo $1| grep /`" != "" ]; then
|
|
DirName=${1%/*.[Pp][Aa][Ss]}
|
|
cd "$DirName"
|
|
fi
|
|
rm -f "$RelProgName"
|
|
fpc "$RelSrcName"
|
|
echo ------------ Free Pascal ---------------------
|
|
$Term -e sh -c "./$RelProgName;read"
|
|
echo ----------------------------------------------
|
|
rm -f "$RelProgName.o"
|
|
rm -f "$RelProgName"
|
|
|
|
# Python
|
|
elif [ "`expr match "$1" ".*\(.[Pp][Yy]$\)"`" != "" ];
|
|
then
|
|
echo --------------- Python -----------------------
|
|
/usr/bin/python "$1"
|
|
echo ----------------------------------------------
|
|
|
|
# Perl
|
|
elif [ "`expr match "$1" '.*\(.[Pp][Ll]$\)'`" != "" ];
|
|
then
|
|
echo ---------------- Perl ------------------------
|
|
$Term -e sh -c "perl "$1";read"
|
|
echo ----------------------------------------------
|
|
|
|
# Simple Bash script
|
|
elif [ "`expr match "$1" '.*\(.sh$\)'`" != "" ];
|
|
then
|
|
echo --------------- Bash Script ------------------
|
|
$Term -e sh -c "bash "$1";read"
|
|
echo ----------------------------------------------
|
|
|
|
# CUDA/CUBLAS project
|
|
else
|
|
echo --------- CUDA/CUBLAS project ----------------
|
|
if [ "`echo $1| grep /`" != "" ]; then
|
|
DirName=${1%/*.[Cc][Uu]}
|
|
cd "$DirName"
|
|
fi
|
|
make
|
|
# RelProgName=${RelSrcName%.cu}
|
|
RelProgName=`grep EXECUTABLE Makefile | cut -f2 | cut -d " " -f2`
|
|
$Term -e sh -c "~/NVIDIA_CUDA_SDK/bin/linux/release/$RelProgName"
|
|
echo ----------------------------------------------
|
|
fi
|