Skip to content

Resolve "Automatically format generated C++ code using clang-format"

What does this MR do?

Format generated code with clang-format before writing it into the output file.

Changes:

  • Add clang-format to install_requires. This installs clang-format via pip, making sure it is available within the dune-env.
  • Add project_srcdir as global option. Populate it with PROJECT_SOURCE_DIR CMake variable.
  • Accumulate generated code into single string. Pass this string to clang-format and write its output into the file.
  • Execute clang-format in the project_srcdir to make it fetch .clang-format style specifications in that directory. Use Mozilla as fallback style. I ensured that this works in downstream modules as well.

Open Questions

  • Fallback style Mozilla ok?

Related issues

Closes #177 (closed)

Edited by Lukas Riedel

Merge request reports