Skip to content

Commit

Permalink
[script] fix bug when running script/build with `OT_CMAKE_NINJA_TAR…
Browse files Browse the repository at this point in the history
…GET` containing no RCP targets

When running `OT_CMAKE_NINJA_TARGET="ot-cli-ftd" script/build brdXXXXy`, the build script errors with `rcp_targets` being an unbound variable.

```shell
+ rcp_targets=()
+ soc_targets=()
+ for t in '"${OT_CMAKE_NINJA_TARGET[@]}"'
+ [[ ot-cli-ftd =~ .*rcp.* ]]
+ soc_targets+=("$t")
script/build: line 282: rcp_targets[@]: unbound variable

```

This commit fixes the problem by using a default empty string when `rcp_targets` is empty.
  • Loading branch information
lmnotran committed Jan 22, 2024
1 parent 2724563 commit c5fdcea
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions script/build
Original file line number Diff line number Diff line change
Expand Up @@ -279,10 +279,10 @@ main()
for t in "${OT_CMAKE_NINJA_TARGET[@]}"; do [[ $t =~ .*rcp.* ]] && rcp_targets+=("$t") || soc_targets+=("$t"); done

# Build ot-rcp targets
if contains "ot-rcp-uart" "${rcp_targets[@]}"; then
if contains "ot-rcp-uart" "${rcp_targets[@]-}"; then
build_rcp_uart -DEFR32_PLATFORM="${platform}" -DBOARD="${board}" "${options[@]}"
fi
if contains "ot-rcp-spi" "${rcp_targets[@]}"; then
if contains "ot-rcp-spi" "${rcp_targets[@]-}"; then
build_rcp_spi -DEFR32_PLATFORM="${platform}" -DBOARD="${board}" "${options[@]}"
fi
# Build soc targets
Expand Down

0 comments on commit c5fdcea

Please sign in to comment.