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

Switch from cmake-format to gersemi for formatting CMake listfiles #722

Merged
merged 4 commits into from
Oct 23, 2024

Conversation

ManifoldFR
Copy link
Contributor

@ManifoldFR ManifoldFR commented Oct 16, 2024

This is a rather large PR (due to reformatting many, many files)

Closes #719

@ManifoldFR ManifoldFR marked this pull request as draft October 16, 2024 08:46
@ManifoldFR
Copy link
Contributor Author

Waiting on #720 to be merged.

@ManifoldFR ManifoldFR force-pushed the topic/gersemi branch 2 times, most recently from 434b669 to 774a97e Compare October 16, 2024 09:30
@ManifoldFR ManifoldFR marked this pull request as ready for review October 16, 2024 09:31
.gersemirc Outdated
Comment on lines 1 to 7
line_length: 80
cache: true
indent: 2
quiet: true
warn_about_unknown_commands: false
workers: 8
list_expansion: favour-inlining
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this necessary ?
Is it going to be necessary on each and every project of ours ?
Couldn't we just use some default settings instead ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tried to put the options that would create the least changes. I think some of these might be the default values though

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we care about the number of changes ?
Those are already 3k on a 15k codebase, so IMHO it could be 2 or 3 times that and we would not see the difference, as long as it is in a single commit documented in .git-blame-ignore-revs

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay, in that case, I remove some of the options in the gersemirc file.

@ManifoldFR ManifoldFR force-pushed the topic/gersemi branch 2 times, most recently from 42cd359 to 610976f Compare October 16, 2024 12:09
Copy link
Collaborator

@nim65s nim65s left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm still not sure about that indent: 2, but I'm not going to block this PR for that either.
Before merging, I think we should clean git history, with:

  1. update .pre-commit-config.yml + setup .gersemirc
  2. pre-commit run -a
  3. add previous to .git-blame-ignore-revs

@ManifoldFR
Copy link
Contributor Author

I'm still not sure about that indent: 2, but I'm not going to block this PR for that either. Before merging, I think we should clean git history, with:

  1. update .pre-commit-config.yml + setup .gersemirc
  2. pre-commit run -a
  3. add previous to .git-blame-ignore-revs

The default indent in gersemi is 4.
I will edit the git history to create a separate commit for 1. and 2.

@ManifoldFR
Copy link
Contributor Author

Done @nim65s 😃

Copy link
Contributor

@jorisv jorisv left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Be sure to replace all # cmake-format: by # gersemi:

Also, I'm curious on how well gersemi handle custom command: https://github.com/BlankSpruce/gersemi?tab=readme-ov-file#lets-make-a-deal

On Pinocchio with cmake-format, I had to do this: https://github.com/stack-of-tasks/pinocchio/blob/devel/.cmake-format.yaml

Last, did you know if gersemi is handling comment in a better way ? cmake-format was joining consecutive line together, make huge comment block.

dist.cmake Outdated Show resolved Hide resolved
dist.cmake Outdated Show resolved Hide resolved
dist.cmake Outdated Show resolved Hide resolved
dist.cmake Outdated Show resolved Hide resolved
dist.cmake Outdated Show resolved Hide resolved
dist.cmake Outdated Show resolved Hide resolved
header.cmake Outdated Show resolved Hide resolved
release.cmake Outdated Show resolved Hide resolved
release.cmake Show resolved Hide resolved
@ManifoldFR
Copy link
Contributor Author

Be sure to replace all # cmake-format: by # gersemi:

Also, I'm curious on how well gersemi handle custom command: https://github.com/BlankSpruce/gersemi?tab=readme-ov-file#lets-make-a-deal

On Pinocchio with cmake-format, I had to do this: https://github.com/stack-of-tasks/pinocchio/blob/devel/.cmake-format.yaml

Last, did you know if gersemi is handling comment in a better way ? cmake-format was joining consecutive line together, make huge comment block.

We can do the custom command stuff later. Checking for this would require some more in-depth look at our own code so that gersemi can pick up definitions, or introduce stubs to tell gersemi how args should be formatted.

@jorisv jorisv merged commit 35e46bb into jrl-umi3218:master Oct 23, 2024
2 checks passed
@ManifoldFR ManifoldFR deleted the topic/gersemi branch October 23, 2024 10:03
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.

Switch from dead cmake-format project to gersemi for CMake formatting
3 participants