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.1.tar.gz (107.7 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.1-py3-none-win_amd64.whl (1.6 MB view details)

Uploaded Python 3Windows x86-64

inclean-0.2.1-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (1.8 MB view details)

Uploaded Python 3manylinux: glibc 2.17+ x86-64

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

Uploaded Python 3manylinux: glibc 2.17+ ARM64

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

Uploaded Python 3macOS 11.0+ ARM64

inclean-0.2.1-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.1.tar.gz.

File metadata

  • Download URL: inclean-0.2.1.tar.gz
  • Upload date:
  • Size: 107.7 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.1.tar.gz
Algorithm Hash digest
SHA256 2988941167f5f04421848cb2c5dc009fecc471ac1cfa808e2d55d615dd733a9b
MD5 1b3ae9af6eb9b0643201c07343bbaafb
BLAKE2b-256 7df97a4af3af3f453cc56e3ff3089c2f527283fdccc34b3bc2599a2163b53186

See more details on using hashes here.

Provenance

The following attestation bundles were made for inclean-0.2.1.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.1-py3-none-win_amd64.whl.

File metadata

  • Download URL: inclean-0.2.1-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.1-py3-none-win_amd64.whl
Algorithm Hash digest
SHA256 665cad15995d993949278191ee7089f1c7089aefaafbb22754bd2a76de280532
MD5 58269ed68390bc8b9d78c8fafdb939c9
BLAKE2b-256 d591da2ba60997ecd6c0e3e4ff24542f5bdf9a91d54d6fd64067c060477dfaff

See more details on using hashes here.

Provenance

The following attestation bundles were made for inclean-0.2.1-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.1-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for inclean-0.2.1-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 6ee66795aafb2009a1a032a2d720ea98cf2a7bab6134085c82beecb61b8ce5d8
MD5 77abeebedde0d985b80d5fd509f28fc9
BLAKE2b-256 8fa5868a5c011bee40ec37dcc1e0c9bb1683a3807a5223012f7ec733fc9085b7

See more details on using hashes here.

Provenance

The following attestation bundles were made for inclean-0.2.1-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.1-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for inclean-0.2.1-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 6dad4457495174e9c6572042141f935209310ac31bce393c20bddce1d3edc4dc
MD5 4810e6d82f3ff5a80f998293774ac8b4
BLAKE2b-256 15be3988422266608bc5d1f79468fe34c2058f31fb5c2716b07c938941aabb0c

See more details on using hashes here.

Provenance

The following attestation bundles were made for inclean-0.2.1-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.1-py3-none-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for inclean-0.2.1-py3-none-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 c5aba361aec5eedeac0a888e4cb8db69c9c03aae3fadac39e8cfd79f61cf2e99
MD5 1311b0c1c7cb4555a36da3c0b1b39b08
BLAKE2b-256 00682c9d4cafc35fb2e5ee9b674e401739de1c9943b5e3722dd4429225f9eb2f

See more details on using hashes here.

Provenance

The following attestation bundles were made for inclean-0.2.1-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.1-py3-none-macosx_10_12_x86_64.whl.

File metadata

File hashes

Hashes for inclean-0.2.1-py3-none-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 3ffcd3d519aeaa57515d21070be0782a97cc2dee5dc66417de32132a028549ab
MD5 14f1ee58888e815b6424a90d238acb73
BLAKE2b-256 93eba208e00d133104701a4ef9554ac88400af9034a92da889b473e3587f9e55

See more details on using hashes here.

Provenance

The following attestation bundles were made for inclean-0.2.1-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