paths: “code-generation/,plc4net/tools/code-gen/” applyTo: “code-generation/,plc4net/tools/code-gen/”

Code generation

PartGenerates
code-generation/protocol-base-mspec/the mspec grammar (ANTLR) and type model: every language
code-generation/language-base-freemarker/the FreeMarker base for the template languages
code-generation/language/java/ (Java generators)plc4j/drivers/*/src/main/generated/
code-generation/language/go/ (templates/go/)plc4go/protocols/*/readwrite/
code-generation/language/c/ (templates/c/)plc4c/generated-sources/
code-generation/language/python/ (templates/python/)plc4py/plc4py/protocols/*/readwrite/
plc4net/tools/code-gen/ (pure .NET, own mspec parser)plc4net/drivers/*/model/
code-generation/language/cs/ (templates/cs/)not used by plc4net (its generator replaced these)

The plc4x-maven-plugin that runs the generators, and its type API, come from apache/plc4x-build-tools, pinned by plc4x-code-generation.version in the root pom.xml. A change there needs a build-tools release (or a local install plus a bumped property) before this repository can use it.

⛔ A generator or template change regenerates every protocol of that language

  • A template or Java generator change affects every protocol the language generates: regenerate all of them (regenerate-code skill) and commit the whole diff. Review it: an unexpected change in another protocol is a bug in the template, not noise.
  • A change to the mspec grammar or type model (protocol-base-mspec) can change the output of every language, including plc4net/tools/code-gen, which has its own parser: keep both parsers accepting the same mspec.
  • A new mspec feature (field kind, attribute, expression function) works in every language that generates a protocol using it, or the PR says which languages reject it and how they fail.
  • Generated files keep the Code generated ... DO NOT EDIT. line and the Apache license header: the RAT check runs on them too.
  • plc4net/tools/code-gen: python plc4net/tools/code-gen/generate_parsers.py --check (its checked-in ANTLR parser is current) and ./mvnw -f plc4net/pom.xml -Pcheck-generated-code generate-sources (models match) run in CI; run both after a change there.