You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mynewt.apache.org by "janc.apache.org via commits" <co...@mynewt.apache.org> on 2026/10/31 22:22:06 UTC

(mynewt-core) 02/04: hw: Quote paths in build scripts

This is an automated email from the ASF dual-hosted git repository.

sjanc pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mynewt-core.git

commit 0151beed2330265298f23ad711d7253d5e0fc45f
Author: Szymon Janc <sz...@codecoup.pl>
AuthorDate: Sat Oct 31 19:57:11 2026 +0100

    hw: Quote paths in build scripts
    
    The cmac and nrf5340 net core and TF-M build scripts used newt provided
    paths unquoted, so builds of projects in directories with spaces in
    their names failed. The net core script also took the image path from
    the last word of the newt output, which cut it at the first space.
    
    Quote all paths, extract the image path with sed and stop if changing
    directory fails.
    
    Assisted-by: Claude:claude-opus-5-5
---
 hw/drivers/ipc_cmac/scripts/build_libcmac.sh       | 22 +++++++++++-----------
 hw/drivers/ipc_cmac/scripts/create_cmac_bin.sh     |  8 ++++----
 .../net_core_image/scripts/build_net_core.sh       | 14 +++++++-------
 hw/mcu/nordic/nrf5340/tfm/scripts/create_tfmlib.sh |  8 ++++----
 hw/mcu/nordic/nrf5340/tfm/scripts/import_tfmlib.sh |  6 +++---
 5 files changed, 29 insertions(+), 29 deletions(-)

diff --git a/hw/drivers/ipc_cmac/scripts/build_libcmac.sh b/hw/drivers/ipc_cmac/scripts/build_libcmac.sh
index ca19aab17..049eeec12 100755
--- a/hw/drivers/ipc_cmac/scripts/build_libcmac.sh
+++ b/hw/drivers/ipc_cmac/scripts/build_libcmac.sh
@@ -28,20 +28,20 @@ export BASENAME_RAM=cmac.ram
 
 if [ ${MYNEWT_VAL_CMAC_IMAGE_SINGLE} -eq 0 ]; then
     # Create empty image binary (1 byte required for objcopy)
-    truncate -s 1 ${WORK_DIR}/${BASENAME_IMG}.bin
+    truncate -s 1 "${WORK_DIR}/${BASENAME_IMG}".bin
     # Create fixed size RAM image
-    truncate -s ${MYNEWT_VAL_CMAC_IMAGE_RAM_SIZE} ${WORK_DIR}/${BASENAME_RAM}.bin
+    truncate -s ${MYNEWT_VAL_CMAC_IMAGE_RAM_SIZE} "${WORK_DIR}/${BASENAME_RAM}".bin
 else
-    cd ${MYNEWT_PROJECT_ROOT}
-    ${NEWT} build ${MYNEWT_VAL_CMAC_IMAGE_TARGET_NAME}
+    cd "${MYNEWT_PROJECT_ROOT}" || exit 1
+    "${NEWT}" build ${MYNEWT_VAL_CMAC_IMAGE_TARGET_NAME}
 fi
 
-cd ${WORK_DIR}
+cd "${WORK_DIR}" || exit 1
 
 # Convert both binaries to objects and create archive to link
-${OBJCOPY} -I binary -O elf32-littlearm -B armv8-m.main \
-    --rename-section .data=.libcmac.img ${BASENAME_IMG}.bin ${BASENAME_IMG}.o
-${OBJCOPY} -I binary -O elf32-littlearm -B armv8-m.main \
-    --rename-section .data=.libcmac.ram ${BASENAME_RAM}.bin ${BASENAME_RAM}.o
-${AR} -rcs ${LIBCMAC_A} ${BASENAME_IMG}.o ${BASENAME_RAM}.o
-cp ${LIBCMAC_A} ${MYNEWT_APP_BIN_DIR}
+"${OBJCOPY}" -I binary -O elf32-littlearm -B armv8-m.main \
+    --rename-section .data=.libcmac.img "${BASENAME_IMG}".bin "${BASENAME_IMG}".o
+"${OBJCOPY}" -I binary -O elf32-littlearm -B armv8-m.main \
+    --rename-section .data=.libcmac.ram "${BASENAME_RAM}".bin "${BASENAME_RAM}".o
+"${AR}" -rcs "${LIBCMAC_A}" "${BASENAME_IMG}".o "${BASENAME_RAM}".o
+cp "${LIBCMAC_A}" "${MYNEWT_APP_BIN_DIR}"
diff --git a/hw/drivers/ipc_cmac/scripts/create_cmac_bin.sh b/hw/drivers/ipc_cmac/scripts/create_cmac_bin.sh
index 45cc226db..be631c23e 100755
--- a/hw/drivers/ipc_cmac/scripts/create_cmac_bin.sh
+++ b/hw/drivers/ipc_cmac/scripts/create_cmac_bin.sh
@@ -20,12 +20,12 @@
 OBJCOPY=${MYNEWT_OBJCOPY_PATH}
 ELF=${MYNEWT_APP_BIN_DIR}/blehci.elf
 
-cd ${WORK_DIR}
+cd "${WORK_DIR}" || exit 1
 
 # Create image by stripping .ram section
-${OBJCOPY} -R .ram -O binary ${ELF} ${BASENAME_IMG}.bin
+"${OBJCOPY}" -R .ram -O binary "${ELF}" "${BASENAME_IMG}".bin
 # RAM image is the same as binary created by newt
-cp ${ELF}.bin ${BASENAME_RAM}.bin
+cp "${ELF}".bin "${BASENAME_RAM}".bin
 
 # Create a copy of image to flash to partition, if required
-cp ${BASENAME_IMG}.bin ${ELF}.img.bin
+cp "${BASENAME_IMG}".bin "${ELF}".img.bin
diff --git a/hw/mcu/nordic/nrf5340/net_core_image/scripts/build_net_core.sh b/hw/mcu/nordic/nrf5340/net_core_image/scripts/build_net_core.sh
index 958537b05..f2de6762e 100755
--- a/hw/mcu/nordic/nrf5340/net_core_image/scripts/build_net_core.sh
+++ b/hw/mcu/nordic/nrf5340/net_core_image/scripts/build_net_core.sh
@@ -35,24 +35,24 @@ fi
 export WORK_DIR=${MYNEWT_USER_WORK_DIR}
 
 export NEWT_CREATE_IMAGE_OUTPUT=$WORK_DIR/create_image_output
-pushd $MYNEWT_PROJECT_ROOT
+pushd "$MYNEWT_PROJECT_ROOT" || exit 1
 
-${NEWT} create-image ${MYNEWT_VAL_NET_CORE_IMAGE_TARGET_NAME} $CREATE_IMAGE_FLAGS -o $NEWT_CREATE_IMAGE_OUTPUT
+"${NEWT}" create-image ${MYNEWT_VAL_NET_CORE_IMAGE_TARGET_NAME} $CREATE_IMAGE_FLAGS -o "$NEWT_CREATE_IMAGE_OUTPUT"
 # Extract image name from output
-export NET_CORE_IMG=`awk '/App image successfully generated:/ { print $NF }' $NEWT_CREATE_IMAGE_OUTPUT`
+export NET_CORE_IMG=`sed -n 's/^App image successfully generated: //p' "$NEWT_CREATE_IMAGE_OUTPUT"`
 
-cd ${WORK_DIR}
+cd "${WORK_DIR}" || exit 1
 if [ -n "$NET_CORE_IMG" ] ; then
   # Copy image to local folder so objcopy creates symbols with short names instead of very long ones.
   # Name net_core.img translates to two symbols created by objcopy:
   # _binary_net_core_img_start, _binary_net_core_img_end those symbols are then used to reference content
   # of net_core.img. Changing this name could lead to invalid builds.
-  cp $NET_CORE_IMG ${WORK_DIR}/net_core.img
+  cp "$NET_CORE_IMG" "${WORK_DIR}"/net_core.img
 
   # Make .o file from existing binary image
-  ${OBJCOPY} --rename-section .data=.net_core_img,alloc,load,readonly,data,contents -O elf32-littlearm -B armv8-m.main -I binary net_core.img ${NET_CORE_O}
+  "${OBJCOPY}" --rename-section .data=.net_core_img,alloc,load,readonly,data,contents -O elf32-littlearm -B armv8-m.main -I binary net_core.img "${NET_CORE_O}"
 
   # Archive .o for newt to use
-  ${AR} -rcs ${NET_CORE_A} ${NET_CORE_O}
+  "${AR}" -rcs "${NET_CORE_A}" "${NET_CORE_O}"
 fi
 popd
diff --git a/hw/mcu/nordic/nrf5340/tfm/scripts/create_tfmlib.sh b/hw/mcu/nordic/nrf5340/tfm/scripts/create_tfmlib.sh
index 55a4ebf93..6358ee2c6 100755
--- a/hw/mcu/nordic/nrf5340/tfm/scripts/create_tfmlib.sh
+++ b/hw/mcu/nordic/nrf5340/tfm/scripts/create_tfmlib.sh
@@ -20,11 +20,11 @@
 
 AR=${MYNEWT_AR_PATH}
 
-pushd ${MYNEWT_PROJECT_ROOT}
+pushd "${MYNEWT_PROJECT_ROOT}" || exit 1
 
-if [ -f ${MYNEWT_PROJECT_ROOT}/bin/tfm_s_CMSE_lib.o ] ; then
-  mv ${MYNEWT_PROJECT_ROOT}/bin/tfm_s_CMSE_lib.o ${MYNEWT_PKG_BIN_DIR}/
-  ${AR} rcs ${MYNEWT_BIN_DIR}/tfm_s_CMSE_lib.a ${MYNEWT_PKG_BIN_DIR}/tfm_s_CMSE_lib.o
+if [ -f "${MYNEWT_PROJECT_ROOT}"/bin/tfm_s_CMSE_lib.o ] ; then
+  mv "${MYNEWT_PROJECT_ROOT}"/bin/tfm_s_CMSE_lib.o "${MYNEWT_PKG_BIN_DIR}"/
+  "${AR}" rcs "${MYNEWT_BIN_DIR}"/tfm_s_CMSE_lib.a "${MYNEWT_PKG_BIN_DIR}"/tfm_s_CMSE_lib.o
 fi
 
 popd
diff --git a/hw/mcu/nordic/nrf5340/tfm/scripts/import_tfmlib.sh b/hw/mcu/nordic/nrf5340/tfm/scripts/import_tfmlib.sh
index 9749cd677..27cbb513f 100755
--- a/hw/mcu/nordic/nrf5340/tfm/scripts/import_tfmlib.sh
+++ b/hw/mcu/nordic/nrf5340/tfm/scripts/import_tfmlib.sh
@@ -21,10 +21,10 @@
 if [ "${MYNEWT_VAL_TFM_SECURE_BOOT_TARGET}" != "" ] ; then
   export IMPORT_LIBRARY=${MYNEWT_PROJECT_ROOT}/bin/targets/${MYNEWT_VAL_TFM_SECURE_BOOT_TARGET}/tfm_s_CMSE_lib.a
 
-  pushd ${MYNEWT_PROJECT_ROOT}
+  pushd "${MYNEWT_PROJECT_ROOT}" || exit 1
 
-  if [ -f ${IMPORT_LIBRARY} ] ; then
-    cp -u ${IMPORT_LIBRARY} ${MYNEWT_BUILD_GENERATED_DIR}/bin/
+  if [ -f "${IMPORT_LIBRARY}" ] ; then
+    cp -u "${IMPORT_LIBRARY}" "${MYNEWT_BUILD_GENERATED_DIR}"/bin/
   fi
 
   popd