nuttx/CMake: Fix build more dependencies for kernel mode build #882
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
If nothing is changed, this cuts down the rebuild steps to 1. This occurs on the first rebuild, after which the rebuild no longer performs any steps.
The reason why the 1 unnecessary step is still executed on the first re-build, is that the kernel mode /bin folder is stripped 'in place'. This confuses the Ninja build system as every file in the folder has been "touched" after Ninja did the build.
First rebuild:
[1/1] Generating bin_copy.stamp
Second rebuild:
ninja: no work to do.
EDIT: Add some comments
There are still several issues with re-build dependencies it seems. Both ROM filesystems (/boot and /bin) depend
on nuttx_app_bins, which is correct in the sense that they need to be ordered in this way. However, it seems that
for some reason custom targets do NOT trigger explicit rebuild, only file targets do that.
This means that any dependency to nuttx_apps_build will not update the final firmware with files changed. Example:
modify nsh code (like nsh_main.c), and do rebuild:
This makes it so, that any modification to nuttx/apps will NOT EXPLICITLY be added to the final firmware, in fact the firmware re-build might not trigger at all. It is by pure chance that it does (some other file dependency does this).
Fix this by using a file dependency (another .stamp file) instead of nuttx_app_bins custom target.
Reference: https://discourse.cmake.org/t/add-custom-command-with-target-dependency-doesnt-rebuild/7029/6