Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adds support for clang-format #605

Merged
merged 1 commit into from
Oct 15, 2024
Merged

Conversation

ilumsden
Copy link
Contributor

This PR adds a .clang-format configuration and support scripts to simplify autoformatting.

@ilumsden
Copy link
Contributor Author

ilumsden commented Oct 10, 2024

@daboehme I've added a few extra things to this PR, so I wanted to make a list of changes here:

  • Adds a .clang-format configuration file to configure autoformatting and format checking of C/C++ code
    • This configuration file is designed for clang-format v16.0
  • Adds the autoformat.sh script, which uses clang-format to autoformat the entire repo
  • Adds Dockerfile.format and the autoformat-docker.sh script to run autoformat.sh with clang-format v16.0.6
  • Adds the check-formatting.sh script, which uses clang-format to check the formatting of the entire repo
  • Adds Dockerfile.check and the check-formatting-docker.sh script to run check-formatting.sh with clang-format v16.0.6
  • Adds a new GitHub Action script (format-check.yml) to check C/C++ code formatting in CI
    • This script is essentially the CI version of check-formatting-docker.sh. I couldn't just use that script in the CI because docker run cannot be used in GitHub Actions.
  • Adds the results of autoformatting the repo

All that's left to do in this PR is tune the .clang-format file to get the desired formatting.

@ilumsden
Copy link
Contributor Author

ilumsden commented Oct 10, 2024

To-Dos:

  • Bump version of clang-format to 17.0.6
  • Make function curly braces on new line
  • Allow short functions on single line
  • Look into function call formatting. Specifically see if indents can be fixed amount instead of with open parenthesis
  • Enable AlignConsecutiveAssignments
  • Look into adding spaces around operator declarations/definitions

@ilumsden
Copy link
Contributor Author

@daboehme I've made the changes you requested. The only one I wasn't able to exactly as you wanted was the change regarding spaces around operator definitions/declarations. I was able to add spaces between e.g., operator+ and the parentheses for arguments, but I was not able to add spaces between the operator keyword and the symbol.

When you get the chance, please take a look, and let me know if there are any other tweaks you'd like.

This commit adds the following:
* A .clang-format file for configuring formatting
* A script for autoformatting with clang-format
* A Dockerfile for running the autoformatting script with clang-format
  17.0.6
* A script for building and running the autoformatting Dockerfile
* A script for checking formatting with clang-format
* A Dockerfile for running the format check script with clang-format
  17.0.6
* A script for building and running the format check Dockerfile
* A GitHub Actions CI file for checking formatting
* The results of reformatting the repo
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants