Skip to content
skipbitPublic

Repository files navigation

scrap πŸ”§

Build codecov License: MIT C++23

A Modern C++ Package Manager and Build System

Quick Start β€’ Features β€’ Project Status β€’ Installation β€’ Contributing


🎯 What is scrap?

scrap is a modern development tool for C++ that brings the simplicity and power of Rust's Cargo to the C++ ecosystem. It aims to provide a unified interface for project management, dependency handling, and build orchestration - all without the traditional complexity of C++ development.

Why scrap?

C++ development has traditionally suffered from:

  • πŸ”§ Complex build systems - CMake, Make, Bazel, Meson... each with its own learning curve
  • πŸ“¦ No standard package manager - Unlike Rust, Go, or Node.js, C++ lacks a unified ecosystem
  • πŸ–₯️ System-dependent toolchains - "It works on my machine" is too common
  • πŸ“š High barrier to entry - Setting up a C++ project shouldn't require a PhD

scrap aims to solve these problems with:

  • πŸš€ Zero-configuration project setup - Get started in seconds, not hours
  • πŸ“ Standardized project structure - Convention over configuration
  • πŸ”„ Reproducible builds - Same toolchain, same results, everywhere
  • πŸ“¦ Modern package management - GitHub-based ecosystem for sharing libraries
  • πŸ› οΈ Integrated toolchain management - No more system dependency hell

What works today is listed under Project Status.

πŸš€ Quick Start

# Create a new C++ application
scrap new my-app

# Build your project
cd my-app
scrap build

# Run your application
scrap run

# Clean build artifacts
scrap clean

That's it! No CMakeLists.txt, no Makefiles, no complex setup. scrap handles everything.

✨ Features

πŸ“ Simple Configuration

Projects are configured with a simple scrap.toml file:

[package]
name = "my-app"
version = "0.1.0"
std = "23"

[[bin]]
name = "my-app"
src = "src/main.cpp"

std names the C++ standard to build against: "11", "14", "17", "20", "23" (the default) or "26". Whether a given compiler can build the one you name is the compiler's to answer, and scrap build says so before it compiles anything.

Sources ending in .c are compiled as C by a C compiler and linked with the C++ sources. c-std names the C standard for them: "99", "11", "17" (the default) or "23". As with std, scrap build says before it compiles anything whether the compiler can build it.

A target can add to the commands that build it. Settings written on a target apply to it alone; a library's settings under [lib.public] also apply to every executable that uses it:

[[lib]]
name = "core"
include-dirs = ["src"]
compile-flags = ["-Werror"]
cpp-compile-flags = ["-Wold-style-cast"]

[lib.public]
compile-flags = ["-pthread"]
link-flags = ["-pthread"]

compile-flags apply to C and C++ sources alike. c-compile-flags apply to C sources alone and cpp-compile-flags to C++ sources alone, and come after every compile-flags, including those of the libraries a target uses. A flag only one language takes belongs in the one for that language: gcc warns of -Wold-style-cast when it compiles C, and with -Werror the warning stops the build.

🎨 Project Templates

Get started quickly with the built-in template:

# Create a project from the default app template
scrap new my-project

Choosing another template with --template is coming soon.

πŸ”§ Integrated Toolchain Management

# Install the newest version of a series, which becomes the default if none is set
scrap toolchain install llvm@18

# Select an installed toolchain as the global default
scrap toolchain select llvm@18

# Remove the global default
scrap toolchain unselect

# List the system's compiler and the installed toolchains, with the default
# and the one used in the project here marked
scrap toolchain list

# List the toolchains of the index this machine can install, as last fetched;
# --all lists every one, with why this machine cannot install it
scrap toolchain list --remote

# Show where a toolchain came from, where it is, what it is made of and
# whether it is chosen; one that is not installed is shown as the index has it
scrap toolchain info llvm@18

# Fetch the index of toolchains, and show what is new and what changed since
# it was last fetched; nothing installed changes
scrap toolchain update

# Remove the one installed version a specifier names, unselecting it if it was
# the global default and leaving the other versions of the series
scrap toolchain uninstall llvm@18.1.8

A project can name its own toolchain in scrap.toml, which comes before the global default; system names the compiler of the system, found through CXX or on PATH, and for C sources the C compiler, found through CC or as cc, gcc or clang on PATH:

[toolchain]
name = "llvm@18"

The SCRAP_TOOLCHAIN environment variable comes before both. A toolchain that is named and not installed is an error; scrap does not install it in passing.

A toolchain the index deprecates or no longer provides is warned of, with a version to install instead, when it is installed, selected, listed, shown or built with. One that is installed and no longer provided still builds. Only install fetches the index for this; the others read the copy saved when the index was last fetched, and say nothing when there is none for the index in use or it cannot be read.

