Layouts modules, compiles them in parallel, links a main executable, and optionally builds tests or hot-reloadable shared objects.
- General Information
- Technologies Used
- Features
- Setup
- Usage
- Project Status
- Room for Improvement
- License
This repository is a starting point for projects that need a simple modular build system driven by Bash.
Each module lives in its own folder and exports what to compile and what to expose via a config.sh.
The top-level build.sh discovers modules, sets compiler flags, runs per-module builds in parallel, links the final executable, and optionally builds tests or creates hot-reloadable .so files.
- GNU bash 5.3.3
- clang 21.1.4
- gtest - 1.17.0-1
- ccache - 4.12.1
- fd - 10.3.0
- pkg-config - 2.5.1
- llvm-ar - 21.1.4
- Modular layout. Each module lives in its own folder with
include/,src/, optionaltests/and aconfig.shcontract that exports what to compile and what to expose. - Parallel module builds. Modules are built in background jobs to use all cores.
- Multiple build types. Supports
DEBUG,RELEASE,PROFILE, andTESTSwith corresponding compiler flags and-Ddefines. - Hot reload. Optionally convert archives to
.soand link withrpath.HOT_RELOADdefine exposed to sources. - Build cache. Uses
ccacheby default and can be disabled per-run. - Rebuild controls to force rebuilds.
- Sanitizers and static analysis. Toggle Address/ UB/ Leak sanitizers and
scan-build. - Test packaging. Builds test artifacts and a test executable when
Testsis selected. - External libs supported via
pkg-config. cflags and link flags injected automatically. - Configurable toolchain and flags. Compiler, link flags, include paths and defines are environment driven.
- Stripping and section removal. Optional objcopy/ strip steps to reduce binary size.
- Colored status output for build steps and module lists.
Dockerfile is available.
Make the script executable and run:
chmod +x build.sh
./build.sh -d # Debug
./build.sh -r # Release
./build.sh -p # Profile
./build.sh -t # Build testsCombine flags. Example: build release, strip executable, disable cache:
./build.sh -ricForce rebuild of all parts:
./build.sh -auProject is: in progress.
- Wrap repeating parts in functions
This project is open source and available under the GNU Affero General Public License v3.0.