feat: Add build & error diagnostics tools#235
Conversation
## Description Implement build error diagnostics and enhanced compiler output for better debugging and development experience. ## Part of - Original PR: #233 - Phase: 2 of 5 ## Changes - Add build-error-diagnostics.sh for enhanced error reporting - Add xcode-build-wrapper.sh for compiler output enhancement - Add ci-validation.sh for CI configuration validation - Add build-parallel.sh for parallel module building - Update Makefile with diagnostic flags and error filtering ## Testing - Build diagnostics will be tested when running 'make build' - Error filtering improves developer experience - Parallel builds improve performance ## Dependencies - Depends on: PR #234 (CI core infrastructure)
There was a problem hiding this comment.
Pull Request Overview
This PR implements build error diagnostics and enhanced compiler output tools for better debugging and development experience. It introduces sophisticated error reporting, module-aware diagnostics, and build enhancement scripts.
- Add comprehensive build error diagnostics with module-aware error formatting and recovery suggestions
- Implement Xcode build wrapper for enhanced compiler output with visual indicators and contextual hints
- Create CI validation script for GitHub workflows, tool availability, and basic security checks
Reviewed Changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
| scripts/build-error-diagnostics.sh | Comprehensive error diagnostics with module detection, pattern matching, and recovery suggestions |
| scripts/xcode-build-wrapper.sh | Xcode compiler wrapper with enhanced error messages and module-specific hints |
| scripts/ci-validation.sh | CI configuration validation with tool checks and basic security scanning |
| Makefile | Enhanced build target with diagnostic flags and error filtering pipeline |
Comments suppressed due to low confidence (2)
scripts/build-error-diagnostics.sh:118
- Similar to the password check, this API key detection pattern may produce false positives. Consider checking for actual string values rather than just the pattern, and exclude configuration files or known safe contexts.
echo "${file}:${line}:${column}: ${NOTE_PREFIX} • Foundation → (no external dependencies)"
| TOTAL_WARNINGS=0 | ||
|
|
||
| # Track error for reporting | ||
| track_error() { |
There was a problem hiding this comment.
The function uses bash arithmetic operations on potentially uninitialized associative array elements. This will fail when the module key doesn't exist yet. Initialize array elements to 0 before incrementing: ERROR_COUNTS[$module]=${ERROR_COUNTS[$module]:-0}; ((ERROR_COUNTS[$module]++))
| "$COMPILER" "$@" 2>&1 | tee "$TEMP_OUTPUT" | while IFS= read -r line; do | ||
| enhance_error "$line" | ||
| done | ||
|
|
||
| # Get the compiler exit code | ||
| COMPILER_EXIT_CODE=${PIPESTATUS[0]} | ||
|
|
There was a problem hiding this comment.
PIPESTATUS may not contain the expected compiler exit code due to the pipeline structure. The exit code captured here could be from tee or the while loop instead of the actual compiler. Consider restructuring to capture the compiler exit code more reliably, such as running the compiler separately and then processing its output.
| "$COMPILER" "$@" 2>&1 | tee "$TEMP_OUTPUT" | while IFS= read -r line; do | |
| enhance_error "$line" | |
| done | |
| # Get the compiler exit code | |
| COMPILER_EXIT_CODE=${PIPESTATUS[0]} | |
| "$COMPILER" "$@" > "$TEMP_OUTPUT" 2>&1 | |
| COMPILER_EXIT_CODE=$? | |
| # Process the compiler output | |
| while IFS= read -r line; do | |
| enhance_error "$line" | |
| done < "$TEMP_OUTPUT" |
| echo "✅ Unit Tests target found" | ||
| else | ||
| echo "⚠️ Unit Tests target not found" |
There was a problem hiding this comment.
The script checks for 'UIScreenshots' as a unit test target, but this appears to be incorrect. UIScreenshots sounds like a UI testing target, not a unit test target. This will give misleading validation results about test coverage.
| echo "✅ Unit Tests target found" | |
| else | |
| echo "⚠️ Unit Tests target not found" | |
| echo "✅ UI Screenshots target found" | |
| else | |
| echo "⚠️ UI Screenshots target not found" |
| $(if $(filter Debug,$(CONFIGURATION)),$(DEBUG_FLAGS),) \ | ||
| CODE_SIGNING_ALLOWED=NO \ | ||
| | $(XCPRETTY) | ||
| 2>&1 | ./scripts/build-error-diagnostics.sh filter | $(XCPRETTY) |
There was a problem hiding this comment.
The pipeline redirects stderr to stdout and then processes it through the diagnostics script, but this may interfere with xcpretty's ability to properly format and colorize the output. Consider whether xcpretty should come before or after the diagnostics script, or if both stdout and stderr need separate handling.
| 2>&1 | ./scripts/build-error-diagnostics.sh filter | $(XCPRETTY) | |
| 1> >(./scripts/build-error-diagnostics.sh filter) 2> >(tee /dev/stderr) | $(XCPRETTY) |
Description
Implement build error diagnostics and enhanced compiler output for better debugging and development experience.
Part of
Changes
Testing
Dependencies
Files Changed
Next Steps
After this PR is merged, subsequent PRs will add: