zhaoxingyu12 opened a new pull request, #21954:
URL: https://github.com/apache/nuttx/pull/21954

   *Note: Please adhere to [Contributing 
Guidelines](https://github.com/apache/nuttx/blob/master/CONTRIBUTING.md).*
   
   ## Summary
   
   CMakeLists.txt
    derives the LFS_CONFIG and LFS_DEFINES headers from CMAKE_CURRENT_LIST_DIR, 
so the absolute path of the source tree is baked into the generated build 
files. A configured build tree then stops working as soon as the sources are 
moved, renamed or copied: the compiler keeps looking for the header under the 
old location and fails in #include LFS_STRINGIZE(LFS_CONFIG).
   
   Pass the paths relative to the including file instead, which is what 
Make.defs has always done. #include "..." resolves relative to the directory of 
the file performing the include, and lfs_util.h lives in fs/littlefs/littlefs, 
so "../lfs_vfs.h" always names 
   lfs_vfs.h
    — independently of where the tree sits, where the build directory is, and 
which directory the compiler runs in.
   
   LFS_DEFINES carried the same absolute path and is fixed the same way.
   
   ## Impact
   
   Users: none. No API, configuration option or runtime behaviour changes.
   Build process: the CMake build no longer records the absolute source path 
for these two macros, so a configured build tree survives being moved or 
copied. The CMake and Makefile builds now spell the macros the same way.
   Hardware: none.
   Documentation: none.
   Security: none.
   Compatibility: none. Both macros already accepted a relative path; only the 
value CMake passes changes.
   
   ## Testing
   
   $ cmake -B build -DBOARD_CONFIG=sim:tcpblaster -GNinja .
   -- Generating done
   -- Build files have been written to: build
   
   $ grep -o '\-DLFS_[A-Z_]*=[^ ]*' build/build.ninja | sort -u
   -DLFS_ASSERT=DEBUGASSERT
   -DLFS_ATTR_MAX=1022
   -DLFS_CONFIG=../lfs_vfs.h
   -DLFS_DEBUG=finfo
   -DLFS_ERROR=ferr
   -DLFS_FILE_MAX=2147483647
   -DLFS_NAME_MAX=32
   -DLFS_TRACE=finfo
   -DLFS_WARN=fwarn
   
   $ cmake --build build
   [160/1771] Building C object fs/CMakeFiles/fs.dir/littlefs/lfs_vfs.c.o
   [675/1771] Building C object fs/CMakeFiles/fs.dir/littlefs/littlefs/lfs.c.o
   [1771/1771] Pac SIM with dynamic libs in nuttx.tgz
   Exit status 0, no errors. No absolute path is left in the flags, and both 
littlefs translation units compile.
   
   


-- 
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