Skip to content

cmake: remove fprime-util metadata of the un-parented directories on configure - #277

Closed
devin-ai-integration[bot] wants to merge 3 commits into
develfrom
devin/1791567374-fprime-util-metadata-reconfigure
Closed

devin-ai-integration[bot] wants to merge 3 commits into
develfrom
devin/1791567374-fprime-util-metadata-reconfigure

Conversation

@devin-ai-integration

@devin-ai-integration devin-ai-integration Bot commented Oct 9, 2026 •

Copy link
Copy Markdown
Related Issue(s)
Has Unit Tests (y/n) n
Documentation Included (y/n) n
Generative AI was used in this contribution (y/n) AI

Change Description

Add fprime_util_metadata_remove(DIRECTORY) in cmake/fprime-util.cmake (removes the four *.fprime-util metadata files of a directory) and call it once per configure for the two directories no add_fprime_subdirectory parent ever resets:

  • the project root (CMAKE_BINARY_DIR), at file scope in cmake/FPrime.cmake next to the existing fprime-*-locations resets;
  • the directory that includes F´ (e.g. F-Prime/), as the first statement of fprime_setup_included_code(), before fprime_setup_platform() writes PlatformXxx / all into it. Skipped when that directory is the root.

Parented directories keep today's behavior (fprime_util_metadata_clear, empty files). The root files are removed rather than truncated because fprime-util treats a missing build-targets.fprime-util as "fall back to the default target" and an empty one as "nothing to build".

Rationale

Metadata is written with file(APPEND) and only cleared by the parent's add_fprime_subdirectory. The two directories above have no such parent, so every re-configure (ninja auto-rerun after a CMakeLists.txt edit, repeated fprime-util generate, ...) appends another PlatformXxx / all pair and another copy of each deployment path. fprime-util build then runs each listed target once per copy:

ninja: no work to do.
[1/1] Running utility command for Deployment_dictionary
-- Install configuration: ""
-- Up-to-date: .../Deployment/dict/DeploymentTopologyDictionary.json
ninja: no work to do.
[1/1] Running utility command for Deployment_dictionary
...

generate -f resets the cache, which is why it is intermittent. Not platform specific; reproduced natively with TestDeploymentsProject (after 7 configures, fprime-util build --recursive ran Ref_dictionary 7× on devel, 1× with this change).

Testing/Review Recommendations

fprime-util generate, then cmake . in the build cache a few times: F-Prime/build-targets.fprime-util stays at two lines (PlatformXxx, all), the root build-targets.fprime-util stays absent, and fprime-util build runs each target once.

Future Work

None.

Contributor Checklist

AI Usage (see policy)

Diagnosis and code written by an AI agent under engineer direction.

IAMAI

@devin-ai-integration

Copy link
Copy Markdown
Author

I'll fix CI failures and address comments from users with write access that start with 'Devin'.

  • Disable automatic comment, CI, and merge conflict monitoring

Original prompt from thomas.boyer.chammard

Sometimes when running a build, it'll kind of loop over the dicitonary install. See

ninja: no work to do.
[1/1] Running utility command for CaptureCarry_dictionary
-- Install configuration: ""
-- Up-to-date: /workspaces/ld-tsw-fc-capture-carry/build-artifacts/vxworks/CaptureCarry/dict/CaptureCarryTopologyDictionary.json
ninja: no work to do.
[1/1] Running utility command for CaptureCarry_dictionary
-- Install configuration: ""
-- Up-to-date: /workspaces/ld-tsw-fc-capture-carry/build-artifacts/vxworks/CaptureCarry/dict/CaptureCarryTopologyDictionary.json
ninja: no work to do.
[1/1] Running utility command for CaptureCarry_dictionary
-- Install configuration: ""
-- Up-to-date: /workspaces/ld-tsw-fc-capture-carry/build-artifacts/vxworks/CaptureCarry/dict/CaptureCarryTopologyDictionary.json
ninja: no work to do.
[1/1] Running utility command for CaptureCarry_dictionary
-- Install configuration: ""
-- Up-to-date: /workspaces/ld-tsw-fc-capture-carry/build-artifacts/vxworks/CaptureCarry/dict/CaptureCarryTopologyDictionary.json
ninja: no work to do.
[1/1] Running utility command for CaptureCarry_dictionary
-- Install configuration: ""
-- Up-to-date: /workspaces/ld-tsw-fc-capture-carry/build-artifacts/vxworks/CaptureCarry/dict/CaptureCarryTopologyDictionary.json

I think it happens more often when using VxWorks (fprime-vxworks library and platform), but I'm not sure. Can you try to reproduce and diagnose and fix?

@devin-ai-integration devin-ai-integration Bot left a comment •

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note

Newer findings are available below. Devin Review posted a newer report on this PR, in addition to the findings presented here.

✅ Devin Review: No Issues Found

Devin Review analyzed this PR and found no bugs or issues to report.

Devin Review

…configure

The fprime-util metadata files (build-targets, sub-directories, tests,
test-dir .fprime-util) are appended to during configure and only cleared
by the parent directory in add_fprime_subdirectory. The project root and
the directory calling fprime_setup_included_code have no such parent, so
every re-configure appended another copy of each entry and fprime-util
build ran each listed target once per copy (repeated dictionary install).

Remove those files once per configure: the root when FPrime.cmake is
included, the include directory at the start of
fprime_setup_included_code. Files are removed, not truncated, so a
directory that registers nothing stays without files as fprime-util
expects (a missing build-targets file selects the default target, an
empty one selects nothing). Add cmake/test/src/test_metadata.py.
@devin-ai-integration
devin-ai-integration Bot force-pushed the devin/1791567374-fprime-util-metadata-reconfigure branch from 96d0977 to 22151d5 Compare October 11, 2026 23:07
@devin-ai-integration devin-ai-integration Bot changed the title cmake: stop fprime-util metadata from accumulating duplicates on re-configure cmake: remove fprime-util metadata of the un-parented directories on configure Oct 11, 2026

@devin-ai-integration devin-ai-integration Bot left a comment

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Devin Review found 1 new potential issue.

Devin Review

Comment thread cmake/fprime-util.cmake

@devin-ai-integration devin-ai-integration Bot Oct 11, 2026 •

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Metadata accumulates in plain subdirectories

When a plain add_subdirectory registers F Prime targets, reconfiguration appends to its old metadata. Neither the parent nor fprime_setup_included_code clears that directory, so fprime-util repeats its targets.

Learn more

F Prime target registration appends a name to a per-directory metadata file. The usual add_fprime_subdirectory clears a child's metadata before entering it, while fprime_setup_included_code clears its own directory. An ordinary CMake add_subdirectory that registers an F Prime target has neither reset. On the next configure, the old file survives and registration appends its targets again; fprime_util_metadata_add_subdirectory only clears directories explicitly passed to it.

Example: A project enters extras using CMake's add_subdirectory(extras) and extras registers ExtraModule. The first configure writes ExtraModule; a second configure writes ExtraModule twice. Running fprime-util build from extras now invokes that target twice.

Recommended fix: Restore first-write clearing for directories not reset by a parent, without clearing root or framework metadata after earlier writes. Track directories cleared by fprime_util_metadata_clear and by the new early removal calls, then clear an untracked directory before its first append.

Devin Review


Was this helpful? React with 👍 or 👎 to provide feedback.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Known limitation, accepted by design: this change resets exactly the directories that have no add_fprime_subdirectory parent today — the project root and the directory that includes F´ (the only plain add_subdirectory in the framework/TestDeploymentsProject that registers F´ targets; googletest/ and STest/ register none). A project directory entered with plain add_subdirectory is already outside what fprime-util tracks (it is absent from the parent's sub-directories.fprime-util, so build -r never visits it), and add_fprime_subdirectory is the documented way to enter such directories. Covering arbitrary writers would need per-configure global state ("first writer clears"), which was deliberately traded away for the stateless explicit reset.

LeStarch added a commit to nasa/fprime that referenced this pull request Oct 28, 2026
* clear top level metadata files so repeated builds don't add no-op targets

* Remove, not truncate, un-parented fprime-util metadata (#6238)

Truncating the project-root build-targets.fprime-util left an empty file where devel has none; fprime-util reads an empty file as "nothing to build", so building TestDeploymentsProject (find_package layout) became a no-op (CI: Ref "ninja: no work to do.", Integration Tests missing ref-build-artifacts). Remove the root metadata instead, and also reset the directory that includes F Prime in fprime_setup_included_code, which no add_fprime_subdirectory parent clears. Fix taken from JPL-Devin#277.

Co-authored-by: Aaron Black <aaron.black@jpl.nasa.gov>
Co-authored-by: Aaron Black <ablack@.jpl.nasa.gov>
Co-authored-by: Thomas Boyer-Chammard <49786685+thomas-bc@users.noreply.github.com>
Co-authored-by: M Starch <LeStarch@googlemail.com>

---------

Co-authored-by: Aaron Black <ablack@.jpl.nasa.gov>
Co-authored-by: Aaron Black <aaron.black@jpl.nasa.gov>
Co-authored-by: Thomas Boyer-Chammard <49786685+thomas-bc@users.noreply.github.com>
Co-authored-by: M Starch <LeStarch@googlemail.com>
@devin-ai-integration

Copy link
Copy Markdown
Author

Superseded by nasa#6277 (merged into devel), which carries this fix.

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.

1 participant