Work-in-progress Rust application that converts C++ header-only libraries to single self-contained headers.

Overview

unosolo

Work-in-progress Rust application that converts C++ header-only libraries to single self-contained headers.

stability license gratipay badge.rust

Disclaimer

This is my first Rust project, mainly created to start getting used to the language. My intention is to improve unosolo as I get better with Rust and the final goal is being able to successfully use it on popular libraries. (If you need a full-fledged customizable preprocessor implementation, check out pcpp.)

I also do not encourage people to create single-header libraries and use those in their projects: they're mainly useful when dealing with very complicated build systems or when experimenting on an online compiler that doesn't allow users to easily import multiple files.

Contributions and code reviews are welcome!

Build instructions

git clone https://github.com/SuperV1234/unosolo
cd unosolo
cargo build
  • cargo run -- args... can be used to build&run unosolo.

  • cargo install can be used to install unosolo on the user's system.

Overview

Given a set of paths containing the C++ header-only library's header files and a "top-level include" file where the graph traversal will start from, unosolo outputs a self-contained single-header version of the library to stdout. Here's the clap-rs auto-generated help:

unosolo 0.1.1
Vittorio Romeo <[email protected]>
transforms a C++ header-only library in a self-contained single header.

USAGE:
    unosolo [FLAGS] [OPTIONS] --topinclude <top_include>

FLAGS:
    -h, --help       Prints help information
    -V, --version    Prints version information
    -v, --verbose    Enable verbose mode

OPTIONS:
    -p, --paths <paths>...            Include paths [default: .]
    -t, --topinclude <top_include>    Top-level include file path (entrypoint)

Use cases

scelta

unosolo is currently able to transform scelta, my latest C++17 header-only library, to a single-header version. In fact, I've used unosolo to add two badges to scelta's README that allow users to try the library either on wandbox or on godbolt. This idea was taken from Michael Park's excellent variant implementation: mpark::variant.

The command used to transform scelta was:

unosolo -p"./scelta/include" -v -t"./scelta/include/scelta.hpp" > scelta_single_header.hpp

It produced this abomination.

vrm_core and vrm_pp

Since 0.1.1, unosolo supports multiple library include paths and "absolute #include directives". My vrm_core library, which depends on vrm_pp, can be transformed to a single header as follows:

git clone https://github.com/SuperV1234/vrm_pp.git
git clone https://github.com/SuperV1234/vrm_core.git
unosolo -p"./vrm_pp/include" "./vrm_core/include" -t"./vrm_core/include/vrm/core.hpp" > vrm_core_sh.hpp

It produced this beauty.

boost::hana

A single-header version of boost::hana can be created using unosolo as follows:

git clone https://github.com/boostorg/hana
unosolo -p"./hana/include" -t"./hana/include/boost/hana.hpp" > hana_sh.hpp

I haven't tested it very thorougly, but I compiled the example on hana's README without any hiccups.

You might also like...
Wrapper over MMTk to simplify integration with runtimes: thread management system, object header, root scanning

vmkit A library which provides bunch of building blocks to make a VM in Rust. Feautures MMTK integration out of the box Thread management provided by

Generate perfect Vyper compatible code headers every time.

headers-vy Generate perfect Vyper-compatible code headers every time. Build You need Rust and Cargo installed on your machine. See the installation gu

📜🔁🎶 A CLI which converts morse code into sound

morse2sound 🎵 A CLI which converts morse code to sound Big shoutout to Br1ght0ne for guiding me how to use Rust on stream

lemmy-help is a emmylua parser as well as a CLI which takes that parsed tree and converts it into vim help docs.
lemmy-help is a emmylua parser as well as a CLI which takes that parsed tree and converts it into vim help docs.

lemmy-help is a emmylua parser as well as a CLI which takes that parsed tree and converts it into vim help docs.

A CLI tool that converts images to ASCII art.
A CLI tool that converts images to ASCII art.

Rust ASCII Art Converter This Rust tool converts images into ASCII art. It takes an image file as input, resizes it according to specified width and h

TextOCX is a Windows program that converts TeX snippet to MSOffice pastable format.

TextOCX TeX Snippet ===== MSOffice Screencast Preview | Download What TextOCX is a Windows program that converts TeX snippet to MSOffice pastable for

A command line progress reporting library for Rust
A command line progress reporting library for Rust

indicatif Documentation A Rust library for indicating progress in command line applications to users. This currently primarily provides progress bars

Console progress bar for Rust
Console progress bar for Rust

Terminal progress bar for Rust Console progress bar for Rust Inspired from pb, support and tested on MacOS, Linux and Windows Documentation Examples s

Rust crate that allows you to display status & progress information in a terminal

status-line This crate allows you to display status & progress information in a terminal This crate handles the problem of displaying a small amount o

Comments
  • Produces empty header

    Produces empty header

    code: https://gitlab.com/TheWisp/SimpleTemplate.git command (placed exe in root): unosolo.exe -p"." -v -t".\simpletemplate.hpp" > simpletemplatesh.hpp

    tried to put the headers into a subdirectory but the problem remained.

    opened by TheWisp 0
  • consider supporting X macro headers

    consider supporting X macro headers

    Header files without include guards are useful for holding large X macros. Here are some examples.

    For example, after expanding a header the first time, unosolo does this for the second include:

    #ifdef BOOST_CLBL_TRTS_ENABLE_NOEXCEPT_TYPES
    #define BOOST_CLBL_TRTS_NOEXCEPT_SPEC noexcept
    #define BOOST_CLBL_TRTS_IS_NOEXCEPT std::true_type
    < blank line instead of expanded header >
    #undef BOOST_CLBL_TRTS_NOEXCEPT_SPEC
    #undef BOOST_CLBL_TRTS_IS_NOEXCEPT
    #endif // #ifdef BOOST_CLBL_TRTS_ENABLE_NOEXCEPT_TYPES
    
    opened by badair 0
Owner
Vittorio Romeo
[](){}();
Vittorio Romeo
A self-contained, unopinionated, fast and lightweight executable launcher.

Kickoff ?? A self-contained, unopinionated, fast and lightweight executable launcher. Supported Platforms Platform Host Target aarch64-apple-macos-non

Nimbus 18 Oct 27, 2023
An experimental, work-in-progress PAM module for Tailscale

Experimental Tailscale PAM Module This is a very very experimental Tailscale PAM module that allows you to SSH using your Tailscale credentials. This

Tailscale 129 Nov 20, 2022
Work-in-progress software for managing the Azeron keypad on any operating system.

azeron-cli A small, unfinished CLI application intended to manage the Azeron Cyborg. The code is still in a very messy state and doesn't look very rus

cozyGalvinism 5 Nov 24, 2022
Work in progress NCBI's Common Tree alternative in the terminal

Lomanai Usage lomanai --species 'Mus musculus' --species 'Homo sapiens' #> Mammalia #> ++Rodentia #> | \-Mus musculus #> \+Primates #> \-Homo sapien

Jean Manguy 3 Dec 20, 2022
A work-in-progress static analyser.

Statan Statan is an early-stage static analyser for PHP and PXP projects. It is being developed in public and the journey is documented on my blog. Th

PXP 12 Jan 30, 2023
A Content Discovery Tool insipired from Feroxbuster. Work In Progress

monologue A Content Discovery Tool written in Rust, insipired from Feroxbuster. Installation Dependencies OpenSSL (If You are on linux). Rust programm

Voyage 3 Jul 20, 2023
A high level DSL for Simplicity. This is a work in progress and is not yet ready for production use

A high level DSL for Simplicity. This is a work in progress and is not yet ready for production use. The language is designed to be simple and easy to use. It is inspired by rust syntax and is statically typed. The syntax will be extended in the future to support more features.

null 13 Oct 28, 2023
zman is a CLI year (time) progress that small, fast, and just one single binary.

zman zman is a CLI year (time) progress that small, fast, and just one single binary. Features Show year progress Show month, and week progress Show r

azzamsa 17 Dec 21, 2022
Sets of libraries and tools to write applications and libraries mixing OCaml and Rust

Sets of libraries and tools to write applications and libraries mixing OCaml and Rust. These libraries will help keeping your types and data structures synchronized, and enable seamless exchange between OCaml and Rust

Meta 36 Jan 28, 2023
omekasy is a command line application that converts alphanumeric characters in your input to various styles defined in Unicode.

omekasy is a command line application that converts alphanumeric characters in your input to various styles defined in Unicode. omekasy means "dress up" in Japanese.

null 105 Nov 16, 2022