-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcompile_all.sh
More file actions
executable file
·53 lines (44 loc) · 1.58 KB
/
Copy pathcompile_all.sh
File metadata and controls
executable file
·53 lines (44 loc) · 1.58 KB
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
#!/bin/bash
# Compile all design pattern files
echo "🚀 Compiling all design pattern files..."
echo "==========================================="
# Create output directory
mkdir -p compiled
# Counter for successful compilations
success_count=0
total_count=0
# Compile each .cpp file
for file in *.cpp; do
if [[ -f "$file" ]]; then
total_count=$((total_count + 1))
basename="${file%.*}"
# Remove spaces and special characters for executable name
exe_name=$(echo "$basename" | sed 's/ /_/g' | sed 's/[^a-zA-Z0-9_]//g')
echo "📦 Compiling: $file"
if g++ -std=c++11 -Wall -Wextra "$file" -o "compiled/$exe_name" 2>/dev/null; then
echo "✅ Success: $file -> compiled/$exe_name"
success_count=$((success_count + 1))
else
echo "❌ Failed: $file"
# Try again with verbose error output
echo " Error details:"
g++ -std=c++11 -Wall -Wextra "$file" -o "compiled/$exe_name"
fi
echo ""
fi
done
echo "==========================================="
echo "🎯 Compilation Summary:"
echo " Total files: $total_count"
echo " Successful: $success_count"
echo " Failed: $((total_count - success_count))"
if [ $success_count -gt 0 ]; then
echo ""
echo "🎉 Compiled executables are in the 'compiled/' directory"
echo "💡 To run a pattern, use: ./compiled/pattern_name"
echo ""
echo "Available executables:"
ls -la compiled/ | grep -v "^d" | awk '{print " " $9}' | grep -v "^ $"
fi
echo ""
echo "✨ Happy coding!"