A fast, minimal C++ build tool designed to make compiling C++ projects simple.
Build wraps the boring parts of invoking a compiler into a small, straightforward command-line tool. No massive project files, no complicated configuration system, and no need to remember a ridiculous collection of compiler commands.
- Compile multiple C++ source files
- Automatic wildcard expansion
- Recursive source discovery
- Custom compiler flags
- Custom output paths
- Run programs immediately after building
- Clean build outputs
- Dry-run mode
- Verbose output
- Runtime arguments
- Automatic
.exehandling on Windows - Automatic output-directory creation
- C++ source detection for
.cpp,.cc,.cxx, and.c++ - Duplicate source removal
- Simple command-line interface
Clone the repository:
git clone [<repository-url>](https://github.com/ayaandh/Build.git)
cd buildCompile Build:
g++ src/main.cpp -std=c++20 -O2 -o build.exeMove build.exe somewhere on your PATH.
Verify the installation:
build --versionThe basic syntax is:
build <sources...> <output> [options]
You can also explicitly specify the output:
build <sources...> -o <output> [options]
build main.cpp appThis compiles:
main.cpp
into:
app.exe
build main.cpp player.cpp world.cpp gameBuild supports wildcard source patterns:
build *.cpp appYou can also specify a directory:
build src/*.cpp appUse -r or --recursive:
build src/*.cpp app --recursiveThis searches subdirectories as well.
Compiler options can be passed directly to Build.
build *.cpp app -Wall -Wextra -WpedanticFor optimization:
build *.cpp app -O2For debugging:
build *.cpp app -gTo select a C++ standard:
build *.cpp app -std=c++23Include directories and libraries can also be passed directly:
build *.cpp app -Iinclude -Llib -lmylibBuild passes these options directly to g++.
Use -run or --run to run the executable after a successful build:
build main.cpp app --runRuntime arguments can be passed after --:
build main.cpp app --run -- hello 123Everything after -- is treated as an argument for the compiled program.
For example:
build main.cpp app -- hello 123results in the equivalent of:
app.exe hello 123
The output executable can be specified with -o:
build main.cpp -o bin/appBuild automatically adds .exe when necessary on Windows:
bin/app
becomes:
bin/app.exe
Output directories are created automatically if they don't exist.
For example:
build src/*.cpp -o bin/debug/gamecreates the required directories before compiling.
Remove the generated executable:
build main.cpp app --cleanThis removes:
app.exe
without compiling anything.
Use --dry-run to see what Build would execute without actually compiling:
build *.cpp app --dry-runThis is useful for inspecting the generated compiler command.
Use -v or --verbose to display additional information:
build *.cpp app --verboseBuild will display the discovered source files and output path before compilation.
Display the complete command reference:
build --helpDisplay the installed Build version:
build --versionproject/
├── main.cpp
├── player.cpp
└── world.cpp
Build it with:
build *.cpp gameproject/
├── include/
│ ├── player.hpp
│ └── world.hpp
├── src/
│ ├── main.cpp
│ ├── player.cpp
│ └── world.cpp
Build it with:
build src/*.cpp game -Iincludebuild src/*.cpp game -Iinclude -g -Wall -Wextrabuild src/*.cpp game -Iinclude -O2 -DNDEBUGbuild src/*.cpp game -Iinclude --runbuild src/*.cpp game --run -- level 3| Option | Description |
|---|---|
-o, --output <file> |
Specify the output executable |
-run, --run |
Run the executable after building |
--clean |
Remove the output executable |
-r, --recursive |
Search wildcard patterns recursively |
-v, --verbose |
Display detailed build information |
--dry-run |
Display commands without executing them |
-h, --help |
Display help |
--version |
Display the Build version |
-- |
Pass remaining arguments to the program |
Any unrecognized option beginning with - is passed directly to g++.
- C++20 or newer
g++- Windows or another platform supported by the C++ standard library implementation
Build uses:
#include <filesystem>so a compiler with C++17 filesystem support is required at minimum, although Build itself is intended to be compiled with C++20 or newer.
Build intentionally keeps its interface small.
Instead of requiring a large configuration file for a simple project:
build src/*.cpp mygame -std=c++23 -O2 -Wall
is enough.
The goal is to make common C++ builds require almost no configuration while still allowing compiler arguments to be passed through when more control is needed.
Build is currently a lightweight command-line build tool.
The project is designed to grow toward a more complete C++ build system while keeping its command-line interface simple and predictable.
Build is licensed under the MIT License. See the repository license for details.
Built by Ayaan Dhalait