22484aefa53e21cc83d2c933581e640a24077d3a
C++ Build Module in Python
This Python module builds C++ projects without CMake, aiming to be:
- Fast
- Automatic
- Cool
Why? Because I'm just not a huge fan of CMake
Setup
For this module to work without any modifications, your project needs to follow a specific directory structure:
src/: Contains your source code files.include/: Holds your header files.build/: Where the output binaries will be placed.
Additionally, you'll need a configuration file named builds.json. Here's an example:
{
"configurations": [
{
"name": "debug",
"build_type": "DEBUG",
"platform": "LINUX_x86_64",
"args": []
}
],
"global_build_args": []
}
Supported builds.json Values
Here's a breakdown of the supported values within your builds.json file:
"name": Specifies the name of the resulting output binary."build_type": Controls the compiler flags used for the build.- Supported values:
DEBUG,TRACE,RELEASE,PROFILE,RELWITHDEBINFO,FASTEST
- Supported values:
"platform": Defines the target platform architecture for compilation.- Supported values:
LINUX_x86_64,LINUX_x86,LINUX_x86_64_V4,MACOS(untested)
- Supported values:
"args": A list of strings containing unique compiler flags and instructions specific to a particular build."global_build_args": A list of strings containing compiler flags and instructions that will be applied to all builds.
Usage
This project is designed to be portable (kinda).
- Clone module into C++ project with supported layout.
- Run with
python compile
Example Usage
oscarg@ws01:~/Development/rpg-game$ ls
build builds.json compile include src
oscarg@ws01:~/Development/rpg-game$ cat builds.json
{
"configurations": [
{
"name": "debug",
"build_type": "DEBUG",
"platform": "LINUX_x86_64",
"args": []
},
{
"name": "trace",
"build_type": "TRACE",
"platform": "LINUX_x86_64",
"args": []
}
],
"global_build_args": ["-lSDL3", "-lSDL3_image", "-lm"]
}oscarg@ws01:~/Development/rpg-game$ python compile
[CppBuilder] 2025-07-07 14:00:37 - DEBUG - 'debug' config loaded from file.
[CppBuilder] 2025-07-07 14:00:37 - DEBUG - 'trace' config loaded from file.
[CppBuilder] 2025-07-07 14:00:37 - INFO - Configurations successfully loaded from 'builds.json'.
[CppBuilder] 2025-07-07 14:00:37 - INFO - Starting builds...
[MultiprocessWorker] 2025-07-07 14:00:37 - DEBUG - Adding task with callable _build_worker
[MultiprocessWorker] 2025-07-07 14:00:37 - DEBUG - Adding task with callable _build_worker
[MultiprocessWorker] 2025-07-07 14:00:37 - DEBUG - Starting with 2 tasks and max 4 processes.
[MultiprocessWorker] 2025-07-07 14:00:37 - DEBUG - All multiprocessing tasks completed.
[CppBuilder] 2025-07-07 14:00:37 - INFO - SUCCESS: Compiled 'build/trace_linux_x86-64'
[CppBuilder] 2025-07-07 14:00:37 - INFO - SUCCESS: Compiled 'build/debug_linux_x86-64'
oscarg@ws01:~/Development/rpg-game$ ls build/
debug_linux_x86-64 res trace_linux_x86-64
oscarg@ws01:~/Development/rpg-game$
Description
Languages
Python
100%