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

Add ninja format #74

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open

Add ninja format #74

wants to merge 2 commits into from

Conversation

Yanis002
Copy link
Collaborator

@Yanis002 Yanis002 commented Feb 14, 2025

I'm not a ninja expert so lmk if there's a better way, also no idea if this works on Windows (actually I think it should work on Windows if I add sh in the command?)

@AetiasHax
Copy link
Collaborator

This could work on Windows, but only if MSYS/Cygwin is installed with the usual GNU commands. I think it would be better if we make ninja format run a new Python script which finds all files and formats them.

Using the clang-format wheel that pre-commit uses, I was able to run clang-format (in a hopefully platform-independent way) like this:

from clang_format import _get_executable
import subprocess

CLANG_FORMAT = _get_executable("clang-format")
subprocess.run(f'{CLANG_FORMAT} --help')

@AetiasHax
Copy link
Collaborator

AetiasHax commented Feb 16, 2025

Actually, we could just use the clang-format executable directly in configure.py. So an alternative solution could be to use the get_c_cpp_files function in configure.py to get a list of all files to format, then use the solution above to format each of them.

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