hdl: parallel build terminates and cleans up if exit or failure occures
This commit is contained in:
parent
a4bc3575e4
commit
eece62f0c2
1 changed files with 31 additions and 5 deletions
|
|
@ -3,6 +3,23 @@
|
|||
# Build a bladeRF fpga image
|
||||
################################################################################
|
||||
|
||||
cleanup() {
|
||||
# Prevent recursive cleanup calls
|
||||
trap '' INT TERM HUP
|
||||
|
||||
echo "Cleaning up and terminating builds..."
|
||||
if [ -n "${build_pids[*]}" ]; then
|
||||
for pid in "${build_pids[@]}"; do
|
||||
pkill -P $pid 2>/dev/null || true
|
||||
done
|
||||
fi
|
||||
|
||||
exit 1
|
||||
}
|
||||
|
||||
# Set up trap to catch Ctrl+C and other termination signals
|
||||
trap cleanup INT TERM HUP
|
||||
|
||||
function print_boards() {
|
||||
echo "Supported boards:"
|
||||
for i in ../fpga/platforms/*/build/platform.conf ; do
|
||||
|
|
@ -192,22 +209,31 @@ if [ "$build_hosted" == "1" ]; then
|
|||
mkdir -p build_logs
|
||||
build_pids=()
|
||||
|
||||
echo "Starting parallel builds for all hosted configurations..."
|
||||
for config in "bladeRF 40" "bladeRF 115" "bladeRF-micro A4" "bladeRF-micro A5" "bladeRF-micro A9"; do
|
||||
read -r board size <<< "$config"
|
||||
echo "Starting build for $board hosted $size..."
|
||||
$0 -b "$board" -r hosted -s "$size" > "build_logs/$board-hosted-$size.log" 2>&1 &
|
||||
log_file="build_logs/$board-hosted-$size.log"
|
||||
$0 -b "$board" -r hosted -s "$size" > "$log_file" 2>&1 &
|
||||
build_pids+=($!)
|
||||
echo " → $board $size (PID: ${build_pids[-1]})"
|
||||
done
|
||||
|
||||
echo "Waiting for ${#build_pids[@]} hosted builds to complete..."
|
||||
echo "Waiting for ${#build_pids[@]} builds to complete..."
|
||||
|
||||
# Monitor build processes
|
||||
failed=0
|
||||
for pid in "${build_pids[@]}"; do
|
||||
if ! wait "$pid"; then
|
||||
echo "Build failed. Check build_logs directory for details."
|
||||
exit 1
|
||||
failed=1
|
||||
fi
|
||||
done
|
||||
|
||||
if [ "$failed" -ne 0 ]; then
|
||||
echo "One or more builds failed. Check build_logs directory for details."
|
||||
cleanup
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "All hosted builds completed successfully!"
|
||||
exit 0
|
||||
fi
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue