trns1997 commented on code in PR #16976:
URL: https://github.com/apache/nuttx/pull/16976#discussion_r2339487220


##########
tools/mkexport.sh:
##########
@@ -364,70 +367,101 @@ cp -LR -p "${TOPDIR}/include" "${EXPORTDIR}/." || \
 ${MAKE} -C ${ARCHDIR} export_startup TOPDIR=${TOPDIR} EXPORT_DIR="${EXPORTDIR}"
 
 # Copy architecture-specific header files into the arch export sub-directory.
-# This is tricky because each architecture does things in a little different
-# way.
-#
-# First copy any header files in the architecture src/ sub-directory (some
-# architectures keep all of the header files there, some a few, and others
-# none
-
-cp -f "${ARCHDIR}"/*.h "${EXPORTDIR}"/arch/. 2>/dev/null
-
-# Then look a list of possible places where other architecture-specific
-# header files might be found.  If those places exist (as directories or
-# as symbolic links to directories, then copy the header files from
-# those directories into the EXPORTDIR
+# Some architectures keep all headers in src/, some only a few, and others 
none.
+
+if [ -d "${ARCHDIR}" ]; then
+    # Expand the glob safely
+    set -- "${ARCHDIR}"/*.h
+    if [ -e "$1" ]; then
+        echo "Copying architecture headers from ${ARCHDIR} to 
${EXPORTDIR}/arch"
+        if ! cp -f "$@" "${EXPORTDIR}/arch/"; then
+            echo "Error: Failed to copy headers from ${ARCHDIR}" >&2
+            exit 1
+        fi
+    else
+        echo "Notice: No header files found in ${ARCHDIR}" >&2
+    fi
+else
+    echo "Warning: Architecture directory ${ARCHDIR} does not exist" >&2

Review Comment:
   add `MK:` to output message



##########
tools/mkexport.sh:
##########
@@ -364,70 +367,101 @@ cp -LR -p "${TOPDIR}/include" "${EXPORTDIR}/." || \
 ${MAKE} -C ${ARCHDIR} export_startup TOPDIR=${TOPDIR} EXPORT_DIR="${EXPORTDIR}"
 
 # Copy architecture-specific header files into the arch export sub-directory.
-# This is tricky because each architecture does things in a little different
-# way.
-#
-# First copy any header files in the architecture src/ sub-directory (some
-# architectures keep all of the header files there, some a few, and others
-# none
-
-cp -f "${ARCHDIR}"/*.h "${EXPORTDIR}"/arch/. 2>/dev/null
-
-# Then look a list of possible places where other architecture-specific
-# header files might be found.  If those places exist (as directories or
-# as symbolic links to directories, then copy the header files from
-# those directories into the EXPORTDIR
+# Some architectures keep all headers in src/, some only a few, and others 
none.
+
+if [ -d "${ARCHDIR}" ]; then
+    # Expand the glob safely
+    set -- "${ARCHDIR}"/*.h
+    if [ -e "$1" ]; then
+        echo "Copying architecture headers from ${ARCHDIR} to 
${EXPORTDIR}/arch"
+        if ! cp -f "$@" "${EXPORTDIR}/arch/"; then
+            echo "Error: Failed to copy headers from ${ARCHDIR}" >&2
+            exit 1
+        fi
+    else
+        echo "Notice: No header files found in ${ARCHDIR}" >&2
+    fi
+else
+    echo "Warning: Architecture directory ${ARCHDIR} does not exist" >&2
+fi
 
 if [ "X${USRONLY}" != "Xy" ]; then
   ARCH_HDRDIRS="arm armv7-m avr avr32 board common chip mips32"
+
   for hdir in $ARCH_HDRDIRS; do
+    srcdir="${ARCHDIR}/${hdir}"
+    dstdir="${EXPORTDIR}/arch/${hdir}"
 
     # Does the directory (or symbolic link) exist?
+    if [ -d "$srcdir" ] || [ -h "$srcdir" ]; then
+      mkdir -p "$dstdir" || {
+        echo "Error: mkdir $dstdir failed" >&2

Review Comment:
   add `MK:` to output message



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to