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
103 changes: 87 additions & 16 deletions .github/workflows/binary-wheels.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,10 @@ name: Build and test binary wheels
# the commands outside an environment (and on Windows, away from the
# environment's other files).
#
# A repository that builds its binaries itself, instead of downloading them,
# builds them in an earlier job of the same workflow run and names those
# artifacts in `binaries-artifacts`; see include-what-you-use-wheel.
# A package that builds its binaries itself, instead of downloading them,
# gives the command in `binaries-command`: the first job runs it on each runner
# of `binaries-platforms`, and the wheel build reads the binaries from
# binaries/binary-<platform>/; see packages/include-what-you-use.
#
# The workflow uploads the wheels as the artifact `wheels`, and the files that
# `release-files-command` writes to release/ as the artifact `release-files`.
Expand Down Expand Up @@ -85,14 +86,26 @@ on:
type: string
required: false
default: ""
binaries-artifacts:
binaries-command:
description: >-
A name pattern of artifacts that earlier jobs of the calling
workflow run uploaded, e.g. binary-*, for a repository that builds
its binaries itself (include-what-you-use-wheel). Each matching
artifact is downloaded to binaries/<artifact name>/ before the
wheels are built, for the recipe to read. Empty means the recipe
downloads everything itself.
For a package that builds its binaries itself: the command that
builds them, for the platform in $PLATFORM, into
binaries/binary-<platform>/. It runs in `directory` on each runner
of `binaries-platforms` before the wheels are built. Empty means the
recipe downloads the binaries itself.
type: string
required: false
default: ""
binaries-platforms:
description: JSON list of {platform, runner} to run binaries-command on
type: string
required: false
default: "[]"
binaries-cache-key:
description: >-
The cache key of the binaries, e.g. a hash of everything that goes
into them; a platform whose binaries are in the cache is not built
again. Empty means no cache.
type: string
required: false
default: ""
Expand Down Expand Up @@ -161,8 +174,53 @@ on:
permissions: {}

jobs:
# Only for a package that builds its binaries itself (binaries-command).
binaries:
name: Build binaries ${{ matrix.platform }}
if: inputs.binaries-command != ''
runs-on: ${{ matrix.runner }}
permissions:
contents: read
strategy:
fail-fast: false
matrix:
include: ${{ fromJSON(inputs.binaries-platforms) }}
defaults:
run:
shell: bash
working-directory: ${{ inputs.directory }}
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
- name: Restore the binaries
id: cache
if: inputs.binaries-cache-key
uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
with:
path: ${{ inputs.directory }}/binaries/binary-${{ matrix.platform }}
key: ${{ inputs.binaries-cache-key }}-${{ matrix.platform }}
- name: Build the binaries
if: steps.cache.outputs.cache-hit != 'true'
env:
PLATFORM: ${{ matrix.platform }}
BINARIES_COMMAND: ${{ inputs.binaries-command }}
run: bash -euo pipefail -c "$BINARIES_COMMAND"
# The artifact holds binary-<platform>/, so that the build job can
# download them all into binaries/.
- uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2
with:
name: binaries${{ inputs.artifact-suffix }}-${{ matrix.platform }}
path: ${{ inputs.directory }}/binaries/
if-no-files-found: error

build:
name: Build wheels
needs: binaries
# After the binaries, or without them (skipped).
if: >-
!cancelled() &&
(needs.binaries.result == 'success' || needs.binaries.result == 'skipped')
runs-on: ubuntu-latest
permissions:
contents: read
Expand All @@ -189,11 +247,12 @@ jobs:
HATCH_PREBUILT: ${{ github.workspace }}/${{ inputs.hatch-prebuilt }}
# With the extra for recipes whose upstream signs its releases.
run: python -m pip install "$HATCH_PREBUILT[minisign]"
- name: Download the binaries built by the calling workflow
if: inputs.binaries-artifacts
- name: Download the binaries
if: inputs.binaries-command
uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8.0.2
with:
pattern: ${{ inputs.binaries-artifacts }}
pattern: binaries${{ inputs.artifact-suffix }}-*
merge-multiple: true
path: ${{ inputs.directory }}/binaries
# The inputs win; the recipe (hatch-prebuilt 0.3 or later) fills in the rest.
- name: Read the recipe
Expand Down Expand Up @@ -321,6 +380,8 @@ jobs:
test:
name: Test ${{ matrix.name }}
needs: build
# build runs even when binaries is skipped, which would skip this job.
if: ${{ !cancelled() && needs.build.result == 'success' }}
runs-on: ${{ matrix.os }}
permissions:
contents: read
Expand Down Expand Up @@ -385,6 +446,8 @@ jobs:
test-linux-containers:
name: Test ${{ matrix.name }}
needs: build
# build runs even when binaries is skipped, which would skip this job.
if: ${{ !cancelled() && needs.build.result == 'success' }}
runs-on: ${{ matrix.os }}
permissions:
contents: read
Expand Down Expand Up @@ -432,15 +495,23 @@ jobs:
all:
name: All wheels pass
if: always()
needs: [build, test, test-linux-containers]
needs: [binaries, build, test, test-linux-containers]
runs-on: ubuntu-latest
permissions: {}
steps:
- name: Check the results
env:
RESULTS: ${{ join(needs.*.result, ' ') }}
BINARIES: ${{ needs.binaries.result }}
RESULTS: >-
${{ needs.build.result }} ${{ needs.test.result }}
${{ needs.test-linux-containers.result }}
run: |
echo "Results: $RESULTS"
echo "Binaries: $BINARIES, wheels: $RESULTS"
# binaries is skipped for a package that downloads its binaries.
case "$BINARIES" in
success | skipped) ;;
*) echo "::error::Building the binaries did not pass: $BINARIES"; exit 1 ;;
esac
for result in $RESULTS; do
if [ "$result" != success ]; then
echo "::error::Not every job passed: $RESULTS"
Expand Down
3 changes: 3 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,9 @@ jobs:
containers: ${{ matrix.containers }}
msvc: ${{ matrix.msvc }}
release-files-command: ${{ matrix.release-files-command }}
binaries-command: ${{ matrix.binaries-command }}
binaries-platforms: ${{ matrix.binaries-platforms }}
binaries-cache-key: ${{ matrix.binaries-cache-key }}

# A package's [tool.wheels] extra-tests: build one version's wheel for the
# runner's platform and run the smoke test with more arguments, after a
Expand Down
3 changes: 3 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,9 @@ jobs:
containers: ${{ matrix.containers }}
msvc: ${{ matrix.msvc }}
release-files-command: ${{ matrix.release-files-command }}
binaries-command: ${{ matrix.binaries-command }}
binaries-platforms: ${{ matrix.binaries-platforms }}
binaries-cache-key: ${{ matrix.binaries-cache-key }}

# Attest the files, and on a release attach them to it before they are on
# PyPI.
Expand Down
5 changes: 5 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,11 @@ PATH="$PWD/.venv/bin:$PATH" .venv/bin/python tests/smoke_test.py --version "$(ca
A tool from anywhere else needs a recipe in `hatch_build.py` and `[tool.wheels]` settings for
its upstream, its version file and its platforms.

A tool whose upstream ships source code only also builds its binaries in CI: in
`[tool.wheels.binaries]`, `command` builds them for `$PLATFORM` into `binaries/binary-<platform>/`
on each runner of `platforms`, and the binaries are cached by the hash of `cache-files`. See
[`packages/include-what-you-use`](packages/include-what-you-use).

