Skip to content

el-dockerr/bodge

Repository files navigation

Bodge - The Idiotic Build System

A minimalistic but powerful C++ build system that reads from a simple configuration file. It aims to be a replacement for CMAKE one day and make it more easy and reliable to build C++ and C projects.

bodge [/bɒdʒ/ verb: make or repair (something) badly or clumsily.]

Please leave a Star ⭐

Every Star show me, that this project is worth to improve for a bigger audience. Fell free to spread the word.

Find a full documentation here

This buildsystem is the draft to overcome typical issues of CMAKE. The vast of dependencies and the chaos it causes should be solved in a modern more package like approach. In Bodge you just point out the dependencies and what compiler to be used and the flags. Everything straight forward without complex commands. Bodge also solves 3rd party dependencies with git support, where you can define sources, pull them and add them to the build chain. Other features will be added step by step.

The major goal is to have one little program what makes the build of C++ software easy like maven in Java or Cargo in Rust.

Screenshot

CLI Demo

Download

Pre-compiled binaries are available in Releases for Windows, Linux, and macOS.

Building the Project

Using bodge (preferred)

bodge --platform=windows_x86

To choose the right platform use:

bodge platform

You can add your own targets in .bodge

Yes it is that easy !!! Bodge can be already build by bodge

Using Make

make all        # Build the project
make clean      # Clean build artifacts
make debug      # Build with debug symbols
make install    # Install to system (Unix/Linux)

Using Windows (mingw)

./make.bat

Using CMake

mkdir build && cd build
cmake ..
make

Manual Compilation

