Skip to content

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