v01d opened a new pull request #3589: URL: https://github.com/apache/incubator-nuttx/pull/3589
## Summary This is an incomplete work in progress, please do not perform a detailed review. I've been working quite hard on this last few weeks and my interest at this point is to gain visibility to how I structured this, gain some feedback to continue the work and hopefully get some help to complete migration and testing. Note that this depends on accompanying apps/ change (which I have in my fork's cmake branch: [master..cmake compare link](https://github.com/apache/incubator-nuttx-apps/compare/master...v01d:cmake)). I will continue migration until complete and then rebase to incorporate relevant changes that happened in between. For colaboration, I can either accept PRs to my fork or we could setup a new branch. Either way, if someone is willing to help, we should coordinate. ## Some changes part of migration 1. Since the goal is to allow for out-of-tree builds, the context step does not create symlinks inside source tree, but in build directory. Include path is extended to expose this as expected 2. Debug/Release flags are handled via CMAKE_BUILD_TYPE as expected, not from config options 3. APPDIR is taken from cmake command line, not from config 4. Each arch should have a cmake/ directory preparing the required toolchain and relevant options 5. Some specialty functions are defined: * nuttx_add_application: defines an application as expected. it adds an OBJECT library for each app, which is then built into the libapps.a static lib as expected * nuttx_add_library: adds a top-level static library which is linked into final nuttx binary (libfs, libnet, etc.) * nuttx_add_user_library: similar to add_application but not defining an application, but a "library" 6. apps/Kconfig is no longer build-time generated but it is now a static file 7. sim's up_head.c was giving some issues and realized it had a mix of host and nuttx headers. it was split into host-only + up_internal.h API and nuttx calls (which went into sim's up_syslog.c). This most likely could be backported to current NuttX if wanted. Similar to 2 and 3, most likely options defining the host platform should not be part of config file. ## TODO The following are not yet addressed - two-phase build: how to handle this? - revise toolchain handling: I based my changes on @dagar but I'm not entirely sure if there's a 1:1 arch-toolchain mapping or not - extend to other arch/boards: only sim and one board supported right now - verify all Make.defs/Makefile against CMakeLists.txt once all Make.defs are complete - support custom boards (currently disabled inclusion of boards/dummy/Kconfig) - Similar to 2 and 3 points above, remove host/toolchain definition from Kconfig, this should be a config time setting - Remove control of optimization from Kconfig, this is handled via CMAKE_BUILD_TYPE - Support module building (extend nuttx_add_application to take a symbol?) - Module handling in sim build - export: probably needs redesign using cmake, maybe even not needed? - Add a flash target (debug also?), and other useful ones - Avoid having to place .config on source tree (kconfig utils supposeddly takes the path to this file and the Kconfig) - examples/bridge, examples/flowc, examples/nettest? They include host code, this will probably require creating a subproject as we cannot have a mixed build as is. - examples/module: builds a character device?? Is this right? - how to support building apps with external code? - FetchContent: if child project is CMake, it automatically configures it (not always wanted, see libaudiosrc) - ExternalProject: delays child configure to build stage, does not allow adding sources to parent - file(DOWNLOAD ...): manual process - Update GitHub workflow: I've done this but I'm not sure if it works yet - Perform extensive testing on other target and host platforms - Document the build system under Documentation/ (design and how to add board/arch/app) ### Low-priority (could be in later PR) - Make applications conform to <app>/include/<app> and <app>/src/ so that a general include/ is not needed (external apps can also split implementation from interface and expose the latter). - remove unneeded support for renaming most applications, not real use, only adds Kconfig options - do we need setting priority via Kconfig of most applications? shouldn't this be done on runtime? ## Conversion checklist: So far I, this is how far I got the conversion, which allows for sim:nsh to build. You fill find some CMakeLists.txt there from @dagar which need adapting (you'll see I'm using `target_sources` and `CONFIG` variables are not evaluated with `STREQUAL` on the ones I converted). This is quite a tedious and manual process so it will take some time to complete (maybe someone wants to lend a hand? I can give some instructions). I will definitely need help for supporting and testing other boards and also other platforms such as mac and windows. ### Apps - [x] apps/builtin - [ ] apps/canutils - [ ] apps/canutils/libcanard - [x] rest - [ ] apps/examples - [ ] apps/examples/audio_rttl: handle SDK - [ ] apps/examples/bridge - [ ] apps/examples/elf - [ ] apps/examples/flowc - [ ] apps/examples/lvgldemo - [ ] apps/examples/module - [ ] apps/examples/nxflat: tests - [ ] apps/examples/posix_spawn - [ ] apps/examples/romfs - [ ] apps/fsutils - [ ] apps/fsutils/inih - [x] rest - [ ] apps/gpsutils - [ ] apps/import - [ ] apps/industry - [ ] apps/interpreters - [ ] apps/modbus - [ ] apps/netutils - [x] apps/nshlib - [ ] rest - [ ] apps/platform - [ ] apps/system - [x] apps/system/nsh - [ ] rest - [ ] apps/tools - [ ] apps/wireless ### NuttX - [ ] nuttx/arch - [x] nuttx/audio - [x] nuttx/binfmt - [ ] nuttx/boards - [x] nuttx/boards/sim/sim/sim (tested: nsh) - [x] nuttx/boards/arm/stm32/stm32f103-minimum (built: nsh) - [ ] rest - [x] nuttx/crypto - [x] nuttx/drivers - [x] nuttx/fs - [x] nuttx/graphics - [ ] nuttx/libs - [ ] nuttx/libs/libc - [x] nuttx/libs/libc/audio/libsrc: testing file(DOWNLOAD), should not use master version (build issues) - [ ] nuttx/libs/libc/zoneinfo/ (romfs) - [x] rest - [x] nuttx/libs/libdsp - [ ] nuttx/libs/libnx: only need to finish font generation - [ ] nuttx/libs/libxx - [x] nuttx/mm - [x] nuttx/net - [ ] nuttx/openamp - [x] nuttx/sched - [ ] nuttx/syscall - [ ] nuttx/tools: only basic binaries for now - [x] nuttx/video - [x] nuttx/wireless ## Impact Major, this should probably be part of a major NuttX release. ## Testing Basic sim:nsh on Linux. -- 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: [email protected]
