Skip to main content

A C/C++ #include path normalizer that rewrites includes to resolve cleanly against a minimal -I set.

Project description

inclean

English | 简体中文

A C/C++ #include path normalizer.

Many legacy C/C++ libraries #include headers by bare filename (#include "bar.h") even though the actual header lives several directories deep (src/internal/bar.h). To consume such a library a caller must add every internal directory to their -I list — which pollutes their include namespace and breaks the library's encapsulation.

inclean does a one-shot, source-level normalization. It scans every source file in the library and rewrites each #include so it resolves cleanly against a small, explicit set of allowed include directories. After running inclean, consumers only -I the allowed directories.


Install

inclean is published to crates.io, PyPI, and as prebuilt binaries on GitHub Releases. Pick whichever ecosystem you already have on your machine.

Via PyPI (Python wheels — no Rust toolchain needed)

Three options:

uv tool install inclean      # isolated, fastest
pipx install inclean         # isolated
pip install inclean          # into the current environment

The wheels ship the native binary built by maturin; inclean lands on your PATH the same way ruff or uv do. Requires Python ≥ 3.8.

Via cargo

Two options:

cargo binstall inclean       # prebuilt binary from GitHub Releases (no compilation)
cargo install inclean        # build from crates.io

cargo binstall fetches inclean's binstall metadata from crates.io and downloads the matching prebuilt archive from this repo's GitHub Releases (no compilation). cargo binstall is a third-party cargo subcommand — install it first via cargo-bins/cargo-binstall if you don't already have it.

cargo install downloads the source from crates.io and compiles it locally.

Prebuilt binaries (no package manager)

Download a tarball for your platform from the latest GitHub Release and put inclean (or inclean.exe) on your PATH. Released targets:

  • x86_64-unknown-linux-gnu
  • aarch64-unknown-linux-gnu
  • x86_64-apple-darwin
  • aarch64-apple-darwin
  • x86_64-pc-windows-msvc

From repo source

Clone this repo and build from source:

git clone https://github.com/inaku-Gyan/inclean.git
cd inclean
cargo install --path .

Quick start

inclean is driven by an inclean.toml placed at the root of the library you want to clean up. A typical workflow:

inclean init                # write a documented starter inclean.toml
$EDITOR inclean.toml        # tell it where your headers live
inclean check               # dry-run: report every proposed change
inclean diff                # see the rewrites as a unified diff
inclean apply               # write the rewrites in place

Every command except explain takes an optional [DIR] argument — the directory containing the root inclean.toml. It defaults to ..

Example

Take a "flat" library where headers live at include/mylib/internal/foo.h but internal #includes use just the basename. The fixture under tests/fixtures/flat-library/ ships this config:

[project]
root = "."
version = "0.2.0"

[[rule]]
name = "base"
paths = ["src/**", "include/**"]
forms = ["quote"]
allowed_include_dirs = ["include"]
original_include_dirs = ["include/mylib/internal"]

A source line #include "foo.h" is rewritten to #include "mylib/internal/foo.h" — so the consumer only needs -Iinclude.

Commands

Command Purpose
inclean init [DIR] Generate a documented starter inclean.toml. Refuses to overwrite.
inclean check [DIR] [-l/--level LEVEL] Read-only check at one of three depths. Never writes.
inclean diff [DIR] Print a unified diff of every proposed rewrite.
inclean apply [DIR] Apply rewrites in place. Refuses if any rule-tree conflict is present.
inclean explain FILE [INCLUDE] Trace, layer-by-layer, which rule matches a given #include — debugging aid.
inclean schema [-o PATH] [--check] Emit the JSON Schema for inclean.toml (stdout by default).

inclean check runs at one of three levels (-l config | rules | full, default full). Each level is a strict superset of the previous; see docs/configuration.md for the full breakdown.

Editor support

inclean.toml ships with a JSON Schema for editor completion and validation. Editors that understand the #:schema directive (VS Code with Even Better TOML, Helix, Zed) automatically pick it up:

#:schema https://raw.githubusercontent.com/inaku-Gyan/inclean/v0.2.0/schemas/inclean.toml.schema.json

[project]
root = "."
version = "0.2.0"

inclean init writes both the #:schema line (for the editor) and the [project].version field (the CLI's own version gate), each pinned to the CLI version that generated the file. To upgrade schema validation, edit the v0.2.0 segment in the URL to a newer release tag; to always track the development schema, replace it with main (not recommended for shared repos — new fields will appear in the schema before your CLI knows about them).

#:schema and [project].version are independent. The #:schema URL is purely for editor tooling; the CLI reads only [project].version and compares it to its built-in MIN_SUPPORTED_INCLEAN_TOML_VERSION. inclean is pre-1.0 and does not ship migration shims for breaking schema changes — see CLAUDE.md.

You can also dump a local copy:

inclean schema --output inclean.toml.schema.json

Documentation

  • docs/configuration.md — full inclean.toml schema: the five-layer matching model, inheritance, @std.* constants, actions, placeholders, exit codes.
  • docs/architecture.md — code-level architecture: module map, pipeline phases, key invariants.
  • CONTRIBUTING.md — toolchain, dev workflow, conventions, scope.
  • CHANGELOG.md — release history.

