Created
July 30, 2011 15:07
-
-
Save rumkin/1115616 to your computer and use it in GitHub Desktop.
G++ compiling
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Exception :) | |
function error { | |
echo "Error: "$1 | |
exit | |
} | |
#read param | |
fname=$1; | |
if [ ${#fname} -eq 0 ]; | |
then | |
echo -e "Message: Filename not set\nEnter filename:" | |
read fname | |
fi | |
#check for param #1 | |
if [ ${#fname} -eq 0 ]; | |
then | |
error "filename is empty" | |
fi | |
# check source for existance | |
if [ ! -r ./$fname.cpp ]; | |
then | |
error "file is not found or unreadable" | |
fi | |
# delete old binary | |
# TODO(deside): rename old binary for bac up | |
if [ -f ./$fname ]; | |
then | |
rm ./$fname | |
fi | |
params=$2 | |
# detect gcc params | |
if [ ${#params} -eq 0 ]; | |
then | |
params="-Wall -W -Werror" | |
fi | |
g++ $params $fname.cpp -o $fname | |
# Show binnary output | |
echo | |
echo "------------------------------------------------" | |
echo | |
./$fname | |
echo | |
echo "------------------------------------------------" | |
echo | |
echo |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment