Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
65 changes: 40 additions & 25 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,46 +16,61 @@ on:
- '.github/dependabot.yml'
workflow_dispatch:

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
plugin_test:
name: asdf plugin test
name: asdf plugin test (${{ matrix.os }})
runs-on: ${{ matrix.os }}
defaults:
run:
shell: bash
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest, macos-15-intel]
tool:
- plugin: clang-format
command: clang-format --version
- plugin: clang-query
command: clang-query --version
- plugin: clang-tidy
command: clang-tidy --version
- plugin: clang-apply-replacements
command: clang-apply-replacements --version
version: ["11", "12", "13", "14", "15", "16", "17", "18", "19", "20", "21", "22"]
exclude:
# clang-apply-replacements-12_linux-amd64 is missing from upstream static-binaries
- os: ubuntu-latest
tool: { plugin: clang-apply-replacements, command: "clang-apply-replacements --version" }
version: "12"
os: [ubuntu-latest, ubuntu-24.04-arm, macos-latest, macos-15-intel]

steps:
- uses: actions/checkout@v6

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

- name: Add plugin ${{ matrix.tool.plugin }}
- name: Install and test all clang tools
run: |
asdf plugin add ${{ matrix.tool.plugin }} "$GITHUB_WORKSPACE"
tools=("clang-format" "clang-query" "clang-tidy" "clang-apply-replacements" "clang-include-cleaner")
cmds=("clang-format --version" "clang-query --version" "clang-tidy --version" "clang-apply-replacements --version" "clang-include-cleaner --version")
versions=("11" "14" "18" "22")
count=${#tools[@]}

- name: Install and test ${{ matrix.tool.plugin }} ${{ matrix.version }} on ${{ matrix.os }}
run: |
asdf install ${{ matrix.tool.plugin }} ${{ matrix.version }}
asdf set ${{ matrix.tool.plugin }} ${{ matrix.version }}
which ${{ matrix.tool.plugin }}
${{ matrix.tool.command }}
i=0
while [ "$i" -lt "$count" ]; do
plugin="${tools[$i]}"
cmd="${cmds[$i]}"

asdf plugin add "$plugin" "$GITHUB_WORKSPACE" 2>/dev/null || true

for version in "${versions[@]}"; do
# clang-include-cleaner is only available from version 18+
if [ "$plugin" = "clang-include-cleaner" ] && [ "$version" -lt 18 ] 2>/dev/null; then
continue
fi

echo ""
echo "========================================"
echo "Testing $plugin $version on ${{ matrix.os }}"
echo "========================================"

asdf install "$plugin" "$version"
asdf set "$plugin" "$version"
which "$plugin"
$cmd
done

i=$((i + 1))
done
env:
ASDF_CLANG_TOOLS_MACOS_DEQUARANTINE: 1
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ This is an asdf plugin for installing several clang tools:
- clang-tidy
- clang-query
- clang-apply-replacements
- clang-include-cleaner (version 18+)

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.

Expand All @@ -29,8 +30,9 @@ Clang versions **11** through **22** are supported.
- Pre-compiled binaries are provided for:
- Linux: `amd64` (`x86_64`), `arm64` (`aarch64`)
- macOS: `amd64` (Intel), `arm64` (Apple Silicon)
- Windows: `amd64` (`x86_64`)
- Windows: `amd64` (`x86_64`), `arm64` (`aarch64`)
- 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.
- `clang-include-cleaner` is only available from version 18 onward.

# Dependencies

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

Example:

Expand Down
1 change: 1 addition & 0 deletions bin/help.overview
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,6 @@ echo "- clang-format"
echo "- clang-tidy"
echo "- clang-query"
echo "- clang-apply-replacements"
echo "- clang-include-cleaner (version 18+)"
echo "See https://github.com/cpp-linter/asdf-clang-tools for more information"
echo
33 changes: 30 additions & 3 deletions lib/utils.bash
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,17 @@ validate_platform() {
esac
fi
;;
MINGW* | MSYS* | CYGWIN*)
USE_KERNEL=windows
case $arch in
x86_64)
USE_ARCH=amd64
;;
arm64 | aarch64)
USE_ARCH=arm64
;;
esac
;;
esac

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

download_release() {
local toolname version url
local toolname version url asset_pattern
toolname="$1"
version="$2"

validate_platform

# Windows assets have an .exe extension
if [ "$USE_KERNEL" = "windows" ]; then
asset_pattern="^${toolname}-${version}_${USE_PLATFORM}.exe\s"
else
asset_pattern="^${toolname}-${version}_${USE_PLATFORM}\s"
fi

# TODO: split output without piping to awk
url=$(fetch_all_assets |
grep "^${toolname}-${version}_${USE_PLATFORM}\s" |
grep "$asset_pattern" |
awk '{print $2}')

(
Expand Down Expand Up @@ -208,12 +226,21 @@ install_version() {

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

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

mkdir -p "${install_path}/bin" || true
ln -s "${asset_path}/${full_tool_cmd}" "$install_path/bin/$tool_cmd"
# Use cp on Windows where symlinks may not work
if [ "$USE_KERNEL" = "windows" ]; then
cp "${asset_path}/${full_tool_cmd}" "$install_path/bin/$tool_cmd"
else
ln -s "${asset_path}/${full_tool_cmd}" "$install_path/bin/$tool_cmd"
fi

if [ "$USE_KERNEL" == "macosx" ]; then
if [ "$ASDF_CLANG_TOOLS_MACOS_DEQUARANTINE" != 1 ]; then
Expand Down
Loading