@@ -244,6 +244,14 @@ function build_sketch { # build_sketch <ide_path> <user_path> <path-to-ino> [ext
244
244
fi
245
245
fi
246
246
247
+ # Install libraries from ci.json if they exist
248
+ install_libs -ai " $ide_path " -s " $sketchdir "
249
+ local install_result=$?
250
+ if [ $install_result -ne 0 ]; then
251
+ echo " ERROR: Library installation failed for $sketchname "
252
+ exit $install_result
253
+ fi
254
+
247
255
ARDUINO_CACHE_DIR=" $HOME /.arduino/cache.tmp"
248
256
if [ -n " $ARDUINO_BUILD_DIR " ]; then
249
257
build_dir=" $ARDUINO_BUILD_DIR "
@@ -558,16 +566,16 @@ function build_sketches { # build_sketches <ide_path> <user_path> <target> <path
558
566
continue
559
567
fi
560
568
echo " "
561
- echo " Building Sketch Index $sketchnum - $sketchdirname "
562
569
563
570
# Install libraries from ci.json if they exist
564
571
install_libs -ai " $ide_path " -s " $sketchdir "
565
572
local install_result=$?
566
573
if [ $install_result -ne 0 ]; then
567
- echo " ERROR: Library installation failed for $sketchdirname "
568
574
return $install_result
569
575
fi
570
576
577
+ echo " Building Sketch Index $sketchnum - $sketchdirname "
578
+
571
579
build_sketch " ${args[@]} " -s " $sketchdir " " ${xtra_opts[@]} "
572
580
local result=$?
573
581
if [ $result -ne 0 ]; then
@@ -611,7 +619,7 @@ function install_libs { # install_libs <ide_path> <sketchdir> [-v]
611
619
* )
612
620
echo " ERROR: Unknown argument: $1 "
613
621
echo " USAGE: install_libs -ai <ide_path> -s <sketchdir> [-v]"
614
- return 1
622
+ exit 1
615
623
;;
616
624
esac
617
625
shift
@@ -621,19 +629,19 @@ function install_libs { # install_libs <ide_path> <sketchdir> [-v]
621
629
if [ -z " $ide_path " ]; then
622
630
echo " ERROR: IDE path not provided"
623
631
echo " USAGE: install_libs -ai <ide_path> -s <sketchdir> [-v]"
624
- return 1
632
+ exit 1
625
633
fi
626
634
627
635
if [ -z " $sketchdir " ]; then
628
636
echo " ERROR: Sketch directory not provided"
629
637
echo " USAGE: install_libs -ai <ide_path> -s <sketchdir> [-v]"
630
- return 1
638
+ exit 1
631
639
fi
632
640
633
641
# Check if arduino-cli exists
634
642
if [ ! -f " $ide_path /arduino-cli" ]; then
635
643
echo " ERROR: arduino-cli not found at $ide_path /arduino-cli"
636
- return 1
644
+ exit 1
637
645
fi
638
646
639
647
# Check if ci.json exists
@@ -649,7 +657,7 @@ function install_libs { # install_libs <ide_path> <sketchdir> [-v]
649
657
return 0
650
658
elif [ " $libs_type " != " array" ]; then
651
659
echo " ERROR: libs field in ci.json must be an array, found: $libs_type "
652
- return 1
660
+ exit 1
653
661
fi
654
662
655
663
libs_count=$( jq -r ' .libs | length' " $sketchdir /ci.json" 2> /dev/null)
@@ -684,6 +692,7 @@ function install_libs { # install_libs <ide_path> <sketchdir> [-v]
684
692
enable_status=$?
685
693
if [ $enable_status -ne 0 ]; then
686
694
echo " WARNING: Failed to enable unsafe installs, some libraries may fail to install"
695
+ exit $enable_status
687
696
fi
688
697
else
689
698
[ " $verbose " = true ] && echo " Unsafe installs already enabled"
@@ -705,9 +714,6 @@ function install_libs { # install_libs <ide_path> <sketchdir> [-v]
705
714
# Capture both stdout and stderr, show only errors
706
715
output=$( " $ide_path /arduino-cli" lib install --git-url " $lib " 2>&1 )
707
716
install_status=$?
708
- if [ $install_status -ne 0 ]; then
709
- echo " $output " | grep -E " Error|WARNING|WARN" || echo " $output "
710
- fi
711
717
fi
712
718
else
713
719
# Library name (with optional version)
@@ -721,6 +727,7 @@ function install_libs { # install_libs <ide_path> <sketchdir> [-v]
721
727
install_status=$?
722
728
if [ $install_status -ne 0 ]; then
723
729
echo " $output " | grep -E " Error|WARNING|WARN" || echo " $output "
730
+ exit $install_status
724
731
fi
725
732
fi
726
733
fi
@@ -732,7 +739,7 @@ function install_libs { # install_libs <ide_path> <sketchdir> [-v]
732
739
[ " $verbose " = true ] && echo " Restoring original unsafe install setting..."
733
740
" $ide_path /arduino-cli" config set library.enable_unsafe_install false > /dev/null 2>&1
734
741
fi
735
- return $install_status
742
+ exit $install_status
736
743
else
737
744
[ " $verbose " = true ] && echo " Successfully installed library: $lib "
738
745
fi
0 commit comments