v01d opened a new issue #3455:
URL: https://github.com/apache/incubator-nuttx/issues/3455


   I'm opening this issue to discuss whether there would be interest in 
eventually migrating the build system to CMake. The motivation is in part a 
recent message by @dagar where he asked about this. But furthermore, the build 
system is sometimes quite a pain to maintain, and is extremely complex to fully 
understand.
   
   The benefits of migrating towards CMake could be the following:
   
   - Improved cross platform developer experience (Windows native build likely 
feasible)
   - Significantly improved build times, both incremental and clean (supports 
not only Makefile generation, but ninja which is highly efficient for large 
parallel builds)
   - Solves dependency handling on its own
   - Better integration with 3rd party projects (consuming NuttX) and libs (eg 
LLVM libc++ cmake). Can also interact with pure Make based projects easily.
   - Proper IDE support (VSCode, CLion, etc), nice things like Intellisense 
will "just work"
   - Potential for tighter integration between configuration and build
   
   Furthermore, it can help alleviate issues that we face:
   
   - As CMake is not just a language but includes higher-level functionality 
(functions handling build targets, etc.) which structures the build in known 
ways, it can be more easily understood and maintained. Makefiles use 
hand-written rules which require explicit documentation (which does not really 
exist right now) for "the right way" to do things (how to structure a 
directory, which variables to define, in what order to add includes, etc) and 
is thus easier to break.
   - Our dependency handling is brittle: it has been broken and fixed many 
times and requires much manual work (it still is not right, particularly for 
external projects)
   - Multiplatform support requires separate code paths and approaches which 
need to be kept in sync
   - Our build requires slow traversal of all sub-directories for various 
operations
   - Object files dispersed over source directories. CMake builds in separate 
directory and opens the potential to having multiple builds of the same code 
base simultaneously.
   - We have to deal with collision between object file names in different 
directories (currently handled by embedding path to file as part of object file 
name)
   
   From the technical standpoint, migration would be indeed a lot of work but 
not necessarily hard. @dagar has already done prior work on this (on older 
version of NuttX). See here:
   
   - https://github.com/PX4/NuttX/commits/pr-cmake
   - https://github.com/PX4/NuttX-apps/tree/pr-cmake
   
   In general, the approach is more or less like this:
   1. Define a set of CMake utility functions, to define libraries and 
applications
   2. Replace every Make.defs with a CMakeLists.txt, which defines the source 
files to be added from that directory
   3. Define custom targets for things like menuconfig, etc.
   4. Define custom commands for things like creating symlinks, etc.
   5. Provide a top-level Makefile that simplifies the "mkdir build; cd build; 
cmake ..; make" procedure
   
   The idea would be to do this work in a separate branch and initially reach a 
minimal POC (support one board for example, and most of the complexity such as 
different platforms, kernel build, etc.). This can then be iterated until the 
user experience is right and then finally extended to all boards/arch.
   
   @dagar has offered to help and I would also like to do so. At the moment, we 
would like to assess whether the community at least feels this is worthy of an 
attempt so we can slowly start heading this direction (we could aim for a major 
release of NuttX, so this is not rushed either). 


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

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


Reply via email to