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

check / diff / apply optionally take [PATHS...] to restrict which files are processed; with no paths they consider every source file under the project root. -c PATH overrides the upward inclean.toml walk; -j N sets the worker thread count.

Example

A simple replace-action config that rewrites #include "foo.h" to #include "lib/foo.h":

[project]
root = "."
version = "0.3.0"
min_inclean_version = "0.3.0"

[[rule]]
name = "lib-prefix"
file_paths = ["src/**/*"]
include_match = ["foo.h", "bar.h"]
action = { type = "replace", with = "lib/${original}" }

See tests/golden_tests/ for runnable end-to-end examples.

Commands

Command Purpose
inclean init [PATH] Generate a documented starter inclean.toml. Alias of inclean config new.
inclean check [SUBCOMMAND] Read-only check. Subcommands: config validates the file alone (-c PATH); unfixable runs the full pipeline and reports only unfixable violations; all runs the full pipeline and reports every per-include outcome. Bare inclean check is equivalent to inclean check all. The full forms accept [-c PATH] [-j N] [PATHS...].
inclean diff [-o PATH] [-c PATH] [-j N] [PATHS...] Print a unified diff of every proposed rewrite. Optional -o writes to a file instead of stdout.
inclean apply [-c PATH] [-j N] [PATHS...] Apply rewrites in place. Files free of unfixable violations are written; files with errors / conflicts / evaluation failures are skipped and reported at end.
inclean config check [-c PATH] Alias of inclean check config.
inclean config new [PATH] Alias of inclean init.
inclean config schema [-o PATH] [--check] Emit / validate the JSON Schema for inclean.toml. --check requires -o and exits non-zero if the file drifts.

The default action when no rule specifies one is keep with output_form = preserve — a rule that omits action is a no-op.

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.3.0/schemas/inclean.toml.schema.json

[project]
root = "."
version = "0.3.0"
min_inclean_version = "0.3.0"

inclean init writes both the #:schema line (for the editor) and the [project].version + [project].min_inclean_version fields, each pinned to the CLI version that generated the file. To upgrade schema validation, edit the v0.3.0 segment in the URL to a newer release tag.

#:schema and the [project] version fields are independent. The #:schema URL is purely for editor tooling; the CLI runs its own two-direction compatibility check (CLI_COMPAT_MIN <= cfg.version AND cfg.min_inclean_version <= CLI_CURRENT). 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 four-layer matching model, copied_from copy semantics, @std.* constants, six action variants, ${copied} and other 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.3.0 — current. Reshapes the configuration around copied_from (a single-level transitive copy that replaces extends AND-merge), 4-layer matching (file_paths / file_suffixes / match_forms / include_match), six action variants (resolve / replace / keep / remove / comment_out / error), suppression_comments_regex off-limits regions, a new trailing_comment.transform model, and conflict-detection by final-line text rather than rule-tree invariants. The CLI gains check unfixable, check all, [PATHS...] filtering, and a unified-diff output via inclean diff -o. 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.3.0a1.tar.gz (107.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.3.0a1-py3-none-win_amd64.whl (1.6 MB view details)

Uploaded Python 3Windows x86-64

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

Uploaded Python 3manylinux: glibc 2.17+ ARM64

inclean-0.3.0a1-py3-none-macosx_11_0_arm64.whl (1.6 MB view details)

Uploaded Python 3macOS 11.0+ ARM64

inclean-0.3.0a1-py3-none-macosx_10_12_x86_64.whl (1.7 MB view details)

Uploaded Python 3macOS 10.12+ x86-64

File details

Details for the file inclean-0.3.0a1.tar.gz.

File metadata

  • Download URL: inclean-0.3.0a1.tar.gz
  • Upload date:
  • Size: 107.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.3.0a1.tar.gz
Algorithm Hash digest
SHA256 bd53786698171c6ad13824c0ff82404ae6d16d8386c2685df4a006929714000d
MD5 64c5d3d6c78b455f1856cd25741faf8e
BLAKE2b-256 0625cdaeee16f90bc6b9b1451587688dcdbce27bcba362baac83db88e8bb0ce7

See more details on using hashes here.

Provenance

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

File metadata

  • Download URL: inclean-0.3.0a1-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.3.0a1-py3-none-win_amd64.whl
Algorithm Hash digest
SHA256 2aae3a92dab2aa2e684229d43adfaddd351766ff66853fbe8fcfcc50c7d4a2f8
MD5 c8dae8b26741dfc53bdc8f85fe202673
BLAKE2b-256 b3dccd0870d768ac19116553144a23d90d1cc90a2e63b3ee6067007670450758

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for inclean-0.3.0a1-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 dd17ef432c538a34d85567ca9c1fbbf3d76e6170721619d34c2babfe963889a6
MD5 121454603ff803106025106b44d42c2e
BLAKE2b-256 c3cca5f6795a9978f2ce762b6a6587b06f11a8ea0f52e6b1d83a3dfa05b0ca08

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for inclean-0.3.0a1-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 458e96bc3d5da83ddd14a622101514c215f6a8dde3b2dbe86c328e73d2cdd033
MD5 a01a143351f4390b35db4a773cdd1c7f
BLAKE2b-256 b8fb1b57a8ad0ea9b8426dac81422fffd8d3a51840cb177e115142bcc8be6f3e

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for inclean-0.3.0a1-py3-none-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 3a865bb05033ea0c3dd32dceb0b2d87b4f78d039d3db2012eb5dc03c98ad3041
MD5 8bcde808d12c3b59215e88f0fb33df1d
BLAKE2b-256 107ed3e4c96f0786cc242107a8fc2b46e1f3b7592da2b309431b0db90ba695a4

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for inclean-0.3.0a1-py3-none-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 13ec286604e9a901bf5a823329bcbcbec5699c83f3c7b60781c83b6c6f1e71f2
MD5 fbb23d10156a6d949871c7bed9385515
BLAKE2b-256 a2c51358dbfea880f7313ced197c9c871e9fd5862a723f55df85789e0b2c8519

See more details on using hashes here.

Provenance

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