Before a new package merges, a maintainer adds a
[pending trusted publisher](https://pypi.org/manage/account/publishing/) on PyPI (and on
[TestPyPI](https://test.pypi.org/manage/account/publishing/)): owner `cpp-linter`, repository
Expand Down
5 changes: 2 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,20 +23,19 @@ clangd --version
| [clangd-bin](packages/clangd-bin) | clangd | [![PyPI](https://img.shields.io/pypi/v/clangd-bin?label=&labelColor=454a63&color=007ec6)](https://pypi.org/project/clangd-bin/) |
| [llvm-cov](packages/llvm-cov) | llvm-cov, llvm-profdata | [![PyPI](https://img.shields.io/pypi/v/llvm-cov?label=&labelColor=454a63&color=007ec6)](https://pypi.org/project/llvm-cov/) |

**Other tools**, repackaged unchanged from their upstream releases:
**Other tools**:

| Package | Tools | |
| --- | --- | --- |
| [ccache-bin](packages/ccache-bin) | ccache | [![PyPI](https://img.shields.io/pypi/v/ccache-bin?label=&labelColor=454a63&color=007ec6)](https://pypi.org/project/ccache-bin/) |
| [include-what-you-use](packages/include-what-you-use) | include-what-you-use, iwyu_tool.py, fix_includes.py | [![PyPI](https://img.shields.io/pypi/v/include-what-you-use?label=&labelColor=454a63&color=007ec6)](https://pypi.org/project/include-what-you-use/) |

**Build tooling**:

| Package | What it is | |
| --- | --- | --- |
| [hatch-prebuilt](packages/hatch-prebuilt) | The hatchling plugin that builds every wheel here from prebuilt binaries | [![PyPI](https://img.shields.io/pypi/v/hatch-prebuilt?label=&labelColor=454a63&color=007ec6)](https://pypi.org/project/hatch-prebuilt/) |

Moving here next: [include-what-you-use](https://github.com/cpp-linter/include-what-you-use-wheel).

Each package's releases are tagged `<package>-v<version>`: see
[the releases of clangd-bin](https://github.com/cpp-linter/wheels/releases?q=clangd-bin), for
example. Every wheel carries a build provenance attestation.
Expand Down
21 changes: 21 additions & 0 deletions packages/include-what-you-use/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2026 cpp-linter

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
129 changes: 129 additions & 0 deletions packages/include-what-you-use/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,129 @@
# include-what-you-use

[![PyPI](https://img.shields.io/pypi/v/include-what-you-use?labelColor=454a63&color=007ec6)](https://pypi.org/project/include-what-you-use/)
[![ci](https://img.shields.io/github/actions/workflow/status/cpp-linter/wheels/ci.yml?branch=main&label=ci&labelColor=454a63)](https://github.com/cpp-linter/wheels/actions/workflows/ci.yml)
[![part of cpp-linter](https://img.shields.io/badge/part%20of-cpp--linter-ffc20a?labelColor=454a63)](https://cpp-linter.github.io/)

[include-what-you-use](https://include-what-you-use.org) (IWYU), the tool that tells you which
`#include` lines a C or C++ file needs and which it does not, as Python wheels on PyPI. Upstream
publishes source code only; these wheels contain a ready-to-run binary with everything it needs.

[Website](https://cpp-linter.github.io/) ·
[PyPI](https://pypi.org/project/include-what-you-use/) ·
[IWYU documentation](https://github.com/include-what-you-use/include-what-you-use/tree/master/docs) ·
[Discussions](https://github.com/orgs/cpp-linter/discussions)

## Quick start

```bash
pip install include-what-you-use # or: uv tool install include-what-you-use
include-what-you-use --version
```

Run it on one file, with the flags you compile it with:

```bash
include-what-you-use -std=c++17 -Iinclude src/main.cpp
```

Or on a whole project, from its `compile_commands.json`, and apply the suggestions:

```bash
iwyu_tool.py -p build > iwyu.out
fix_includes.py < iwyu.out
```

With CMake, run it during the build:

```bash
cmake -B build -DCMAKE_CXX_INCLUDE_WHAT_YOU_USE=include-what-you-use
```

## What the wheel installs

| Command | What it runs |
|---|---|
| `include-what-you-use` | the IWYU binary (`include_what_you_use/data/bin/`) |
| `iwyu_tool.py`, `fix_includes.py` | the upstream helper scripts, with the environment's Python; `iwyu_tool.py` uses the binary of this wheel unless `IWYU_BINARY` is set |

Everything else stays together in the `include_what_you_use` package, under `data/`: clang's
builtin headers (`lib/clang/<LLVM major>/include/`, where the binary looks for them), the
upstream mapping files for `--mapping_file` (`share/include-what-you-use/*.imp`) and the man
page. So the commands work the same with `pip install`, `uv tool install` and `pip install
--user`, which put the commands in different places.

IWYU parses code the way clang does, so it needs clang's builtin headers next to it. Without them
it stops at the first standard header with `'stddef.h' file not found`. The wheel installs them
where the binary looks for them, so it works anywhere the wheel is installed.

## Supported platforms

| Platform | Architecture | Wheel tag |
|----------|--------------|-----------|
| **Linux** (glibc 2.17+ and musl) | x86_64 | `manylinux_2_17_x86_64.manylinux2014_x86_64.musllinux_1_1_x86_64` |
| **Linux** (glibc 2.17+ and musl) | aarch64 | `manylinux_2_17_aarch64.manylinux2014_aarch64.musllinux_1_1_aarch64` |
| **macOS** 11.0+ | Intel (x86_64) | `macosx_11_0_x86_64` |
| **macOS** 11.0+ | Apple Silicon (arm64) | `macosx_11_0_arm64` |
| **Windows** | x86_64 | `win_amd64` |
| **Windows** | ARM64 | `win_arm64` |

The Linux binaries are statically linked, so one wheel works on glibc and musl distributions. The
macOS binaries only use system libraries, and the Windows binaries link the C runtime statically.

## Versions

Every IWYU release is built against one LLVM version, so each wheel version holds one pair:

| Wheel | include-what-you-use | LLVM / clang |
|-------|----------------------|--------------|
| `0.27` | 0.27 | 23.1.6 |

The wheel version is the IWYU version. A packaging-only fix is released as `0.27.post1`.

The binaries on their own are attached to every
[release](https://github.com/cpp-linter/wheels/releases?q=include-what-you-use), with their
`SHA256SUMS`. They need clang's builtin headers in `../lib/clang/<LLVM major>/include` next to
them, for example from the `clang-resource-headers-<major>.tar.gz` of the matching
[static binaries release](https://github.com/cpp-linter/clang-tools-static-binaries/releases).

## How the binaries are built

[`iwyu_build.py`](iwyu_build.py) builds IWYU inside the LLVM source tree, with the flags that
[clang-tools-static-binaries](https://github.com/cpp-linter/clang-tools-static-binaries) uses
for clang-tidy. The sources are pinned in [`sources.json`](sources.json): the LLVM release
tarball by its sha256, IWYU by the commit of its release tag, and clang's builtin headers by their
sha512. CI builds every platform from source, checks that the binary needs no libraries a clean
machine may lack, and installs and tests every wheel before it is published, with the shared
workflows in [cpp-linter/wheels](https://github.com/cpp-linter/wheels). Every release carries
build provenance attestations for its wheels and binaries. A bot opens a pull request for every
new IWYU release, which merges and releases itself once the tests pass.

## Acknowledgements

[include-what-you-use](https://github.com/include-what-you-use/include-what-you-use) is written
by the include-what-you-use authors. This is not an official IWYU project, so report problems
with IWYU itself [upstream](https://github.com/include-what-you-use/include-what-you-use/issues).

## Contributing

This package lives in [cpp-linter/wheels](https://github.com/cpp-linter/wheels), with the other
C and C++ tools that cpp-linter packages as wheels.
[Open an issue](https://github.com/cpp-linter/wheels/issues) for packaging bugs and feature
requests, and see the [contributing guide](https://github.com/cpp-linter/wheels/blob/main/CONTRIBUTING.md)
for how the wheels are built and released. To build a wheel locally:

```bash
python iwyu_build.py # about an hour; needs CMake and a C++ compiler
python -m pip install --group build
python -m build --wheel
```

## License

The files in this directory are released under the
[MIT License](https://github.com/cpp-linter/wheels/blob/main/packages/include-what-you-use/LICENSE).
include-what-you-use is under the
[University of Illinois/NCSA Open Source License](https://github.com/include-what-you-use/include-what-you-use/blob/master/LICENSE.TXT),
and the binary also contains LLVM and clang, under the
[Apache License 2.0 with LLVM exceptions](https://llvm.org/LICENSE.txt). The wheels carry both
license files.
Loading
Loading