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.

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.0.tar.gz (7.6 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.0-py3-none-any.whl (7.5 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: buildcpp-0.2.0.tar.gz
  • Upload date:
  • Size: 7.6 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.0.tar.gz
Algorithm Hash digest
SHA256 7954580f1e76a3d41266df9938d1e8bb0208a27816ef0f800c3ac9494616941d
MD5 64ca7a3847f970492debd2363c373d04
BLAKE2b-256 d585a806a6ccda5a6bd9d7c267811229669ac31c7eb38a74b9f75cc97d6f47aa

See more details on using hashes here.

File details

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

File metadata

  • Download URL: buildcpp-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 7.5 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.0-py3-none-any.whl
Algorithm Hash digest
SHA256 d3be7366d8518082ee7add2156f6ca6d61f9f70d53be4a502e77a59964f72d52
MD5 ae0c9eb8c13e7376a9cc296353746e8a
BLAKE2b-256 383f9d65cd18da512b30a358c903cc1658b3e250d9216ecc86c991199a253dd1

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