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.2.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.2-py3-none-any.whl (8.9 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: buildcpp-0.2.2.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.2.tar.gz
Algorithm Hash digest
SHA256 7ee73651b3dcbf0f3d663d36e600d3d1961d8c99c2e0c7c3c8aaf9eef8b5658f
MD5 7273ec02daabb970dcc68dbedce59748
BLAKE2b-256 01e73090b2032b947a288a0ee2d90a2a4cfb8ed7716a6f3b8e00f620124743f7

See more details on using hashes here.

File details

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

File metadata

  • Download URL: buildcpp-0.2.2-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.2-py3-none-any.whl
Algorithm Hash digest
SHA256 6f8581f8c22f85535aa274dfb868d30404b0481b7836c7b110e0991f78cecdc1
MD5 fb10fb9fd100ff15f570ac180647e8a5
BLAKE2b-256 58b1bbdda338bcf7e0650f41c004bff0d25512c3c9a825b9cb64751a7b0a0b8b

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