A rule-based build system to automatically find source files and compile them. No need for build scripts.
- A root folder holds one-or-more projects.
- Source files are recursively found in the
srcfolder of each project or library. - Projects are placed in subfolders.
- The name of the project folder is the name of the resulting executable.
- A source file with the same name as the project will contain the
mainfunction.
- A source file with the same name as the project will contain the
- Names starting with
s.ord.produce static- and dynamic libraries, respectively.
- The name of the project folder is the name of the resulting executable.
libfolder is for libraries.- Libraries are shared across all projects.
- Static libraries are in folders starting with
s.. - Dynamic libraries are in folders starting with
d.. - Other folders are added to the includes list. They are not searched for source files.
- Include paths for libraries are automatically added to projects.
- Also includes
incandincludesubfolders, if present.
- Also includes
unittestfolder is for unit tests.- Each
test.*.cppfile is compiled into a unittest executabletest.*.exe. - Other sourcefiles are linked to each unittest executable.
- Each
- Files and folders starting with
x.are ignored. - TODO: Files and folders postfixed with
.win,.linux,.darwinare only compiled on matching platforms.
example/
├── lib/
│ ├── s.libname1/ (shared static library)
│ │ ├── inc/
│ │ └── src/
│ ├── d.libname2/ (shared dynamic library)
│ │ ├── inc/
│ │ └── src/
│ └── libname3/ (shared header-only include)
│ ├── inc/
│ └── src/ (for building implementions)
├── example/ (executable - main project)
│ └── src/
├── other_executeable/ (another executable)
│ └── src/
├── unittest/
│ ├── test.example.cpp
│ └── test.other.cpp
└── d.some_dll/ (dynamic library)
├── inc/
└── src/
gbs [command, ...]
Calling gbs without any commands will do a debug build of the current directory and run all unittests.
The following commands are supported:
versionShows the current version of the build system.config=<reponse file, ...>Sets the configurations to use for compilation.- Configurations are provided as a comma-separated list of response files. Currently
debug,release,analyzehave built-in support, and will be created if not found. - A configuration name corresponds to a response file in the folder
.gbs/.- Response files are simple text files containing command line arguments for the selected compiler.
- They can be created manually or you can use the auto generated ones. You are free to change them as you see fit.
- Example:
gbs config=release,analyze buildwill do an analyzed release build.
- Configurations are provided as a comma-separated list of response files. Currently
cl=<compiler>:<major.minor.patch>Selects the compiler to use for subsequent commands.gbs cl=msvc build cl=clang:17.3.1 buildwill first build with latest msvc, then build with clang 17.3.1.
buildBuilds the current directory.- If no configuration is specified (via
configcommand),debug,warningsis used by default.
- If no configuration is specified (via
cleancleans the build output folder (gbs.out).- Uses same format as
config. - TODO: only clean specified configuration (
=<configuration>).
- Uses same format as
unittest=<args>Runs built unittests.argsare passed verbatim to the unittest executables.
get_cl=<compiler>:<major.minor.patch>Downloads the compiler with at least the specified version. Supports clang and gcc.- This also sets the compiler for subsequent commands, as if
cl=...was used.
- This also sets the compiler for subsequent commands, as if
enum_clEnumerates installed compilers.ide=<ide name>Generates tasks.vs.json for the specified IDE.- Supported IDEs are
vscodeandvs. - Example:
gbs ide=vswill let a folder to be opened in Visual Studio and allow the user to right-click a folder and have several build options available, without needing a project or solution.
- Supported IDEs are
- TODO
new=<project_name>Creates a new project with the specified name in the current directory.- If no name is specified, the current directory name is used.
- The project will have the following structure:
src- source files for main executeablelib- librariesunittest- unit testsdeps- dependencies ?
The following compilers can be used by gbs to build gbs:
- msvc 19.38+
- clang 22+
- gcc 16+ (linking error when using
std::print)- Requires manual edits to
printandostreamstd headers to fix linking errors. In the functionvprint_unicode, in both files, change the line:to#if !defined(_WIN32) || defined(__CYGWIN__)#if 1//!defined(_WIN32) || defined(__CYGWIN__)
- Requires manual edits to
- Support package managers (vcpkg, conan, etc.)
- Use GCC on WSL
- Concurrent compilations of multiple different compilers
- Good documentation for all commands
- Compiling/running unit tests
- Use package managers
- Add a
get_cl=compiler:?option to list versions available for download - Allow matrix builds, eg.
gbs build=[debug,release] runresults in 2 builds and 2 runs - Support for running custom build steps before/after compilation
- WSL support
- Create a simple build system
- Automatic compilation without build scripts
- Find source files automatically
- Don't compile things that don't need it
- Don't link things that don't need it
- Deduce executable name from current directory
- Compile module sources in correct order
- Compile nested sources
- Compile GBS with itself
- Automated support for
import std;- msvc
- clang 19+
- gcc 15+
- Enumerate installed compilers
- Choose compiler from command
gbs cl=msvc:19.44 build cl=clang:17 build - Use response files for compilation variance
- Create variants for debug/release/analyze/sanitize/library/etc.
- Compile by selecting one-or-more response files, eg.
gbs build=release,analyze,avx2,hardened_stdlib
- Multiple operations, eg.
gbs build=debug unittest build=release unittest - Compiling/linking of static libraries
- msvc
- clang
- gcc
- Compiling/linking of dynamic libraries
- msvc
- clang
- gcc
- Support multiple compilers
- msvc
- clang
- gcc
- Download compilers, eg.
gbs get_cl=clang:19- clang
- gcc
- Integrate with Visual Studio [Code]
- Visual Studio
- Visual Studio Code
Yes, I am aware of the irony of using CMake to make a build system. I am making this so I hopefully never have to use cmake again.