Status

0.2.0 — current. Introduces JSON Schema generation, editor #:schema support, and a required [project].version field that the CLI uses as a hard version gate. inclean is pre-1.0 / beta and does not provide migration shims between breaking schema changes; see CLAUDE.md for the project policy.

License

BSD 3-Clause.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

inclean-0.2.0.tar.gz (103.3 kB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

inclean-0.2.0-py3-none-win_amd64.whl (1.6 MB view details)

Uploaded Python 3Windows x86-64

inclean-0.2.0-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (1.7 MB view details)

Uploaded Python 3manylinux: glibc 2.17+ x86-64

inclean-0.2.0-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (1.6 MB view details)

Uploaded Python 3manylinux: glibc 2.17+ ARM64

inclean-0.2.0-py3-none-macosx_11_0_arm64.whl (1.5 MB view details)

Uploaded Python 3macOS 11.0+ ARM64

inclean-0.2.0-py3-none-macosx_10_12_x86_64.whl (1.6 MB view details)

Uploaded Python 3macOS 10.12+ x86-64

File details

Details for the file inclean-0.2.0.tar.gz.

File metadata

  • Download URL: inclean-0.2.0.tar.gz
  • Upload date:
  • Size: 103.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for inclean-0.2.0.tar.gz
Algorithm Hash digest
SHA256 12e907b166eb7fe8885a7bc8e6d480cd5306707bd9a01d582d9f4a5f321eef2f
MD5 32f23f599dd9d163de37cae54b567207
BLAKE2b-256 b4b01fe8e939facf6ddf35843dcaff052b8d23da3de3ddbdc50a7290783e7896

See more details on using hashes here.

Provenance

The following attestation bundles were made for inclean-0.2.0.tar.gz:

Publisher: release.yml on inaku-Gyan/inclean

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file inclean-0.2.0-py3-none-win_amd64.whl.

File metadata

  • Download URL: inclean-0.2.0-py3-none-win_amd64.whl
  • Upload date:
  • Size: 1.6 MB
  • Tags: Python 3, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for inclean-0.2.0-py3-none-win_amd64.whl
Algorithm Hash digest
SHA256 842465e5eee160d5367e1ec2aed69913e408ae08701aeda59e39588b8d0b46df
MD5 7bbc9d9a283217fd8a87533a09c2812a
BLAKE2b-256 fb40c65ab9633ff19fb623977347c21db82c1ff8b6c79387b4c5e6d754cce10a

See more details on using hashes here.

Provenance

The following attestation bundles were made for inclean-0.2.0-py3-none-win_amd64.whl:

Publisher: release.yml on inaku-Gyan/inclean

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file inclean-0.2.0-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for inclean-0.2.0-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 d54553afd891e2c547e62337d7d10b963a8b8c4307c7c67d0157b04cea74ccd9
MD5 ad54c5ea8591edbe2b83e2a420652e5b
BLAKE2b-256 a8f600124b32996e588f8ad7c07e4e74bfbf2c4fa73eabe4842c9c9850d2e1a4

See more details on using hashes here.

Provenance

The following attestation bundles were made for inclean-0.2.0-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl:

Publisher: release.yml on inaku-Gyan/inclean

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file inclean-0.2.0-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for inclean-0.2.0-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 70cb2a221e85e0bd74e4381c290c4f964bd870f24feeeffacb0b5828c24411bb
MD5 66c0790d97e772ec5d122ef230bd8974
BLAKE2b-256 010e648b24698fc45735cafaf8fd52b64d175fa51851b96accab31c90f9515cf

See more details on using hashes here.

Provenance

The following attestation bundles were made for inclean-0.2.0-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl:

Publisher: release.yml on inaku-Gyan/inclean

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file inclean-0.2.0-py3-none-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for inclean-0.2.0-py3-none-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 f7b24e7f294f377484ca863a9764418a56eae945a8f15d7341bb46f21ce69f9d
MD5 991fbc728297384292cab179111dbf67
BLAKE2b-256 25017f2470c0269bbde153c67716afaf75327400dbd69f054e5bad34b81c7b38

See more details on using hashes here.

Provenance

The following attestation bundles were made for inclean-0.2.0-py3-none-macosx_11_0_arm64.whl:

Publisher: release.yml on inaku-Gyan/inclean

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file inclean-0.2.0-py3-none-macosx_10_12_x86_64.whl.

File metadata

File hashes

Hashes for inclean-0.2.0-py3-none-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 c7d0b49ee13a06cfb92d157bee8d7326dab91087f172cf298d10299866424443
MD5 f6c45e4f82de18065fbac1456b66a026
BLAKE2b-256 b53a1b1a8137264c4b400f76ea5f3836603aa9a32f0a2d7b40a4b48e6119b853

See more details on using hashes here.

Provenance

The following attestation bundles were made for inclean-0.2.0-py3-none-macosx_10_12_x86_64.whl:

Publisher: release.yml on inaku-Gyan/inclean

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page