-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild_cpp.sh
executable file
·110 lines (108 loc) · 2.1 KB
/
build_cpp.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
#!/usr/bin/env bash
# Colors
GREEN="\033[1;32m"
NC="\033[0m"
YELLOW="\033[1;33m"
MAGENTA="\033[1;35m"
RED="\033[0;31m"
echo "Clearing Object Files and Executable Files"
rm -r "*.exe" "*.o" "*.out"
echo "Done!"
sleep .5
clear
echo -e "${GREEN}" "Available Files -${NC}"
for f in *.cpp; do echo "$f"; done
echo ""
echo -e "Enter File Name -- ${YELLOW}Without '.cpp' Extension${NC}"
read -r fname
if [[ -f ${fname}.cpp ]]; then
echo ""
echo "What do you want to compile '${fname}.cpp' with?"
echo "Clang++ or G++"
echo "Enter '1' for Clang++ and '2' for G++"
read -r temp
COMPILED_PROGRAM=a.out
if [[ ${temp} = "1" ]]; then
clear
echo "Compiling '$fname.cpp' with Clang++"
clang++ "$fname.cpp"
if [[ -f ${COMPILED_PROGRAM} ]]; then
echo ""
echo "Build With Clang++ without any errors"
sleep .5
clear
else
echo ""
echo -e "${RED}" "Check the Program Please"
sleep 5
clear
exit
fi
else
if [[ ${temp} = "2" ]]; then
clear
echo "Compiling '${fname}.cpp' with G++"
g++ "${fname}.cpp"
if [[ -f ${COMPILED_PROGRAM} ]]; then
echo ""
echo "Build With G++ without any errors"
sleep .5
clear
else
echo ""
echo -e "${RED}" "Check the Program Please"
sleep 5
clear
exit
fi
else
if [ "${temp}" != "1" ] && [ "${temp}" != "2" ]; then
echo -e "${RED}Wrong Compiler${NC}"
echo "Exiting!"
sleep 1
clear
exit
fi
fi
fi
else
echo ""
echo -e "${RED}File Does not Exist!${NC}"
echo "Exiting..."
echo -e "${MAGENTA}K Thanks, Bye!${NC}"
sleep 1
clear
exit
fi
echo "Running Compiled Program Now"
sleep 1
clear
./a.out
echo ""
echo -e "${YELLOW}Show Source Code?${NC}"
echo ""
echo "'y' for yes and anything else for no"
read -r temp
if [[ ${temp} = "y" ]]; then
clear
echo -e "${YELLOW}///// Source Code for '${fname}.cpp' /////${NC}"
echo ""
cat "${fname}.cpp"
sleep 5
echo ""
echo "Press 'y' to Exit"
read -r temp
if [[ ${temp} = "y" ]]; then
clear
sleep 1
echo -e "${MAGENTA}K Thanks, Bye!${NC}"
exit
fi
else
if [[ ${temp} != "y" ]]; then
clear
echo -e "${MAGENTA}K Thanks, Bye!${NC}"
sleep 1
exit
fi
fi