zhaoxingyu12 opened a new pull request, #21955:
URL: https://github.com/apache/nuttx/pull/21955
The CMake build derived these headers from CMAKE_CURRENT_LIST_DIR, so the
absolute path of the source tree was baked into the build directory. 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 already does. lfs_util.h lives in fs/littlefs/littlefs, so
"../lfs_vfs.h" resolves to fs/littlefs/lfs_vfs.h no matter where the tree sits
or which directory the compiler runs in.
*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
$ kconfig-tweak --enable CONFIG_FS_LITTLEFS_HAS_LFS_DEFINES
$ cmake -B build -DBOARD_CONFIG=sim:tcpblaster -GNinja .
$ grep -o '\-DLFS_\(CONFIG\|DEFINES\)=[^ ]*' build/build.ninja | sort -u
-DLFS_DEFINES=../lfs_nuttx_defines.h
$ cmake --build build
[183/1760] Building C object fs/CMakeFiles/fs.dir/littlefs/lfs_vfs.c.o
[786/1760] Building C object fs/CMakeFiles/fs.dir/littlefs/littlefs/lfs.c.o
--
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]