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

Add -f option to fpp-depend #101

Closed bocchino closed 2 years ago

bocchino commented 2 years ago

For reporting framework dependencies to CMake. Known dependencies are

bocchino commented 2 years ago

@LeStarch FYI. Let me know if you need other framework dependency info.

LeStarch commented 2 years ago

Guarded inputs/commands as these need a dependency on Os. Everything else should not cause issues if including in a global list.

LeStarch commented 2 years ago

Note: the Ai XML representation is here: https://github.com/nasa/fprime/blob/devel/cmake/support/parser/ai_parser.py this has all the details broken out, although we decided we can live with larger aggregates.

@timcanham also put in a "packets" setup, but I think for now that will still be an XML definition as it is a custom autocoder.

bocchino commented 2 years ago

Sounds good. I think coarsening the dependencies at this stage is a good idea, to simplify and reduce coupling, if it works OK. Eventually we will need even finer-grained dependencies (FPP symbol --> framework header file) to do C++ code gen, but we can't do that analysis in fpp-depend.

I think the coarsening should work fine, since the performance bottleneck is dependency analysis, not compiling a few extra small C++ files in the framework here and there.

I agree that FPP analysis can't do anything with telemetry packets at this stage. BTW I notice that Svc_TlmPacketizer is not represented in DEPENDENCY_ORDER -- is this a bug?

bocchino commented 2 years ago

My plan is to have the tool print out these dependencies, in the correct (reversed) order:

Fw_Comp
Os
Fw_CompQueued

If needed we can add more later. But it looks like we can just make the others unconditional and place them all before these ones.

bocchino commented 2 years ago

place them all before

By which, of course, I mean place after (because of the reversal).

bocchino commented 2 years ago

BTW I notice that Svc_TlmPacketizer is not represented in DEPENDENCY_ORDER -- is this a bug?

OK, it looks like any dependency not in DEPENDENCY_ORDER goes at the end.

bocchino commented 2 years ago

@LeStarch Can you see if the changes on this branch

https://github.com/fprime-community/fpp/tree/issue-101-fwk-depend

are doing what you need? I added an -f option to fpp-depend. It's documented on the wiki and in the User's Guide on this branch. You can see it by installing from this branch and running fpp-depend --help.

bocchino commented 2 years ago

Example:

[I] bocchino@MT-306179 ~/J/T/f/d/users-guide (issue-101-fwk-depend)> fpp-depend -f fwk.txt
active component C { }
passive component D {
  guarded input port p: P
}
[I] bocchino@MT-306179 ~/J/T/f/d/users-guide (issue-101-fwk-depend)> cat fwk.txt 
Fw_CompQueued
Os
Fw_Comp
LeStarch commented 2 years ago

Yes, I can take a look tomorrow!

LeStarch commented 2 years ago

@bocchino this seems to always generate an empty file. I am running it on FileManager.fpp, which has an active component and thus should depend on Fw_CompQueued...but generates an empty file.

LeStarch commented 2 years ago

@bocchino I see two bugs on this branch:

  1. If a component or object is defined in a module (e.g. module Svc { --defined here -- }) then this fails.
  2. An active/queued component only reports Fw_CompQueued but it should report Fw_CompQueued and Os ... although this is a moot point because the Os dependency is done inside Fw_CompQueue too
LeStarch commented 2 years ago

@bocchino here is a patch that fixes the first bug. The second is, again, inconsequential.

index ae01eb0d..63503d9f 100644
--- a/compiler/lib/src/main/scala/analysis/ComputeDependencies/Framework/ComputeFrameworkDependencies.scala
+++ b/compiler/lib/src/main/scala/analysis/ComputeDependencies/Framework/ComputeFrameworkDependencies.scala
@@ -20,6 +20,15 @@ object ComputeFrameworkDependencies extends AstStateVisitor {
     visitList(s + d, data.members, matchComponentMember)
   }

+  override def defModuleAnnotatedNode(
+    s: State,
+    aNode: Ast.Annotated[AstNode[Ast.DefModule]]
+  ) = {
+    val (_, node, _) = aNode
+    val data = node.data
+    visitList(s, data.members, matchModuleMember)
+  }
+
bocchino commented 2 years ago

Thanks, good catch! I fixed both issues.

Here is my current understanding of the framework dependency rules: https://github.com/fprime-community/fpp/wiki/fpp-depend

I'll go ahead and merge the branch to main. Let me know if you see any other issues.

bocchino commented 2 years ago

Done in commit d029d357c0e8900f07e2c6b0be864e4a724f974d.