Skip to content

Commit f394e9e

Browse files
authored
feat: support clang version 21 and macOS arm64 (#149)
* chore: Update supported Clang versions 21 and binary tag in configuration * chore: Update SHA512 checksums for clang-format-21 binaries * feat: Enhance installation logic for macOS architecture support and update tests * style: Refactor import statements and format platform string assignment for clarity
1 parent c84c198 commit f394e9e

12 files changed

+74
-23
lines changed

.github/workflows/test.yml

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -74,8 +74,8 @@ jobs:
7474
needs: [build]
7575
strategy:
7676
matrix:
77-
version: [ 9, 10, 11, 12, 12.0.1, 13, 14, 15, 16, 17, 18, 19, 20, 21 ]
78-
os: [ ubuntu-latest, macos-latest, windows-latest ]
77+
version: [ 11, 12, 12.0.1, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22 ]
78+
os: [ ubuntu-latest, macos-15-intel, macos-latest, windows-latest ]
7979
fail-fast: false
8080
runs-on: ${{ matrix.os }}
8181
steps:
@@ -101,12 +101,12 @@ jobs:
101101
- name: Show path of clang-tools binaries
102102
shell: bash
103103
run: |
104-
if [ "${{ matrix.version }}" = "15" -o "${{ matrix.version }}" = "16" ] && [ "${{ matrix.os }}" = "windows-latest" ]; then
104+
if [ "${{ matrix.version }}" = "15" -o "${{ matrix.version }}" = "16" ] && [ "${{ runner.os }}" = "Windows" ]; then
105105
which clang-format
106106
which clang-tidy
107107
which clang-query
108108
which clang-apply-replacements
109-
elif [ "${{ matrix.os }}" = "ubuntu-latest" ]; then
109+
elif [ "${{ runner.os }}" = "Linux" ] || [ "${{ runner.os }}" = "macOS" ]; then
110110
which "clang-format-${{ matrix.version }}"
111111
which "clang-tidy-${{ matrix.version }}"
112112
which "clang-query-${{ matrix.version }}"
@@ -118,7 +118,7 @@ jobs:
118118
shell: bash
119119
run: |
120120
case "${{ matrix.version }}" in
121-
15|16|18|20|21)
121+
15|16|18|20|21|22)
122122
clang-format.exe --version
123123
clang-tidy.exe --version
124124
clang-query.exe --version
@@ -133,9 +133,9 @@ jobs:
133133
esac
134134
135135
- name: Check clang-tools binaries on Unix
136-
if: matrix.os == 'ubuntu-latest' || matrix.os == 'macos-latest'
136+
if: runner.os == 'Linux' || runner.os == 'macOS'
137137
run: |
138-
if [ "${{ matrix.version }}" = "12.0.1" -a "${{ matrix.os }}" = "ubuntu-latest" ]; then
138+
if [ "${{ matrix.version }}" = "12.0.1" -a "${{ runner.os }}" = "Linux" ]; then
139139
clang-format-12.0.1 --version
140140
clang-tidy-12.0.1 --version
141141
clang-query-12.0.1 --version

README.rst

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -168,12 +168,12 @@ clang tools binaries
168168
The following table shows the supported versions of clang-format, clang-tidy, clang-query, and clang-apply-replacements binaries for each platform:
169169

170170
.. csv-table::
171-
:header: "Platform", "21", "20", "19", "18", "17", "16", "15", "14", "13", "12", "11", "10", "9"
171+
:header: "Platform", "22", "21", "20", "19", "18", "17", "16", "15", "14", "13", "12", "11"
172172
:stub-columns: 1
173173

174-
Linux,✔️,✔️,✔️,✔️,✔️,✔️,✔️,✔️,✔️,✔️,✔️,✔️,✔️
175-
Windows,✔️,✔️,✔️,✔️,✔️,✔️,✔️,✔️,✔️,✔️,✔️,✔️,✔️
176-
macOS,✔️,✔️,✔️,✔️,✔️,✔️,✔️,✔️,✔️,✔️,✔️,✔️,✔️
174+
Linux,✔️,✔️,✔️,✔️,✔️,✔️,✔️,✔️,✔️,✔️,✔️,✔️
175+
Windows,✔️,✔️,✔️,✔️,✔️,✔️,✔️,✔️,✔️,✔️,✔️,✔️
176+
macOS,✔️,✔️,✔️,✔️,✔️,✔️,✔️,✔️,✔️,✔️,✔️,✔️
177177

