Skip to content

msqr1/importizer

Repository files navigation

importizer

Are you looking to convert your header-based C++ codebase to C++20 modules, but afraid that modularizing is too cumbersome? importizer is here to help.

And by modularization I don’t mean exposing a module interface & wrapping headers. I mean native modules a.k.a using modules internally.

This project uses semantic versioning.

Note: This project is currently going through a complete rewrite using Clang LibTooling to replace Regex (pre-2.0.0). Much pre-2.0.0 code are gone, but releases & git history are preserved.

Why native C++ modules?

  • Improved compilation time: Modules don’t need to be recompiled every time it is imported, unlike headers.

  • Improved encapsulation: Modules allow you to choose what is exposed to users (exported), no need to hide stuff with a detail namespace. Includes & macros from a module will only stay in that module.

  • arewemodulesyet.org

Prebuilt binaries

Importizer provides pre-compiled binaries for major operating systems. Necessary shared libraries are bundled directly in the distribution archive.

Linux macOS Windows

Architecture

AMD64, ARM64

Minimum OS

None

MacOS 14+

Windows 10+

Format (release)

zst(bin)

Format (debug)

tzst(trampoline + bin + .so)

tzst(bin + .dylib)

tzst(bin + .dll)

  • Stable release: Download optimized release builds from the releases page.

  • Bleeding edge (debug): Download unoptimized builds from the Continuous release. Useful for testing latest features or reporting bugs.

Configuration & usage

Importizer primarily uses a TOML configuration file, complemented by a few command-line options.

Command-line interface (CLI)

By default, running importizer looks for an importizer.toml file in the current working directory. You can override this by passing the path as a positional argument: importizer path/to/configuration.toml.

Option Description

-h, --help

Display available options.

--help-list

Display list of available options.

--version

Display version.

-o, --outDir

Override the output directory specified in the configuration file

Configuration file (TOML)

All relative paths in the configuration file are resolved relative to the file’s location, not the current working directory.

Option Type Description

inDir

String

Required. The directory containing the source code to process.

outDir

String

Required (unless provided via CLI). The directory for the modularized output.

compilationDb

String

Highly Recommended. Path to a compile_commands.json compilation database to provide context.

Bootstrap mode

For projects without a JSON compilation database, Importizer can attempt to imitate one using the [bootstrap] table. Note: if compilationDb is specified, the bootstrap table is ignored.

Option Type Description Default

ignores

String Array

gitignore-style ignores to exclude non-code files.

["CMakeLists.txt"]

includePaths

Include paths to search during resolution.

String Array

[]

Example configuration file

inDir = "src"
outDir = "modular_src"
# compilationDb = "build/compile_commands.json"

[bootstrap]
includePaths = ["include", "third_party/libs"]

About

Automagically rewrite header-based C++ into using modules.

Topics

Resources

License

Contributing

Stars

Watchers

Forks

Packages

 
 
 

Contributors