g++ -std=c++17 -Wall -Wextra -Isrc src/*.cpp -o bodge

FreeBSD Compilation

c++ -Wall -Lsrc src/*.cpp -o bodge
cp bodge /usr/local/bin/bodge

Key Features

Multi-Target Support

  • Build executables, shared libraries (DLLs/SOs), and static libraries
  • Per-target configuration with global defaults
  • Automatic file extension handling for different platforms

Build Sequences

  • Chain multiple build and file operations
  • Copy, remove, and create directory operations
  • Perfect for deployment workflows

Advanced Build System

  • Cross-platform compatibility (Windows/Linux)
  • Static linking support to eliminate DLL dependencies
  • Pre-compilation flags (pre_cxx_flags) for SDK setup and early initialization
  • Comprehensive error handling and logging

Automatic Source Collection

  • Use src/** to automatically collect all C++ files from directories
  • Recursive pattern matching with ** and single directory with *
  • Automatic dependency analysis and build order optimization
  • No need to manually list every source file

File Operations

  • Built-in file and directory copying
  • Safe file/directory removal
  • Directory creation with parent path handling

Daemon Mode - Automatic Rebuilds

  • Watch mode that monitors source files for changes
  • Automatically triggers rebuilds when files are modified
  • Comprehensive build logging with timestamps and error tracking
  • Configurable polling intervals
  • Perfect for active development and continuous integration

fetch sources from other repositories

  • No hassle about fetch and pull
  • Dependencies can setup fluently

Cross-Platform & Architecture-Aware Building

  • Automatic platform detection (Windows, Linux, Unix, macOS)
  • Architecture-specific builds (x86, x64, ARM, ARM64)
  • Platform-specific compiler flags, linker flags, and configurations
  • Build for multiple platforms from a single configuration
  • Platform-specific source files and dependencies

Benefits of This Modular Design

  1. Single Responsibility Principle: Each class has one clear purpose
  2. Testability: Individual components can be unit tested in isolation
  3. Maintainability: Changes to one component don't affect others
  4. Reusability: Utility classes can be reused in other projects
  5. Readability: Code is organized logically and easy to navigate
  6. Extensibility: New features can be added without major refactoring
  7. Multi-Target Support: Build multiple outputs from one configuration
  8. Workflow Automation: Sequences enable complex build and deploy workflows

Usage

Basic Usage

Create a .bodge configuration file and run:

./bodge              # Build all targets
./bodge help         # Show help
./bodge list         # List available targets and sequences

Advanced Usage with Targets and Sequences

./bodge build mylib               # Build specific target
./bodge sequence deploy           # Execute specific sequence
./bodge platform                  # Show platform information
./bodge --platform=windows_x64    # Build only for this platform
./bodge watch                     # Watch mode: auto-rebuild on file changes
./bodge daemon --interval=2000    # Daemon with custom polling interval
./bodge --arch=x86                # Build only for targets from architecture x86

Configuration Examples

Simple Configuration with Automatic Source Collection:

name: MyProject
compiler: g++
output_name: my_app
cxx_flags: -std=c++17, -Wall, -O2
sources: src/**
include_dirs: include
libraries: pthread, m

SDK Integration with Pre-CXX Flags:

name: Vulkan Project
compiler: g++
output_name: vulkan_app

# Pre-flags are applied before sources (useful for SDK paths)
pre_cxx_flags: -I$VULKAN_SDK/include, -L$VULKAN_SDK/lib
cxx_flags: -std=c++17, -Wall, -O2

sources: src/**
libraries: vulkan

Legacy Configuration (Manual File Listing):

name: MyProject
compiler: g++
output_name: my_app
cxx_flags: -std=c++17, -Wall, -O2
sources: main.cpp, utils.cpp
include_dirs: include
libraries: pthread, m

Advanced Multi-Target Configuration:

name: Multi-Target Project
compiler: g++

# Global settings for all targets
global_pre_cxx_flags: -DEARLY_INIT
global_cxx_flags: -std=c++17, -Wall, -static-libgcc, -static-libstdc++
global_include_dirs: include

# Main executable target (automatic source collection)
main.type: exe
main.output_name: my_app
main.sources: src/**
main.libraries: mylib

# Shared library target (automatic source collection)
mylib.type: shared
mylib.output_name: mylib
mylib.sources: src/lib/**
mylib.pre_cxx_flags: -DLIB_EXPORTS
mylib.cxx_flags: -O2, -fPIC

# Static library target (automatic source collection)
tools.type: static
tools.output_name: tools
tools.sources: src/tools/**

# Build sequence
sequence.build_all: build:mylib build:tools build:main

# Deploy sequence with file operations
sequence.deploy: build:main mkdir:dist copy:my_app.exe->dist/my_app.exe copy:config->dist/config

# Clean sequence
sequence.clean: remove:*.exe remove:*.dll remove:dist

Architecture-Aware Configuration:

name: Cross-Platform Project
compiler: g++

# Build for multiple platforms
platforms: windows_x64, linux_x64, windows_x86

# Global platform-specific pre-flags (applied before sources)
@windows.pre_cxx_flags: -IC:/SDK/include
@linux.pre_cxx_flags: -I/usr/include/sdk

# Global platform-specific settings
@windows.cxx_flags: -static-libgcc, -static-libstdc++
@linux.cxx_flags: -pthread
@x86.cxx_flags: -m32
@x64.cxx_flags: -m64

# Main application with platform-specific configurations
app.type: exe
app.output_name: my_app
app.sources: src/main.cpp, src/common.cpp

# Platform-specific source files
app@windows.sources: src/windows_impl.cpp
app@linux.sources: src/linux_impl.cpp

# Platform-specific libraries
app@windows.libraries: kernel32, user32
app@linux.libraries: dl, rt

# Platform-specific linker flags
@windows_x64.linker_flags: -lws2_32, -lpthread
@linux_x64.linker_flags: -pthread, -ldl
app@windows_x64.linker_flags: -lwinmm

# Platform-specific output suffixes
app@windows_x64.output_suffix: _x64
app@windows_x86.output_suffix: _x86
app@linux_x64.output_suffix: _linux64

Supported Target Types

  • exe / executable - Executable programs (.exe on Windows)
  • shared / dll / so - Shared libraries (.dll on Windows, .so on Linux)
  • static / lib - Static libraries (.lib on Windows, .a on Linux)

Supported Platforms

  • windows_x86 / windows_x64 - Windows 32-bit/64-bit
  • linux_x86 / linux_x64 - Linux 32-bit/64-bit
  • unix_x86 / unix_x64 - Unix 32-bit/64-bit
  • apple_x86 / apple_x64 - macOS 32-bit/64-bit
  • *_arm / *_arm64 - ARM 32-bit/64-bit (any OS)

Compiler Flags Configuration

Bodge provides two types of compiler flags for fine-grained control:

  • pre_cxx_flags - Applied before sources in the build command

    • Perfect for SDK setup and early initialization
    • Use for include paths that must be resolved before source compilation
    • Example: -I$VULKAN_SDK/include, -DSDK_EARLY_INIT
  • cxx_flags - Standard compiler flags applied after pre-flags

    • Use for compilation options like -std=c++17, -O2, -Wall
    • Applied in order: global → platform-specific → target-specific

Build Command Order:

compiler → pre_cxx_flags → cxx_flags → includes → sources → output → libraries → linker_flags

Linker Flags Configuration

Bodge supports linker flags at multiple levels for fine-grained control over the linking stage:

  • linker_flags - Raw linker flags passed directly to the linker
    • Applied after libraries in the build command
    • Perfect for system libraries, linker-specific options, and platform-specific linking
    • Use -l prefix for libraries (e.g., -lws2_32)
    • Use -Wl, prefix for linker-specific options (e.g., -Wl,--no-undefined)

Linker flags can be specified at multiple levels:

  1. Global: global_linker_flags: -static, -Wl,--no-undefined
  2. Legacy (single target): linker_flags: -lm, -ldl
  3. Target-specific: myapp.linker_flags: -lws2_32
  4. Platform-specific (global): @windows_x64.linker_flags: -lws2_32, -lpthread
  5. Target + Platform: myapp@windows_x64.linker_flags: -lwinmm

Linker flags are applied in order:

global_linker_flags → @platform.linker_flags → target.linker_flags → target@platform.linker_flags

Common Use Cases:

Windows networking and threading:

@windows_x64.linker_flags: -lws2_32, -lmswsock, -lpthread

Linux threading and real-time:

@linux_x64.linker_flags: -pthread, -lrt

macOS frameworks:

@apple_x64.linker_flags: -framework Foundation, -framework CoreFoundation

Static linking:

global_linker_flags: -static, -static-libgcc, -static-libstdc++

Platform Configuration Syntax

  • platforms: platform1, platform2 - Set default target platforms
  • @platform.property: value - Global platform-specific configuration
  • target@platform.property: value - Target-specific platform configuration
  • target.platforms: platform1, platform2 - Platforms for specific target

Supported Operations in Sequences

  • build:target_name - Build a specific target
  • copy:source->destination - Copy files or directories
  • remove:path - Remove files or directories
  • mkdir:path - Create directories

License

Bodge License (BL-V2.0)

Free for personal use, students, and open source!

  • 🆓 Personal & Open Source: Completely free forever
  • 💼 Commercial Use: Simple, transparent pricing starting at €14/user/year or Sponsoring
  • 📋 Read Full License

Using Bodge at work? Get your commercial license here!