p4c
p4c copied to clipboard
[P4Testgen] Unify compiler options and tool options. Ensure options context is always initialized correctly.
This is a larger rewrite of the core parts of P4Testgen's target initialization. The goal is to fix several problems when trying to use P4Testgen and other tools as a library. We need to make sure that the CompileContext we are accessing is the correct one.
-
We decouple initialization of the options and the initialization of the target. This way we can initialize a target before we even know which options we need. This means we can make the options target-dependent (e.g., different options for BMv2, Tofino, etc). This can be really nice for usability since we can create bespoke options per target.
-
To reduce the amount of random static objects floating around we fold P4ToolsOptions and the CompilerOptions together. There is no reason why need two classes here.
-
Options are only accessed by passing them along or retrieving them from the context stack. Ideally, we get rid of the context stack entirely but this requires a lot more work.