-
Notifications
You must be signed in to change notification settings - Fork 14.3k
[Windows] Add git-clang-format wrapper bat file #69228
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
Conversation
This allows git-clang-format to be used on a Windows terminal without manually needing to find the path and invoke the python interpreter. We have a similar script for `scan-build`.
@llvm/pr-subscribers-clang-format Author: Chris B (llvm-beanz) ChangesThis allows git-clang-format to be used on a Windows terminal without manually needing to find the path and invoke the python interpreter. We have a similar script for Full diff: https://github.com/llvm/llvm-project/pull/69228.diff 2 Files Affected:
diff --git a/clang/tools/clang-format/CMakeLists.txt b/clang/tools/clang-format/CMakeLists.txt
index 30c93f8667c8359..1c61a3c8fb80368 100644
--- a/clang/tools/clang-format/CMakeLists.txt
+++ b/clang/tools/clang-format/CMakeLists.txt
@@ -38,3 +38,9 @@ install(FILES clang-format.py
install(PROGRAMS git-clang-format
DESTINATION "${CMAKE_INSTALL_BINDIR}"
COMPONENT clang-format)
+
+if (WIN32 AND NOT CYGWIN)
+ install(PROGRAMS git-clang-format.bat
+ DESTINATION "${CMAKE_INSTALL_BINDIR}"
+ COMPONENT clang-format)
+endif()
diff --git a/clang/tools/clang-format/git-clang-format.bat b/clang/tools/clang-format/git-clang-format.bat
new file mode 100644
index 000000000000000..d4bc5172989cb09
--- /dev/null
+++ b/clang/tools/clang-format/git-clang-format.bat
@@ -0,0 +1 @@
+py -3 git-clang-format %*
|
Can you open an issue and link to it from here? It seems |
Filed #69643.
IIUC, |
@mydeveloperday what do you think? |
@@ -0,0 +1 @@ | |||
py -3 git-clang-format %* |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is py
? I have no program called py
on my machine (Windows with msys2), so you would possibly break that? Why not write python
or python3
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
py.exe
is the Windows python launcher. It comes with Python for Windows (not msys2 or cygwin where the shebang line would work). It is the Windows way of choosing which python version you want. You need to use this approach because the standard Python for Windows install always installs python.exe
regardless of version because Windows generally doesn't version binaries.
[1] Python for Windows docs
[2] Microsoft docs
I'm going to go take a long shower now to try and forget that I learned this much about Windows.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@llvm-beanz This doesn't seem to work if git-clang-format
is run from another directory:
C:\Users\Owen\llvm-project>clang\tools\clang-format\git-clang-format
C:\Users\Owen\llvm-project>py -3 git-clang-format
C:\Users\Owen\AppData\Local\Programs\Python\Python39\python.exe: can't open file 'C:\Users\Owen\llvm-project\git-clang-format': [Errno 2] No such file or directory
C:\Users\Owen\llvm-project>
I have no real opinion on this matter, as I don't use that program/script. But when it helps the windows users, why not? I also see no harm. |
Local branch amd-gfx b98ebf3 Merged main:c2f02e3bd6a5 into amd-gfx:f41124e56306 Remote branch main 7d7e4d2 [Windows] Add git-clang-format wrapper bat file (llvm#69228)
See #75268. |
This allows git-clang-format to be used on a Windows terminal without manually needing to find the path and invoke the python interpreter. We have a similar script for
scan-build
.Fixes #69643