A Modern C++ Package Manager and Build System
Quick Start β’ Features β’ Project Status β’ Installation β’ Contributing
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.
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.
# 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 cleanThat's it! No CMakeLists.txt, no Makefiles, no complex setup. scrap handles everything.
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.
Get started quickly with the built-in template:
# Create a project from the default app template
scrap new my-projectChoosing another template with --template is coming soon.
# 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.8A 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.
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 --checkWith --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.
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 1What 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.
scrap is in early alpha development.
β Works today
- Creating a project -
scrap new <name>creates a project from the built-in template - Building -
scrap buildmakes a debug build, or an optimised one with--release, belowbuild/, along with acompile_commands.jsonfor 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 -
.csources are compiled as C and linked with the C++ sources - Static libraries - with a
[[lib]]inscrap.toml, the sources belowsrc/become a static library that each executable links - Settings per target - include directories, defines and flags, as shown in Simple Configuration
- Running -
scrap runbuilds 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 cleanremovesbuild/ - Formatting -
scrap formatformats the sources with theclang-formatonPATH, and--checkreports the files it would change, as shown in Formatting - Static analysis -
scrap checkanalyzes the sources with theclang-tidyonPATHand the commands a build would compile them with, as shown in Static Analysis - Toolchains -
scrap toolchain install,select,unselect,list(with--remote),info,updateanduninstall, and a toolchain per project inscrap.toml, as shown in Integrated Toolchain Management - External commands - an executable named
scrap-<name>onPATHruns asscrap <name>and is listed inscrap --help
π§ In Progress
- Choosing a template with
--template, and templates from Git repositories scrap template listandscrap template update[dependencies]inscrap.toml, which is accepted and not yet read
π Planned
- Package management: dependency resolution, a package registry, and
scrap add,scrap searchandscrap update - Binary package distribution and package publishing tools
- Cross-compilation
- IDE integrations
- CI/CD templates
- SBOM generation
curl -fsSL https://skipbit.github.io/scrap/install.sh | shThis 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.ZPrebuilt 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.
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/scrap is building a comprehensive C++ ecosystem:
- scrap-templates - Official project templates
- scrap-toolchain - The toolchains that
scrap toolchain installinstalls - scrap-packages (Coming Soon) - Package registry
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
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
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Follow our coding style guide
- Commit your changes
- Push to your branch
- Open a Pull Request
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 debugThe 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 releaseTest Structure:
test/unit/command/- Unit tests for the command layertest/unit/file/- Unit tests for reading and writing whole filestest/unit/digest/- Unit tests for SHA-256 digeststest/unit/tar/- Unit tests for reading and extracting tar archivestest/unit/json/- Unit tests for the JSON parsertest/unit/xz/- Unit tests for reading xz-compressed filestest/unit/fetch/- Unit tests for fetching a URLtest/unit/registry/- Unit tests for fetching toolchains from a container registrytest/unit/install/- Unit tests for installing a fetched toolchaintest/unit/project/- Unit tests for project configuration (scrap.toml) and layouttest/unit/process/- Unit tests for running other programstest/unit/toolchain/- Unit tests for toolchain detectiontest/unit/compile/- Unit tests for the compile and link commands, the compiler drivers and the compilation databasetest/unit/build/- Unit tests for running the steps of a buildtest/support/- Helpers shared by the tests of more than one moduletest/e2e/- End-to-end tests that spawn the builtscrapbinary as a subprocesstest/cmake/- Tests of the CMake modules, run in script mode
scrap follows these core principles:
- Convention over Configuration - Sensible defaults that just work
- Reproducible Builds - Same input, same output, everywhere
- Modern C++ First - New projects start on a modern standard; older ones are there when a project needs them
- Community Driven - Open source, open development
- Developer Experience - Making C++ development enjoyable
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.
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.
- GitHub Issues: Report bugs or request features
Made with β€οΈ for the C++ Community