nuttx icon indicating copy to clipboard operation
nuttx copied to clipboard

Add `oldconfig` and `olddefconfig` custom targets to CMake

Open pietroalbini opened this issue 1 year ago • 2 comments

Summary

The Fast configuration changes section of the documentation mentions the need to run make oldconfig and make olddefconfig after changing the configuration with kconfig-tweak, but those commands are not exposed through CMake. This PR adds them, and adds a note in the documentation pointing users to it.

Impact

This will allow users compiling with CMake to properly use kconfig-tweak.

Testing

cmake -Bbuild -GNinja -DBOARD_CONFIG=fvp-armv8r-aarch32:nsh
cd build
cat .config | grep MKFATFS  # Doesn't show anything :(
kconfig-tweak --enable CONFIG_FS_FAT
cat .config | grep MKFATFS  # Doesn't show anything :(
cmake --build . -t olddefconfig
cat .config | grep MKFATFS  # Show the newly available option!

pietroalbini avatar Aug 21 '24 16:08 pietroalbini

Hi @pietroalbini @xiaoxiang781216 nice question! I think we should deal with an essential problem here.

First, I think the usage of kconfig-kweak in the description should be the lack of parameters. when I use kconfig-kweak --file .config --enable XXXX, the configuration can be modified successfully.

But when doing cmake build, it is necessary to distinguish between original build and incremental build.

If we do original build, the tweak changes will take effect, but if it is incremental build, it will NOT.

This is because our config.h in cmake is an independent execution generation, not a target, which leads to no relationship dependency between .config and config.h. and this is why config.h needs to be deleted.

So I think the problem we should deal with is to make config.h independent and establish dependency?

xuxin930 avatar Aug 29 '24 02:08 xuxin930

@xuxin930 added a dependency relationship between .config and config.h!

Note that until now I never worked on CMake configuration files, so there is probably a better way to do it than my approach. I ended up invoking nuttx_mkconfig with cmake -P as a separate invocation, which doesn't feel "right" to me. But from what I could see online, the solution I would've intuitively done (wrapping the config.h generation into a function and calling that function from add_custom_command) doesn't seem to be possible in CMake.

pietroalbini avatar Aug 29 '24 10:08 pietroalbini

@pietroalbini could you fix the build break?

xiaoxiang781216 avatar Mar 10 '25 13:03 xiaoxiang781216

please try rebase your changes

xuxin930 avatar Mar 11 '25 03:03 xuxin930

Unfortunately priorities at work shifted, and I won't be able to finish this change :frowning_face: Closing the PR.

pietroalbini avatar Mar 27 '25 11:03 pietroalbini