[clang] [Windows] Add git-clang-format wrapper bat file (PR #69228)

Chris B via cfe-commits cfe-commits at lists.llvm.org
Mon Oct 16 10:14:13 PDT 2023


https://github.com/llvm-beanz created https://github.com/llvm/llvm-project/pull/69228

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`.

>From 8d56f363230ff064fc3fba7d75c6713af8d64f66 Mon Sep 17 00:00:00 2001
From: Chris Bieneman <chris.bieneman at me.com>
Date: Mon, 16 Oct 2023 11:30:21 -0500
Subject: [PATCH] [Windows] Add git-clang-format wrapper bat file

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`.
---
 clang/tools/clang-format/CMakeLists.txt       | 6 ++++++
 clang/tools/clang-format/git-clang-format.bat | 1 +
 2 files changed, 7 insertions(+)
 create mode 100644 clang/tools/clang-format/git-clang-format.bat

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 %*



More information about the cfe-commits mailing list