Skip to content

Commit f2fed05

Browse files
miduggan24Copilot
andauthored
NOJIRA: Update build.sh to handle pids correctly (SiliconLabsSoftware#175)
* update build.sh to handle pids arguments correctly * fix bootloader makefile detection * Apply suggestions from code review Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * resolve copilot comment --------- Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
1 parent 7b93a3a commit f2fed05

1 file changed

Lines changed: 63 additions & 10 deletions

File tree

slc/build.sh

Lines changed: 63 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,15 @@
4848
# ./slc/build.sh slc/solutions/thermostat/series-2/thermostat-917-ncp-bootloader.slcw brd4187c --without_bootloader '<component1>,<component2>'
4949
# output in: out/brd4187c/thermostat-917-ncp-solution/
5050
#
51+
# -pids option : Allows to build only specific parts of a solution (.slcw) project. If provided for .slcp file, silently ignored.
52+
# Valid arguments: 'bootloader' or 'application'
53+
# Example bootloader-only build:
54+
# ./slc/build.sh slc/apps/lighting-app/thread/lighting-app-series-2.slcw brd4187c -pids bootloader
55+
# output in: out/brd4187c/lighting-app-solution/ (builds only bootloader)
56+
# Example application-only build:
57+
# ./slc/build.sh slc/apps/lighting-app/thread/lighting-app-series-2.slcw brd4187c -pids application
58+
# output in: out/brd4187c/lighting-app-solution/ (builds only application)
59+
#
5160

5261
# Helper functions to build component arguments
5362
build_with_arg() {
@@ -162,6 +171,9 @@ WITH_APP_COMPONENTS=""
162171
WITHOUT_APP_COMPONENTS=""
163172
WITH_BOOTLOADER_COMPONENTS=""
164173
WITHOUT_BOOTLOADER_COMPONENTS=""
174+
PIDS_ARG=""
175+
GENERATE_BOOTLOADER=true
176+
GENERATE_APPLICATION=true
165177
while [ $# -gt 0 ]; do
166178
case "$1" in
167179
--clean)
@@ -221,6 +233,20 @@ while [ $# -gt 0 ]; do
221233
shift
222234
;;
223235

236+
-pids)
237+
PIDS_ARG="$2"
238+
if [ "$PIDS_ARG" = "bootloader" ]; then
239+
GENERATE_APPLICATION=false
240+
elif [ "$PIDS_ARG" = "application" ]; then
241+
GENERATE_BOOTLOADER=false
242+
else
243+
echo "ERROR: Invalid -pids argument: $PIDS_ARG. Must be 'bootloader' or 'application'"
244+
exit 1
245+
fi
246+
shift
247+
shift
248+
;;
249+
224250
*)
225251
CONFIG_ARGS+="$1 "
226252
shift
@@ -285,7 +311,7 @@ fi
285311

286312
if [ "$skip_gen" = false ]; then
287313
if [[ "$SILABS_APP_PATH" == *.slcw ]]; then
288-
if [[ "$SILABS_APP_PATH" != *-siwx* ]]; then
314+
if [[ "$SILABS_APP_PATH" != *-siwx* ]] && [ "$GENERATE_BOOTLOADER" = true ]; then
289315
# Get bootloader arguments
290316
BOOTLOADER_WITH_ARG=$(build_with_arg "$SILABS_BOARD" "$WITH_BOOTLOADER_COMPONENTS")
291317
BOOTLOADER_WITHOUT_ARG=$(build_without_arg "$WITHOUT_BOOTLOADER_COMPONENTS")
@@ -299,15 +325,17 @@ if [ "$skip_gen" = false ]; then
299325
fi
300326
fi
301327

302-
# Get application args
303-
APP_WITH_ARG=$(build_with_arg "$SILABS_BOARD" "$WITH_APP_COMPONENTS")
304-
APP_WITHOUT_ARG=$(build_without_arg "$WITHOUT_APP_COMPONENTS")
328+
if [ "$GENERATE_APPLICATION" = true ]; then
329+
# Get application args
330+
APP_WITH_ARG=$(build_with_arg "$SILABS_BOARD" "$WITH_APP_COMPONENTS")
331+
APP_WITHOUT_ARG=$(build_without_arg "$WITHOUT_APP_COMPONENTS")
305332

306-
echo "Generating application..."
307-
run_slc_generate_with_retry generate --tt -s $GSDK_ROOT --daemon -d $OUTPUT_DIR $PROJECT_FLAG $SILABS_APP_PATH $APP_WITH_ARG $APP_WITHOUT_ARG -pids application $CONFIG_ARGS --generator-timeout=3500
308-
if [ $? -ne 0 ]; then
309-
echo "FAILED TO Generate application for: $SILABS_APP_PATH"
310-
exit 1
333+
echo "Generating application..."
334+
run_slc_generate_with_retry generate --tt -s $GSDK_ROOT --daemon -d $OUTPUT_DIR $PROJECT_FLAG $SILABS_APP_PATH $APP_WITH_ARG $APP_WITHOUT_ARG -pids application $CONFIG_ARGS --generator-timeout=3500
335+
if [ $? -ne 0 ]; then
336+
echo "FAILED TO Generate application for: $SILABS_APP_PATH"
337+
exit 1
338+
fi
311339
fi
312340
else
313341
# Generate .slcp projects
@@ -319,4 +347,29 @@ if [ "$skip_gen" = false ]; then
319347
fi
320348
fi
321349

322-
make all -C $OUTPUT_DIR -f $MAKE_FILE -j13
350+
if [ "$GENERATE_BOOTLOADER" = true ] && [ "$GENERATE_APPLICATION" = false ]; then
351+
# Use bootloader makefile instead of solution makefile
352+
echo "Building bootloader only..."
353+
# Find the bootloader makefile
354+
BOOTLOADER_MAKEFILE=$(find $OUTPUT_DIR/matter-bootloader -maxdepth 1 -name "*.Makefile" | head -1)
355+
if [ -z "$BOOTLOADER_MAKEFILE" ]; then
356+
echo "Error: No bootloader Makefile found in $OUTPUT_DIR/matter-bootloader"
357+
exit 1
358+
fi
359+
BOOTLOADER_MAKEFILE_NAME=$(basename "$BOOTLOADER_MAKEFILE")
360+
make all -C $OUTPUT_DIR/matter-bootloader -f $BOOTLOADER_MAKEFILE_NAME -j13
361+
elif [ "$GENERATE_BOOTLOADER" = false ] && [ "$GENERATE_APPLICATION" = true ]; then
362+
# Use application makefile instead of solution makefile
363+
echo "Building application only..."
364+
# Find the application makefile
365+
APP_MAKEFILE=$(find $OUTPUT_DIR -mindepth 2 -maxdepth 2 -name "*.Makefile" ! -name "*.solution.Makefile" | head -1)
366+
if [ -z "$APP_MAKEFILE" ]; then
367+
echo "ERROR: No application Makefile found in $OUTPUT_DIR"
368+
exit 1
369+
fi
370+
APP_DIR=$(dirname "$APP_MAKEFILE")
371+
APP_MAKEFILE_NAME=$(basename "$APP_MAKEFILE")
372+
make all -C $APP_DIR -f $APP_MAKEFILE_NAME -j13
373+
else
374+
make all -C $OUTPUT_DIR -f $MAKE_FILE -j13
375+
fi

0 commit comments

Comments
 (0)