Open weggert2 opened 1 month ago
This is a good point. It would also remove the need to purge the build cache if generation hasn't been successful in some instances. What do we think would be the best behavior:
fprime-util generate
force a re-generate, even when CMake doesn't detect changes?I think we should mirror what CMake does. As far as I know, it doesn't ask for any confirmation if you re run cmake. I also don't think it should force a regenerate, because I think build already does this to some extent (although I am unclear as to when)
Agreed!
If anyone would like to contribute for this, changes likely should be around this function or wherever it gets invoked by fprime-util generate
https://github.com/nasa/fprime-tools/blob/b72544568269010abf2197d9b0dec10bce40e71c/src/fprime/fbuild/builder.py#L371
I'm happy to contribute here, but it would help to have some context on why this behavior exists, since it's called out directly in the docs:
def invent(self, platform: str = None, build_dir: Path = None):
"""Invents a build path from a given platform
Sets this build up as a new build that would be used as as part of a generate step.
This directory must not already exist.
What pitfalls are there to just not raising the error (i.e. removing the following snippet)
if self.build_dir.exists():
msg = f"{self.build_dir} already exists."
raise InvalidBuildCacheException(msg)
It might be that this snippet can just be removed. But I don't know, there may be something else under.
Here's how you can test it out yourself with a local install: https://github.com/nasa/fprime-tools?tab=readme-ov-file#developer-installation
Alright, PR open! Thanks for all the quick responses.
cc @csmith608
Problem Description
fprime-util generate fails if it has already been run, even if the first run was successful.
A typical cmake workflow is
cmake .. && make
. The parallel for F' would befprime-util generate && fprime-util build
, which fails after the first generate. Understood that fprime-util build probably re-runs generate if it needs to, and you only need to run generate once, but from a 'use tools like you're used to' perspective, fprime-util generate should be indempotent and not fail if it has nothing to do.Context / Environment
Execute
fprime-util version-check
and share the output.How to Reproduce
Run fprime-util generate twice
Expected Behavior
Similar to cmake, the second time should either print 'already generated', or some other small message and return success. This is useful for scripting 'generate' and 'build' tasks which rely on the error code.