nasa / fpp

F Prime Prime: A modeling language for F Prime
https://fprime.jpl.nasa.gov
Apache License 2.0
49 stars 31 forks source link

Should fpp@main build with fprime@devel? #255

Closed sobkulir closed 1 year ago

sobkulir commented 1 year ago

Hello,

I'm working on a port for Zephyr (https://github.com/sobkulir/fprime-zephyr-app) and I need to add a few changes to the fpp-to-cpp tool (https://github.com/nasa/fprime/discussions/2026). Therefore, I branched from fpp@main (71932e3) and added my changes, however, the app does not build with fprime@devel (ccb974a) with the following error:

Traceback (most recent call last):
  File "/zephyr-workspace/fprime-zephyr-app/fprime/fprime/Autocoders/Python/bin/codegen.py", line 28, in <module>
    from fprime_ac.utils import (
  File "/zephyr-workspace/fprime-zephyr-app/fprime/fprime/Autocoders/Python/src/fprime_ac/utils/ArrayGenerator.py", line 18, in <module>
    from fprime_ac.generators.templates.arrays import array_cpp, array_hpp
ImportError: cannot import name 'array_cpp' from 'fprime_ac.generators.templates.arrays' (/zephyr-workspace/fprime-zephyr-app/fprime/fprime/Autocoders/Python/src/fprime_ac/generators/templates/arrays/__init__.py)
gmake[3]: *** [Ref/Top/CMakeFiles/Ref_Top.dir/build.make:203: Ref/Top/RefTopologyAppDictionary.xml] Error 1
gmake[2]: *** [CMakeFiles/Makefile2:8407: Ref/Top/CMakeFiles/Ref_Top.dir/all] Error 2
gmake[1]: *** [CMakeFiles/Makefile2:2045: CMakeFiles/Ref.dir/rule] Error 2
gmake: *** [Makefile:195: Ref] Error 2
[ERROR] CMake erred with return code 2

The python autocoder files under Autocoders/Python/src/fprime_ac/generators/templates/**/**.py seem to not get generated in the build. I'm not sure why fpp affects this, however, when trying to build the same app with fpp@v1.2.0 it worked.

I did not bisect the error because maybe this is the intended behavior. Therefore, I have the following questions: 1) If this is intended? If yes, what is the recommended workflow for developing fpp with fprime? 2) The non-release build of fpp seems to be quite slow (I use compiler/install script) and the release build takes a lot of time to compile (compiler/release). I use the following to get sbt and graal: https://github.com/sobkulir/fprime-zephyr-app/blob/main/Dockerfile#L83 and also export FPP_SBT_FLAGS='--batch -Dsbt.server.forcestart=true'. Do you just bear with this or can you recommend a better way? (This is also why I didn't bisect the error and rather created an issue)

bocchino commented 1 year ago

Here are my answers:

  1. The build failure that you reported is not intended. From the output you provided, it looks like an issue with the interaction between the CMake build system and the Python XML generator.
  2. We bear with it.

With regard to the recommended workflow, here is what I do when developing F Prime with a non-released version of FPP:

  1. Wipe out all the F Prime build caches.
  2. Re-install F Prime tools if there has been any update to F Prime.
  3. Run a script that (a) copies the version of FPP I want to use into fprime-venv/bin and (b) updates requirements.txt to reflect that version.
  4. Run the ordinary generate and build steps.

Note: I just built fprime/Ref with a branch of fpp that's ahead of main. It builds fine. You may want to try wiping out the build caches and trying again. If it still doesn't work, see if you can build fprime/Ref with your fpp branch.

bocchino commented 1 year ago

Also, note that fpp/main does more C++ code generation than the FPP version that fprime/devel expects. This should work, but it's possible that the CMake build cache is getting confused. If so, then wiping out the build cache should make the problem go away.

sobkulir commented 1 year ago

Thanks a lot for your answer! I think you are not wiping the build caches haha 🙃 F' does a small in-source build of the following files:

Autocoders/Python/src/fprime_ac/generators/templates/**/**.py

Can you please try also wiping those and rebuilding? I used

ls -d Autocoders/Python/src/fprime_ac/generators/templates/**/**.py | sed '/.*__init__.py/d' | xargs -I{} rm -r "{}"

Maybe I'm missing something, but I created a PR that fixes the issue for me: https://github.com/nasa/fprime/pull/2044

bocchino commented 1 year ago

Sounds good! I'm closing this issue as the PR was merged.