Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

nuttx/CMake: Fix build more dependencies for kernel mode build #882

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

pussuw
Copy link

@pussuw pussuw commented Jan 21, 2025

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:

  • libapps.a gets updated
  • Since libapps.a was updated, the custom_command nuttx_install.stamp is run
  • Since nuttx_install.stamp was updated, custom target nuttx_app_bins is updated, but nothing happens

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

The dependency should be to nuttx_app_bins target, since nsh is deleted
from the /bin folder (to not allow users to execute it). Otherwise the
nsh target will always be re-build (as it does not exist). Using
nuttx_app_bins as the dependency fixes it, and when the content of nsh
is changed it also re-triggers all relevant targets.
The only broken dependency after this change is:
${OUTDIR}/${OUTPREFIX}_romfsimg.h

The file path is a symbolic link and for some reason CMake / Ninja does
not understand this. Maybe it will get fixed some day.
@pussuw pussuw requested a review from jlaitine January 21, 2025 13:34
@pussuw pussuw marked this pull request as draft January 22, 2025 10:29
@pussuw
Copy link
Author

pussuw commented Jan 22, 2025

Marking as draft, this change does not work correctly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants