Skip to content

Commit 81a60fb

Browse files
authored
feat: add Windows ARM support and clang-include-cleaner tool (#42)
* feat: add Windows ARM support and clang-include-cleaner tool - Add Windows platform detection (MINGW*/MSYS*/CYGWIN*) with amd64 and arm64 architecture support - Handle .exe extension for Windows binary assets in download and install steps - Add clang-include-cleaner as a supported tool (version 18+) - Update README and help overview with new platform and tool * ci: add windows runner and clang-include-cleaner to test matrix - Add windows-latest to OS matrix with shell: bash default - Add clang-include-cleaner as test tool, excluding versions < 18 - Use cp instead of ln -s on Windows (symlinks often fail in Git Bash) * ci: remove clang-apply-replacements-12 linux-amd64 exclusion The missing binary issue in upstream static-binaries has been fixed. * ci: remove windows-latest from CI matrix asdf-vm/actions/setup does not support Windows runners. The Windows platform detection code in utils.bash remains for users who set up asdf manually on Git Bash/MSYS2. * ci: add Linux ARM64 test job Add a targeted plugin_test_arm job on ubuntu-24.04-arm testing all 5 tools at versions 11, 18, and 22. Keeps the main x86_64 matrix unchanged to avoid CI bloat. * ci: add concurrency control to cancel in-progress builds When new code is pushed to the same branch/PR, cancel any previous in-progress workflow runs to save CI resources. * ci: simplify ARM test - just add runner to existing matrix Replace duplicate plugin_test_arm job with a single os entry in the main matrix. * ci: restructure to sequential per-runner testing Replace the Cartesian matrix (212 jobs) with 4 sequential jobs, one per OS. Each runner loops through all 5 tools at versions 11, 14, 18, 22 in a single bash script, greatly reducing scheduling overhead and total wait time.
1 parent febd8a7 commit 81a60fb

4 files changed

Lines changed: 75 additions & 29 deletions

File tree

.github/workflows/build.yml

Lines changed: 40 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -16,46 +16,61 @@ on:
1616
- '.github/dependabot.yml'
1717
workflow_dispatch:
1818

19+
concurrency:
20+
group: ${{ github.workflow }}-${{ github.ref }}
21+
cancel-in-progress: true
22+
1923
jobs:
2024
plugin_test:
21-
name: asdf plugin test
25+
name: asdf plugin test (${{ matrix.os }})
2226
runs-on: ${{ matrix.os }}
27+
defaults:
28+
run:
29+
shell: bash
2330
strategy:
2431
fail-fast: false
2532
matrix:
26-
os: [ubuntu-latest, macos-latest, macos-15-intel]
27-
tool:
28-
- plugin: clang-format
29-
command: clang-format --version
30-
- plugin: clang-query
31-
command: clang-query --version
32-
- plugin: clang-tidy
33-
command: clang-tidy --version
34-
- plugin: clang-apply-replacements
35-
command: clang-apply-replacements --version
36-
version: ["11", "12", "13", "14", "15", "16", "17", "18", "19", "20", "21", "22"]
37-
exclude:
38-
# clang-apply-replacements-12_linux-amd64 is missing from upstream static-binaries
39-
- os: ubuntu-latest
40-
tool: { plugin: clang-apply-replacements, command: "clang-apply-replacements --version" }
41-
version: "12"
33+
os: [ubuntu-latest, ubuntu-24.04-arm, macos-latest, macos-15-intel]
4234

4335
steps:
4436
- uses: actions/checkout@v6
4537

4638
- name: Install asdf
4739
uses: asdf-vm/actions/setup@v4
4840

49-
- name: Add plugin ${{ matrix.tool.plugin }}
41+
- name: Install and test all clang tools
5042
run: |
51-
asdf plugin add ${{ matrix.tool.plugin }} "$GITHUB_WORKSPACE"
43+
tools=("clang-format" "clang-query" "clang-tidy" "clang-apply-replacements" "clang-include-cleaner")
44+
cmds=("clang-format --version" "clang-query --version" "clang-tidy --version" "clang-apply-replacements --version" "clang-include-cleaner --version")
45+
versions=("11" "14" "18" "22")
46+
count=${#tools[@]}
5247
53-
- name: Install and test ${{ matrix.tool.plugin }} ${{ matrix.version }} on ${{ matrix.os }}
54-
run: |
55-
asdf install ${{ matrix.tool.plugin }} ${{ matrix.version }}
56-
asdf set ${{ matrix.tool.plugin }} ${{ matrix.version }}
57-
which ${{ matrix.tool.plugin }}
58-
${{ matrix.tool.command }}
48+
i=0
49+
while [ "$i" -lt "$count" ]; do
50+
plugin="${tools[$i]}"
51+
cmd="${cmds[$i]}"
52+
53+
asdf plugin add "$plugin" "$GITHUB_WORKSPACE" 2>/dev/null || true
54+
55+
for version in "${versions[@]}"; do
56+
# clang-include-cleaner is only available from version 18+
57+
if [ "$plugin" = "clang-include-cleaner" ] && [ "$version" -lt 18 ] 2>/dev/null; then
58+
continue
59+
fi
60+
61+
echo ""
62+
echo "========================================"
63+
echo "Testing $plugin $version on ${{ matrix.os }}"
64+
echo "========================================"
65+
66+
asdf install "$plugin" "$version"
67+
asdf set "$plugin" "$version"
68+
which "$plugin"
69+
$cmd
70+
done
71+
72+
i=$((i + 1))
73+
done
5974
env:
6075
ASDF_CLANG_TOOLS_MACOS_DEQUARANTINE: 1
6176
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

README.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ This is an asdf plugin for installing several clang tools:
1616
- clang-tidy
1717
- clang-query
1818
- clang-apply-replacements
19+
- clang-include-cleaner (version 18+)
1920

2021
This plugin uses the pre-compiled binaries from the very handy [cpp-linter/clang-tools-static-binaries](https://github.com/cpp-linter/clang-tools-static-binaries) repo.
2122

@@ -29,8 +30,9 @@ Clang versions **11** through **22** are supported.
2930
- Pre-compiled binaries are provided for:
3031
- Linux: `amd64` (`x86_64`), `arm64` (`aarch64`)
3132
- macOS: `amd64` (Intel), `arm64` (Apple Silicon)
32-
- Windows: `amd64` (`x86_64`)
33+
- Windows: `amd64` (`x86_64`), `arm64` (`aarch64`)
3334
- Signed binaries are not provided for macOS. This plugin will offer to de-quarantine the binaries for you, but please make sure you understand the consequences.
35+
- `clang-include-cleaner` is only available from version 18 onward.
3436

3537
# Dependencies
3638

@@ -47,6 +49,7 @@ Plugin:
4749
| clang-query | `asdf plugin add clang-query https://github.com/cpp-linter/asdf-clang-tools.git` |
4850
| clang-tidy | `asdf plugin add clang-tidy https://github.com/cpp-linter/asdf-clang-tools.git` |
4951
| clang-apply-replacements | `asdf plugin add clang-apply-replacements https://github.com/cpp-linter/asdf-clang-tools.git` |
52+
| clang-include-cleaner | `asdf plugin add clang-include-cleaner https://github.com/cpp-linter/asdf-clang-tools.git` |
5053

5154
Example:
5255

bin/help.overview

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,6 @@ echo "- clang-format"
55
echo "- clang-tidy"
66
echo "- clang-query"
77
echo "- clang-apply-replacements"
8+
echo "- clang-include-cleaner (version 18+)"
89
echo "See https://github.com/cpp-linter/asdf-clang-tools for more information"
910
echo

lib/utils.bash

Lines changed: 30 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,17 @@ validate_platform() {
114114
esac
115115
fi
116116
;;
117+
MINGW* | MSYS* | CYGWIN*)
118+
USE_KERNEL=windows
119+
case $arch in
120+
x86_64)
121+
USE_ARCH=amd64
122+
;;
123+
arm64 | aarch64)
124+
USE_ARCH=arm64
125+
;;
126+
esac
127+
;;
117128
esac
118129

119130
if [ -z "${USE_KERNEL}" ] || [ -z "${USE_ARCH}" ]; then
@@ -143,15 +154,22 @@ list_all_versions() {
143154
}
144155

145156
download_release() {
146-
local toolname version url
157+
local toolname version url asset_pattern
147158
toolname="$1"
148159
version="$2"
149160

150161
validate_platform
151162

163+
# Windows assets have an .exe extension
164+
if [ "$USE_KERNEL" = "windows" ]; then
165+
asset_pattern="^${toolname}-${version}_${USE_PLATFORM}.exe\s"
166+
else
167+
asset_pattern="^${toolname}-${version}_${USE_PLATFORM}\s"
168+
fi
169+
152170
# TODO: split output without piping to awk
153171
url=$(fetch_all_assets |
154-
grep "^${toolname}-${version}_${USE_PLATFORM}\s" |
172+
grep "$asset_pattern" |
155173
awk '{print $2}')
156174

157175
(
@@ -208,12 +226,21 @@ install_version() {
208226

209227
# TODO: detect this instead of hard-coding in case the format changes?
210228
full_tool_cmd=${toolname}-${version}_${USE_PLATFORM}
229+
# Windows assets have an .exe extension
230+
if [ "$USE_KERNEL" = "windows" ]; then
231+
full_tool_cmd="${full_tool_cmd}.exe"
232+
fi
211233
tool_cmd="$(echo "$toolname" | cut -d' ' -f1)"
212234

213235
chmod +x "${asset_path}/${full_tool_cmd}"
214236

215237
mkdir -p "${install_path}/bin" || true
216-
ln -s "${asset_path}/${full_tool_cmd}" "$install_path/bin/$tool_cmd"
238+
# Use cp on Windows where symlinks may not work
239+
if [ "$USE_KERNEL" = "windows" ]; then
240+
cp "${asset_path}/${full_tool_cmd}" "$install_path/bin/$tool_cmd"
241+
else
242+
ln -s "${asset_path}/${full_tool_cmd}" "$install_path/bin/$tool_cmd"
243+
fi
217244

218245
if [ "$USE_KERNEL" == "macosx" ]; then
219246
if [ "$ASDF_CLANG_TOOLS_MACOS_DEQUARANTINE" != 1 ]; then

0 commit comments

Comments
 (0)