Skip to content

Commit 4a92a3d

Browse files
authored
Make formatting work in MSYS2 (#1740)
Signed-off-by: Juan Cruz Viotti <jv@jviotti.com>
1 parent c55b344 commit 4a92a3d

File tree

2 files changed

+9
-13
lines changed

2 files changed

+9
-13
lines changed

.github/workflows/ci.yml

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -21,74 +21,62 @@ jobs:
2121
type: static
2222
shell: sh
2323
benchmark: macos/llvm
24-
format: true
2524
- os: macos-latest
2625
cc: clang
2726
cxx: clang++
2827
type: shared
2928
shell: sh
30-
format: true
3129
- os: macos-latest
3230
cc: gcc-13
3331
cxx: g++-13
3432
type: static
3533
shell: sh
36-
format: true
3734
benchmark: macos/gcc
3835
- os: ubuntu-latest
3936
cc: clang
4037
cxx: clang++
4138
type: static
4239
shell: sh
43-
format: true
4440
benchmark: linux/llvm
4541
- os: ubuntu-latest
4642
cc: gcc
4743
cxx: g++
4844
type: static
4945
shell: sh
50-
format: true
5146
benchmark: linux/gcc
5247
- os: ubuntu-latest
5348
cc: clang
5449
cxx: clang++
5550
type: shared
5651
shell: sh
57-
format: true
5852
- os: ubuntu-latest
5953
cc: gcc
6054
cxx: g++
6155
type: shared
6256
shell: sh
63-
format: true
6457
- os: windows-latest
6558
type: static
6659
shell: pwsh
67-
format: true
6860
benchmark: windows/msvc
6961
- os: windows-latest
7062
type: shared
7163
shell: pwsh
72-
format: true
7364
- os: windows-latest
7465
type: static
7566
shell: msys2 {0}
76-
format: false
7767

7868
# Sanitizers
7969
- os: ubuntu-latest
8070
cc: clang
8171
cxx: clang++
8272
type: static
8373
shell: sh
84-
format: false
8574
options: -DSOURCEMETA_CORE_ADDRESS_SANITIZER:BOOL=ON
8675
- os: ubuntu-latest
8776
cc: clang
8877
cxx: clang++
8978
type: static
9079
shell: sh
91-
format: false
9280
options: -DSOURCEMETA_CORE_UNDEFINED_SANITIZER:BOOL=ON
9381

9482
defaults:
@@ -138,7 +126,6 @@ jobs:
138126
-DCMAKE_COMPILE_WARNING_AS_ERROR:BOOL=ON
139127
${{ matrix.platform.options }}
140128
- run: cmake --build ./build --config Release --target clang_format_test
141-
if: matrix.platform.format
142129
- run: cmake --build ./build --config Release --parallel 4
143130
- run: >
144131
cmake --install ./build --prefix ./build/dist --config Release --verbose

cmake/common/targets/clang-format.cmake

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,19 @@ function(sourcemeta_target_clang_format_attempt_install)
77
# See https://pypi.org/project/clang-format/
88
set(CLANG_FORMAT_BINARY_VERSION "20.1.6")
99
set(CLANG_FORMAT_BINARY_Windows_AMD64 "clang_format-${CLANG_FORMAT_BINARY_VERSION}-py2.py3-none-win_amd64.whl")
10+
set(CLANG_FORMAT_BINARY_MSYS_x86_64 "clang_format-${CLANG_FORMAT_BINARY_VERSION}-py2.py3-none-win_amd64.whl")
1011
set(CLANG_FORMAT_BINARY_Darwin_arm64 "clang_format-${CLANG_FORMAT_BINARY_VERSION}-py2.py3-none-macosx_11_0_arm64.whl")
1112
set(CLANG_FORMAT_BINARY_Darwin_x86_64 "clang_format-${CLANG_FORMAT_BINARY_VERSION}-py2.py3-none-macosx_10_9_x86_64.whl")
1213
set(CLANG_FORMAT_BINARY_Linux_aarch64 "clang_format-${CLANG_FORMAT_BINARY_VERSION}-py2.py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl")
1314
set(CLANG_FORMAT_BINARY_Linux_x86_64 "clang_format-${CLANG_FORMAT_BINARY_VERSION}-py2.py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl")
1415
set(CLANG_FORMAT_BINARY_CHECKSUM_Windows_AMD64 "76/d0/2781f7699ce9ff1f5f9035d30cdb4c46f40b6acf191e0100543c289f46be")
16+
set(CLANG_FORMAT_BINARY_CHECKSUM_MSYS_x86_64 "76/d0/2781f7699ce9ff1f5f9035d30cdb4c46f40b6acf191e0100543c289f46be")
1517
set(CLANG_FORMAT_BINARY_CHECKSUM_Darwin_arm64 "fd/27/171dcef3288369bc0f7034307cebc6ea5d9a2b03d44e5cfa5a218f0e4f53")
1618
set(CLANG_FORMAT_BINARY_CHECKSUM_Darwin_x86_64 "ac/f7/01502ff0869985df8b47ae62cdace425f02dfcd61b463a046f873ad5d2e2")
1719
set(CLANG_FORMAT_BINARY_CHECKSUM_Linux_aarch64 "b1/51/2a0f401f5a5e27f97b8ebfed6ca9c4ccc2809cabafa2f97c7ac8e5b0d882")
1820
set(CLANG_FORMAT_BINARY_CHECKSUM_Linux_x86_64 "b9/5e/7713e11945fa8018589e37a60052a1b1a2485be2292fcf382d154231eab6")
1921
set(CLANG_FORMAT_BINARY_NAME_Windows_AMD64 "clang-format.exe")
22+
set(CLANG_FORMAT_BINARY_NAME_MSYS_x86_64 "clang-format.exe")
2023
set(CLANG_FORMAT_BINARY_NAME_Darwin_arm64 "clang-format")
2124
set(CLANG_FORMAT_BINARY_NAME_Darwin_x86_64 "clang-format")
2225
set(CLANG_FORMAT_BINARY_NAME_Linux_aarch64 "clang-format")
@@ -97,6 +100,12 @@ function(sourcemeta_target_clang_format)
97100
${SOURCEMETA_TARGET_CLANG_FORMAT_SOURCES})
98101

99102
set(CLANG_FORMAT_CONFIG "${CMAKE_CURRENT_FUNCTION_LIST_DIR}/clang-format.config")
103+
if(CMAKE_SYSTEM_NAME STREQUAL "MSYS")
104+
# Because `clang-format` is typically a Windows `.exe`, transform the path accordingly
105+
execute_process(COMMAND cygpath -w "${CLANG_FORMAT_CONFIG}"
106+
OUTPUT_VARIABLE CLANG_FORMAT_CONFIG OUTPUT_STRIP_TRAILING_WHITESPACE)
107+
endif()
108+
100109
if(CLANG_FORMAT_BIN)
101110
message(STATUS "Using `clang-format` from ${CLANG_FORMAT_BIN}")
102111
add_custom_target(clang_format

0 commit comments

Comments
 (0)