178178
For more details, visit the `clang-tools-static-binaries <https://github.com/cpp-linter/clang-tools-static-binaries>`_ repository.
179179

clang_tools/__init__.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,16 @@
11
"""The clang-tools package's base module."""
22

33
import os
4-
from .util import check_install_os
4+
from .util import check_install_arch, check_install_os
55

66

77
RESET_COLOR = "\033[0m"
88
YELLOW = "\033[93m"
99
install_os = check_install_os()
10+
install_arch = check_install_arch()
1011
suffix = ".exe" if install_os == "windows" else ""
1112

1213
binary_repo = os.getenv(
1314
"CLANG_TOOLS_REPO", "https://github.com/cpp-linter/clang-tools-static-binaries"
1415
)
15-
binary_tag = os.getenv("CLANG_TOOLS_TAG", "master-6e612956")
16+
binary_tag = os.getenv("CLANG_TOOLS_TAG", "master-63858060")

clang_tools/install.py

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,15 @@
1313
import sys
1414
from typing import Optional, cast
1515

16-
from . import binary_repo, binary_tag, install_os, RESET_COLOR, suffix, YELLOW
16+
from . import (
17+
binary_repo,
18+
binary_tag,
19+
install_arch,
20+
install_os,
21+
RESET_COLOR,
22+
suffix,
23+
YELLOW,
24+
)
1725
from .util import download_file, verify_sha512, get_sha_checksum, Version
1826

1927

@@ -73,7 +81,13 @@ def clang_tools_binary_url(tool: str, version: str) -> str:
7381
:returns: The URL used to download the specified tool.
7482
"""
7583
base_url = f"{binary_repo}/releases/download/" + binary_tag
76-
download_url = f"{base_url}/{tool}-{version}_{install_os}-amd64{suffix}"
84+
if install_os == "macosx":
85+
platform_str = (
86+
"macosx-arm64" if install_arch == "arm64" else "macos-intel-amd64"
87+
)
88+
else:
89+
platform_str = f"{install_os}-amd64"
90+
download_url = f"{base_url}/{tool}-{version}_{platform_str}{suffix}"
7791
return download_url.replace(" ", "")
7892

7993

clang_tools/util.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,17 @@
1414
from http.client import HTTPResponse
1515

1616

17+
def check_install_arch() -> str:
18+
"""Identify the CPU architecture.
19+
20+
:returns: ``"arm64"`` for ARM processors, ``"amd64"`` otherwise.
21+
"""
22+
machine = platform.machine().lower()
23+
if machine in ("arm64", "aarch64"):
24+
return "arm64"
25+
return "amd64"
26+
27+
1728
def check_install_os() -> str:
1829
"""Identify this Operating System.
1930
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
c399d13b5cd5b7cb718773009ec656cf1e402e6a95eb931b5db0cc71235fa18e6fcfe63519393d977d0457de1737f5c9f5a7d6cff57eb1e678780b85768d67b7 clang-format-21_linux-amd64
1+
d108785107539ada648fbe2569dd1454661df9f6c7b200b75e7a19f0cbaee283f2f64e4abc5513ccb5822d4f02a1b3e7b14f21cd106a2f301384fbeda1d60591 clang-format-21_linux-amd64
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
bffb86ca1278b0fe316eeac4955dc8847f8589c09dad683ae58107ddcc08b978b0fbfe551eb71918c146ca83dc17f6e309b957716f0ed3795c785cec9b213055 clang-format-21_macos-intel-amd64

tests/clang-format-21_macosx-amd64.sha512sum

Lines changed: 0 additions & 1 deletion
This file was deleted.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
205860a9e39d9145444e6fcd356efd03d5b8051ed65b3a834f9688b4d38477cb38c1689eca5b5d8a465770fd7437ff7052b53c08b25bc5e2cecb118d6fcb5f57 clang-format-21_macosx-arm64
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
40c290a38318fcaa28c83bc86fb8f465f1c748f7f93405ec19653fe99e58b54d71eab228065be36b7bd031dd63a8ed595ff6a909a883f06cad9300b6cb632a2e *clang-format-21_windows-amd64
1+
39ff0df4cbb2f4b198e8ce1717765fd594809f394c05391cf1591a0e20e49e136c6f332ce37c660c99c9f5561b38d6579d680e797587267a789e3b84aa0328c7 *clang-format-21_windows-amd64

0 commit comments

Comments
 (0)