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

xiaoxiang781216 pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx.git


The following commit(s) were added to refs/heads/master by this push:
     new 7f4629ca01a cmake: keep preprocess depfiles out of the ROMFS staging 
directory
7f4629ca01a is described below

commit 7f4629ca01ae3cb3e137d5940af30fdff4b26277
Author: Junbo Zheng <[email protected]>
AuthorDate: Thu Nov 12 10:44:18 2026 +0800

    cmake: keep preprocess depfiles out of the ROMFS staging directory
    
    nuttx_generate_preprocess_target writes its dependency file next to
    the preprocessed output (-MF ${TARGET_FILE}.d).  For the ROMFS staging
    targets that directory is packed verbatim by genromfs, so a
    CMake-built configuration with CONFIG_ETC_ROMFS ships the .d files
    in /etc: sim:nsh currently carries init.rc.d next to the real
    script.  The Make flow is not affected: its PREPROCESS macro does
    not generate depfiles.
    
    Generate the depfile under a .deps/ directory instead, so the staging
    directory only ever contains files meant for the image.
    
    Testing:
    - cmake -B build -DBOARD_CONFIG=sim:nsh && ./build/nuttx,
      then ls /etc/init.d:
    
    Before:
     init.rc
     init.rc.d
    After:
     init.rc
    
    Signed-off-by: Junbo Zheng <[email protected]>
---
 cmake/nuttx_toolchain.cmake | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)

diff --git a/cmake/nuttx_toolchain.cmake b/cmake/nuttx_toolchain.cmake
index 2a83ae677d3..2541ad4ef40 100644
--- a/cmake/nuttx_toolchain.cmake
+++ b/cmake/nuttx_toolchain.cmake
@@ -99,7 +99,16 @@ if(NOT NUTTX_TOOLCHAIN_PREPROCESS_DEFINED)
     if((CMAKE_GENERATOR MATCHES "Ninja|Makefiles")
        AND (CMAKE_C_COMPILER_ID STREQUAL "GNU" OR CMAKE_C_COMPILER_ID MATCHES
                                                   "Clang"))
-      set(preprocess_depfile ${TARGET_FILE}.d)
+      # Keep the depfile out of the preprocessed output directory: for ROMFS
+      # staging targets that directory is packed verbatim by genromfs, so a .d
+      # file next to the output would ship in the image.
+      file(RELATIVE_PATH preprocess_depfile_rel ${CMAKE_CURRENT_BINARY_DIR}
+           ${TARGET_FILE})
+      set(preprocess_depfile
+          ${CMAKE_CURRENT_BINARY_DIR}/.deps/${preprocess_depfile_rel}.d)
+      get_filename_component(preprocess_depfile_dir ${preprocess_depfile}
+                             DIRECTORY)
+      file(MAKE_DIRECTORY ${preprocess_depfile_dir})
       list(
         APPEND
         preprocess_depflags

Reply via email to