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

Uploaded Python 3Windows x86-64

inclean-0.2.2-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.2-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (1.6 MB view details)

Uploaded Python 3manylinux: glibc 2.17+ ARM64

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

Uploaded Python 3macOS 11.0+ ARM64

inclean-0.2.2-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.2.tar.gz.

File metadata

  • Download URL: inclean-0.2.2.tar.gz
  • Upload date:
  • Size: 107.6 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.2.tar.gz
Algorithm Hash digest
SHA256 e954938187bd1757254c6102a55b2201f6c2278d81327b5efe9875a1c01bb5b3
MD5 3d8a351ddb893e25548901e77b0c7a40
BLAKE2b-256 c23776798ea6caffd22ebffb33e600a2bd3824253c81b8902ccca205fabaad36

See more details on using hashes here.

Provenance

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

File metadata

  • Download URL: inclean-0.2.2-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.2-py3-none-win_amd64.whl
Algorithm Hash digest
SHA256 080c43b1e96650288f95070b8c0fa1fd171512d6fe07daf7b9d699269822e15e
MD5 af5fce6cc7e41d7f9864aa4764988617
BLAKE2b-256 6ca5edf03d066449b07a41e62f04930fba90939f3ef3109275ba5c6eae558d01

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for inclean-0.2.2-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 202ea29d54e3500e59517eb84a74622348aaf21fde702c4d565b58f92ca1b8cb
MD5 ef34031b14e6493b1672fb7b7a29c7a9
BLAKE2b-256 f7a7d9d67f84b9efd3ee607763518b723fb5113780af5c1197291c8f3dc422eb

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for inclean-0.2.2-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 c8921199c838f1afcd1e543213fd63c65169047a2743ac27e0d956b79046ff5d
MD5 8b4db92a1d0faa11fa76add292082170
BLAKE2b-256 dba79be19d80e3614970ee4b018e4d31735cdecd86d797af0e96d682a46cc86e

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for inclean-0.2.2-py3-none-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 d1d808d9c4fc7901f3daa7f403164555f8a0da4582bb1f2bfef04c43fa3abfc1
MD5 ba141920fd42093379bb60111dc710d0
BLAKE2b-256 01d149b95fd9cd6566ac1738aa202ac5039943c000294c555e6fd9ae038e0c50

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for inclean-0.2.2-py3-none-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 68fe762891e8b2a8077c6359be2eac30f4def2dbfada7ace8514cfd6711ddbb0
MD5 b0da8fdf2cad2a318301726094206b80
BLAKE2b-256 d967a74a636a67d070a83981332c1a70a10d50b8315cf757b7931b451b1f1f4e

See more details on using hashes here.

Provenance

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