ps contest setting
This commit is contained in:
Executable
+72
@@ -0,0 +1,72 @@
|
||||
#!/bin/bash
|
||||
# version 1.0
|
||||
|
||||
path="$HOME/.PS"
|
||||
|
||||
path_warning="$path/warning"
|
||||
path_obj="$path/obj"
|
||||
path_objmd5="$path/objmd5"
|
||||
path_output="$path/output.txt"
|
||||
|
||||
mkdir -p $path_warning
|
||||
mkdir -p $path_obj
|
||||
mkdir -p $path_objmd5
|
||||
|
||||
if [ -f "$1.cpp" ] && [ ! -z "$1.cpp" ]; then
|
||||
md5=`md5sum $1.cpp | cut -f1 -d' '`
|
||||
|
||||
name=`basename $1`
|
||||
echo "$1.cpp : File Exist!"
|
||||
echo "md5: $md5"
|
||||
|
||||
if [ -e "$path_objmd5/$md5" ]; then
|
||||
read -p "There's excutable file with same md5. Will you excute this?(Y/n) " yesno
|
||||
|
||||
if [ -z "$yesno" ] || [[ $yesno =~ [yY] ]] || [[ $yesno =~ [yY][eE][sS] ]]; then
|
||||
echo -e "---------------- \"$1.cpp(?)\" Standard Input ----------------"
|
||||
"$path_objmd5/$md5" > $path_output; ret=$?
|
||||
echo -e "\n-------------------- \"$1.cpp(?)\" output --------------------"
|
||||
cat $path_output
|
||||
echo -e "\n----------------------- \"$1.cpp(?)\" ------------------------"
|
||||
|
||||
exit 0
|
||||
fi
|
||||
fi
|
||||
|
||||
copt="g++ $1.cpp -o $path_obj/$1 -O2 -lm -Wall -static -std=c++2a -DDEBUG -Wno-unused-result"
|
||||
|
||||
echo "Now Compiling..."
|
||||
|
||||
echo "## Name of Source File : $1.cpp" > "$path_warning/$1"
|
||||
echo "## MD5 of Source File : $md5" >> "$path_warning/$1"
|
||||
echo "## Compile command : $copt" >> "$path_warning/$1"
|
||||
ctime=`date +%y%m%d%H%M%S`; echo "## Compile start time : $ctime" >> "$path_warning/$1"
|
||||
|
||||
`$copt 2> $path/latest`; res=$?
|
||||
echo -e "## Compile end time : $(date +%y%m%d%H%M%S)\n" >> "$path_warning/$1"
|
||||
cat "$path/latest" >> "$path_warning/$1"
|
||||
|
||||
echo "Compile Finished!"
|
||||
|
||||
cat "$path_warning/$1"
|
||||
|
||||
if [ $res -eq 0 ]; then
|
||||
cp "$path_obj/$1" "$path_objmd5/$md5"
|
||||
|
||||
echo -e "---------------- \"$1.cpp\" Standard Input ----------------"
|
||||
"$path_obj/$1" > $path_output; ret=$?
|
||||
echo -e "\n-------------------- \"$1.cpp\" output --------------------"
|
||||
cat $path_output
|
||||
echo -e "\n----------------------- \"$1.cpp\" ------------------------"
|
||||
echo -e "\nProgram returned with $ret"
|
||||
echo -e "Excutable File : $path_obj/$1\n"
|
||||
else
|
||||
echo "Compile Failed!"
|
||||
fi
|
||||
elif [ -z "$1" ]; then
|
||||
echo "No string is given!"
|
||||
else
|
||||
echo "There's no such file!"
|
||||
fi
|
||||
|
||||
exit 0
|
||||
Reference in New Issue
Block a user