Skip to main content

A build system for C++.

Project description

buildcpp

MIT-LICENSE PyPI

Buildcpp is an innovative build system that combines Python's expressive power with the reliability of CMake. You no longer need to deal with complex CMake syntax—simply manage your C++ projects using clear and maintainable Python code.

Why buildcpp?

Setting up a C++ build process has traditionally been a tedious task. From Makefile to CMake and Xmake, developers have long sought ways to simplify building C++ projects. However, the inherent complexity of C++ builds remains. Buildcpp addresses this by using Python’s approachable syntax to write build scripts, while providing essential utilities for C++ project building.

How It Works

Buildcpp serves the same role as CMake within the build system. Just as CMake scripts generate corresponding Makefiles when you run cmake, Buildcpp is designed to let you write Python scripts that, when executed, generate CMake scripts for the build process. This approach avoids reinventing the wheel and ensures Buildcpp is inherently cross-platform, leveraging the cross-platform nature of both Python and CMake.

Getting Started

Buildcpp is essentially a Python package. First, ensure you have a Python 3.7+ environment installed on your system.

Run the following command in your terminal:

pip install buildcpp

Once installed, you’re ready to use Buildcpp.

For example, create a new directory for your C++ project and add a new Python file inside it. The folder and Python file names are not restricted—you can choose any name you prefer. Note that the Python file name will be used as the project name.

myproject
└── myproject.py

Now you can add C++ source files as you normally would. Buildcpp does not impose any specific structure here. For instance, you might create a src folder to store .cpp files. Write a simple Hello World program in a C++ file. Your directory structure might look like this:

myproject
├── myproject.py
└── src
    └── main.cpp

Next, write the Buildcpp build script:

from buildcpp import *

target = Target('demo')\
    .add_source(Scope.PUBLIC, find_files(SRC_ROOT, '*.cpp'))

if __name__ == '__main__':
    builder = Builder()
    builder.attach(target)
    builder.build()

Here, we first create a Target object named demo. We then add source files to the target using the add_source method. The Scope.PUBLIC parameter indicates that these files are publicly accessible to other targets. The find_files function locates all .cpp files in the src directory.

We then create a Builder object, attach the target to it, and call the build method to generate the Makefile and compile the project.

For more detailed information, check out the documentation.

LICENSE

MIT License

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

buildcpp-0.2.1.tar.gz (8.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

buildcpp-0.2.1-py3-none-any.whl (8.9 kB view details)

Uploaded Python 3

File details

Details for the file buildcpp-0.2.1.tar.gz.

File metadata

  • Download URL: buildcpp-0.2.1.tar.gz
  • Upload date:
  • Size: 8.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.3

File hashes

Hashes for buildcpp-0.2.1.tar.gz
Algorithm Hash digest
SHA256 3d6eb042e6121a8fd04a34683186986744dd8b2ad87d481f20c09e761ea39f12
MD5 1a6f1786ae0aa5c655d347ecb89f3b8c
BLAKE2b-256 6bfde75009cb01368da211f6c38f1d8a2ec26d2a3345f598aa916c7855cbbcd8

See more details on using hashes here.

File details

Details for the file buildcpp-0.2.1-py3-none-any.whl.

File metadata

  • Download URL: buildcpp-0.2.1-py3-none-any.whl
  • Upload date:
  • Size: 8.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.3

File hashes

Hashes for buildcpp-0.2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 f87c8e8e34912622322be8c89094962ed8ee61c5fb4b2f67305c0b2c4214df6e
MD5 3f503333760376096265c43dab9fe0b4
BLAKE2b-256 3cd2bd1641913684dc0956b1d09c9a371fb69a21f40e72c47ace173627643e44

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page