|
| 1 | +#!/bin/bash |
| 2 | +# Build script that filters output to show only errors and warnings |
| 3 | +# Usage: tools/build.sh [configuration] |
| 4 | +# Configuration defaults to Development |
| 5 | + |
| 6 | +set -o pipefail |
| 7 | + |
| 8 | +CONFIG="${1:-Development}" |
| 9 | +SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)" |
| 10 | +PROJECT_DIR="$(dirname "$SCRIPT_DIR")" |
| 11 | +TMP_DIR="$PROJECT_DIR/tmp" |
| 12 | +LOG_FILE="$TMP_DIR/build.log" |
| 13 | + |
| 14 | +# Create tmp directory if needed |
| 15 | +mkdir -p "$TMP_DIR" |
| 16 | + |
| 17 | +echo "Building $CONFIG configuration..." |
| 18 | +echo "Full log: $LOG_FILE" |
| 19 | + |
| 20 | +# Run the build and capture output |
| 21 | +cd "$PROJECT_DIR" |
| 22 | +make "$CONFIG" > "$LOG_FILE" 2>&1 |
| 23 | +BUILD_STATUS=$? |
| 24 | + |
| 25 | +if [ $BUILD_STATUS -eq 0 ]; then |
| 26 | + echo "Build succeeded." |
| 27 | + exit 0 |
| 28 | +fi |
| 29 | + |
| 30 | +echo "" |
| 31 | +echo "Build failed. Errors and warnings:" |
| 32 | +echo "-----------------------------------" |
| 33 | + |
| 34 | +# Extract errors and warnings, filtering out noise |
| 35 | +# Look for compiler errors/warnings with file:line:column format |
| 36 | +grep -E "^/.*:\d+:\d+: (error|warning):" "$LOG_FILE" | head -50 |
| 37 | + |
| 38 | +# Also check for linker errors |
| 39 | +grep -E "^(ld|clang): error:" "$LOG_FILE" | head -10 |
| 40 | + |
| 41 | +# Check for Swift errors (different format) |
| 42 | +grep -E "error: " "$LOG_FILE" | grep -v "CLANG_WARN\|GCC_TREAT\|export " | head -20 |
| 43 | + |
| 44 | +# Show the failure summary |
| 45 | +echo "" |
| 46 | +echo "-----------------------------------" |
| 47 | +grep -E "\([0-9]+ (error|warning|failure)" "$LOG_FILE" | tail -5 |
| 48 | + |
| 49 | +exit $BUILD_STATUS |
0 commit comments