Skip to main content

Quom is a single header generator for C/C++ libraries.

Project description

logo

Build Status PyPI

Quom

Quom is a single file generator for C/C++.

It resolves all included local headers starting with your main C/C++ file. This is also known as amalgamation.

Afterwards, it tries to find the related source files and their headers and places them at the end of the main file or at a specific stitch location if provided.

At the end there will be one single file with all your header and sources joined together.

Installation

pip install --user quom

Requires Python 3.7 or later.

How to use it

usage: quom [-h] [--stitch format] [--include_guard format] [--trim]
            input output

Single header generator for C/C++ libraries.

positional arguments:
  input                 Input file path of the main file.
  output                Output file path of the generated single header file.

optional arguments:
  -h, --help            show this help message and exit
  --stitch format, -s format
                        Format of the comment where the source files should be placed
                        (e.g. // ~> stitch <~). Default: None (at the end of the main file)
  --include_guard format, -g format
                        Regex format of the include guard. Default: None
  --trim, -t            Reduce continuous line breaks to one. Default: True
  --include_directory INCLUDE_DIRECTORY, -I INCLUDE_DIRECTORY
                        Add include directories for header files.
  --source_directory SOURCE_DIRECTORY, -S SOURCE_DIRECTORY
                        Set the source directories for source files.
                        Use ./ in front of a path to mark as relative to the header file.
  --encoding ENCODING, -e ENCODING
                        The encoding used to read and write all files.

Simple example

The project:

|-src/
|  |-foo.hpp
|  |-foo.cpp
|   -main.cpp
|-out/
    -main_gen.cpp

foo.hpp

#pragma once

int foo();

foo.cpp

#include "foo.hpp"

int foo() {
    return 0;
}

main.cpp

#include "foo.hpp"

int main() {
    return foo();
}

The command:

quom src/main.hpp main_gen.cpp

main_gen.cpp

int foo();

int main() {
    return foo();
}

int foo() {
    return 0;
}

Advanced example

The project:

|-src/
|  |-foo.hpp
|  |-foo.cpp
|   -foobar.hpp
|-out/
    -foobar_gen.hpp

foo.hpp

#pragma once

#ifndef FOOBAR_FOO_HPP
#define FOOBAR_FOO_HPP

extern int foo; 

#endif

foo.cpp

#include "foo.hpp"

int foo = 42;

foobar.hpp

#pragma once

#ifndef FOOBAR_HPP
#define FOOBAR_HPP

#include "foo.hpp"

#endif

#ifdef FOO_MAIN

// ~> stitch <~

#endif

The command:

quom src/foobar.hpp foobar_gen.hpp -s "~> stitch <~" -g FOOBAR_.+_HPP

foobar_gen.hpp

#pragma once

#ifndef FOOBAR_HPP
#define FOOBAR_HPP

extern int foo;

#endif

#ifdef FOO_MAIN

int foo = 42;

#endif

Take a look into the examples folder for more.

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

quom-4.0.2.tar.gz (502.7 kB view details)

Uploaded Source

Built Distribution

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

quom-4.0.2-py2.py3-none-any.whl (14.8 kB view details)

Uploaded Python 2Python 3

File details

Details for the file quom-4.0.2.tar.gz.

File metadata

  • Download URL: quom-4.0.2.tar.gz
  • Upload date:
  • Size: 502.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.18

File hashes

Hashes for quom-4.0.2.tar.gz
Algorithm Hash digest
SHA256 db96f350076ee45f9df251e9ff807be3fd19971e08dc5bdf720f39ce5862f593
MD5 1d0c59da8cc119e04d54212bfd1bbc5f
BLAKE2b-256 4ee8abd145fff7ca9ae32383fa3fe2c8488778fc5e55aa382f21870fa5758979

See more details on using hashes here.

File details

Details for the file quom-4.0.2-py2.py3-none-any.whl.

File metadata

  • Download URL: quom-4.0.2-py2.py3-none-any.whl
  • Upload date:
  • Size: 14.8 kB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.18

File hashes

Hashes for quom-4.0.2-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 5976053f357099d7a78e8ab5036eee3a06e092284488cfaf8972ab4491542593
MD5 b9b9e177d351004cf6cf87e8ba64fac8
BLAKE2b-256 eac7bbf7f4622f29dc9c3d165985be4cbde43ecd36036af550c9793880a841db

See more details on using hashes here.

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