A program built with an installed toolchain runs with the runtime libraries of that toolchain; with LLVM, that is the libc++ it carries. On Linux, the linker of LLVM 17 to 22 needs libxml2 on the machine. On macOS, an installed LLVM uses the SDK that xcrun names, which the Command Line Tools provide, or the one SDKROOT names. An LLVM installed by an earlier version of scrap has to be installed again with --force, as a build with it says. A toolchain installed by an earlier version of scrap does not record its C compiler, so it has to be installed again with --force to build C sources, as a build with it says.

🧹 Formatting

scrap format formats the sources of a project in place with the clang-format found on PATH, and names the one it uses and its version before it starts. It covers the sources and headers below src/, the headers below include/ and below the include-dirs of each target, its own and its public ones, and the entry points a target names in src. Nothing below build/ is covered, nor a symbolic link to a file. Files and directories named after the command narrow that down. A named file the command does not cover is left out with a warning, and so is a named directory below which it covers nothing. When everything named is left out, nothing is formatted and the command exits with 0. A named path is resolved through the file system first, so a path through a symbolic link names the file the link reaches.

# Format the whole project
scrap format

# Format one file and what lies below a directory
scrap format src/main.cpp src/net

# Report the files formatting would change, and change none
scrap format --check

With --check, no file is changed: each file formatting would change is reported with a warning. The command exits with 1 when there is any, or when a file cannot be checked, and with 0 otherwise, also when the paths given leave no file to check.

Without a style, clang-format follows the .clang-format it finds in the directory of each file or above it. A style in scrap.toml is passed to the --style of clang-format as written, and takes the place of any .clang-format:

[format]
style = "llvm"

tool names the formatter, and "clang-format", the default, is the only one. When clang-format fails on a file, the file and what clang-format wrote are shown, the other files are still formatted, and scrap format exits with 1.

πŸ” Static Analysis

scrap check analyzes the sources of a project with the clang-tidy found on PATH, and names the one it uses and its version before it starts. It covers the sources the targets compile. The commands scrap build would compile them with are written to compile_commands.json below build/ and passed to clang-tidy, and nothing is compiled. A source that more than one target compiles is analyzed with the command of each. Files and directories named after the command narrow that down, as they do for scrap format, and a named header is left out with a warning.

# Analyze the whole project
scrap check

# Analyze one file with the commands of the release profile
scrap check src/main.cpp --release

# Analyze one file at a time
scrap check -j 1

What clang-tidy writes for a file is shown once the file has been analyzed. Whether the check passes is for clang-tidy to say: scrap check exits with 1 when clang-tidy fails on a file, as it does on a compile error or on a warning that WarningsAsErrors in .clang-tidy makes an error, and with 0 when it only warns. The files it failed on are named at the end.

Without checks in scrap.toml, clang-tidy enables the checks of the .clang-tidy of the project. Checks in scrap.toml, in the notation of the --checks of clang-tidy, take their place, and the other settings of .clang-tidy still apply:

[check]
checks = "readability-*,modernize-use-nullptr"

tool names the analyzer, and "clang-tidy", the default, is the only one.

πŸ“‹ Project Status

scrap is in early alpha development.

βœ… Works today

  • Creating a project - scrap new <name> creates a project from the built-in template
  • Building - scrap build makes a debug build, or an optimised one with --release, below build/, along with a compile_commands.json for editors and other tools. --target <name> builds one target, and -j <n> (--jobs) sets how many steps run at once
  • Building only what changed - a source is compiled again when it, a header it includes, the compiler or the command that compiles it has changed
  • C sources - .c sources are compiled as C and linked with the C++ sources
  • Static libraries - with a [[lib]] in scrap.toml, the sources below src/ become a static library that each executable links
  • Settings per target - include directories, defines and flags, as shown in Simple Configuration
  • Running - scrap run builds the executable and starts it with the arguments after --, and exits with its exit code. --bin <name> chooses the executable when there is more than one, and -j <n> sets how many steps of the build run at once
  • Cleaning - scrap clean removes build/
  • Formatting - scrap format formats the sources with the clang-format on PATH, and --check reports the files it would change, as shown in Formatting
  • Static analysis - scrap check analyzes the sources with the clang-tidy on PATH and the commands a build would compile them with, as shown in Static Analysis
  • Toolchains - scrap toolchain install, select, unselect, list (with --remote), info, update and uninstall, and a toolchain per project in scrap.toml, as shown in Integrated Toolchain Management
  • External commands - an executable named scrap-<name> on PATH runs as scrap <name> and is listed in scrap --help

🚧 In Progress

  • Choosing a template with --template, and templates from Git repositories
  • scrap template list and scrap template update
  • [dependencies] in scrap.toml, which is accepted and not yet read

πŸ“… Planned

  • Package management: dependency resolution, a package registry, and scrap add, scrap search and scrap update
  • Binary package distribution and package publishing tools
  • Cross-compilation
  • IDE integrations
  • CI/CD templates
  • SBOM generation

πŸ› οΈ Installation

Install a prebuilt binary

curl -fsSL https://skipbit.github.io/scrap/install.sh | sh

This installs the latest release to ~/.scrap/bin/scrap ($SCRAP_HOME/bin when SCRAP_HOME is set), after checking the archive against its published sha256, and offers to add that directory to PATH. To install a specific release, give its version as the releases page names it, in place of vX.Y.Z:

curl -fsSL https://skipbit.github.io/scrap/install.sh | sh -s -- vX.Y.Z

Prebuilt binaries are available for:

  • Linux x86_64, with glibc 2.29 or later
  • macOS on Apple silicon, 15.0 or later

The archives, their checksums and build provenance attestations are on the releases page.

Building from Source

To build scrap yourself, you need:

  • A C++23 compiler and standard library. CI builds and tests scrap with:
    • On Linux, GCC 13 and 15 with their libstdc++, and Clang 20 and 22 with libstdc++ 13, 14 and 15 and with the libc++ of the same version
    • On macOS, the Apple Clang of macOS 15 and 26
  • A C compiler as well: the build fetches liblzma and links it in, and on Linux libcurl and Mbed TLS too. macOS uses the libcurl it ships with.
  • CMake 3.25 or higher
  • Git

Then build it and copy it to a directory on your PATH:

git clone https://github.com/skipbit/scrap.git
cd scrap

# Build scrap alone, without its tests
cmake --preset release-no-tests
cmake --build --preset release-no-tests --parallel

# Copy it to where the install script puts it
mkdir -p ~/.scrap/bin
cp build/release-no-tests/bin/scrap ~/.scrap/bin/

🌐 Ecosystem

scrap is building a comprehensive C++ ecosystem:

Related Repositories

  • scrap-templates - Official project templates
  • scrap-toolchain - The toolchains that scrap toolchain install installs
  • scrap-packages (Coming Soon) - Package registry

Vision

Our goal is to create a Homebrew-like ecosystem for C++ development, where:

  • Libraries are easily discoverable and installable
  • Toolchains are managed independently from the system
  • Projects are reproducible across different environments
  • The community can easily contribute and share packages

🀝 Contributing

We welcome contributions! scrap is written in C++23, and its design aims for:

  • Clean Architecture - Keep the core free of I/O, platform and command-line details
  • Single responsibility - Give each unit one job, so that a change stays in one place

How to Contribute

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/amazing-feature)
  3. Follow our coding style guide
  4. Commit your changes
  5. Push to your branch
  6. Open a Pull Request

Development Setup

git clone https://github.com/skipbit/scrap.git

# Configure, build and run the tests in debug mode
cmake --workflow --preset debug

# Run the tests again after a change
cmake --build --preset debug --parallel
ctest --preset debug

Testing

The project uses GoogleTest for unit and end-to-end testing, run through ctest. The tests are built unless BUILD_TESTS is set to OFF.

# Build and run all tests
cmake --workflow --preset debug

# Run tests with verbose output
ctest --preset debug --verbose

# Run the tests of one module directly, or the end-to-end tests
./build/debug/test/scrap_gtest_<module>
./build/debug/test/scrap_e2e

# Release build testing
cmake --workflow --preset release

Test Structure:

  • test/unit/command/ - Unit tests for the command layer
  • test/unit/file/ - Unit tests for reading and writing whole files
  • test/unit/digest/ - Unit tests for SHA-256 digests
  • test/unit/tar/ - Unit tests for reading and extracting tar archives
  • test/unit/json/ - Unit tests for the JSON parser
  • test/unit/xz/ - Unit tests for reading xz-compressed files
  • test/unit/fetch/ - Unit tests for fetching a URL
  • test/unit/registry/ - Unit tests for fetching toolchains from a container registry
  • test/unit/install/ - Unit tests for installing a fetched toolchain
  • test/unit/project/ - Unit tests for project configuration (scrap.toml) and layout
  • test/unit/process/ - Unit tests for running other programs
  • test/unit/toolchain/ - Unit tests for toolchain detection
  • test/unit/compile/ - Unit tests for the compile and link commands, the compiler drivers and the compilation database
  • test/unit/build/ - Unit tests for running the steps of a build
  • test/support/ - Helpers shared by the tests of more than one module
  • test/e2e/ - End-to-end tests that spawn the built scrap binary as a subprocess
  • test/cmake/ - Tests of the CMake modules, run in script mode

🎯 Design Philosophy

scrap follows these core principles:

  1. Convention over Configuration - Sensible defaults that just work
  2. Reproducible Builds - Same input, same output, everywhere
  3. Modern C++ First - New projects start on a modern standard; older ones are there when a project needs them
  4. Community Driven - Open source, open development
  5. Developer Experience - Making C++ development enjoyable

πŸ“œ License

scrap is MIT licensed. See LICENSE for details. A release archive also holds THIRD_PARTY_LICENSES, with the licenses of the libraries built into the binary.

πŸ™ Acknowledgments

scrap is inspired by:

  • Cargo - Rust's excellent package manager
  • Homebrew - The missing package manager for macOS
  • Poetry - Python's modern dependency management

Special thanks to all contributors and the C++ community for feedback and support.

πŸ“¬ Contact


Made with ❀️ for the C++ Community

⬆ Back to top

Releases

Packages

Used by

Contributors

Languages