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.1.1.tar.gz (6.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.1.1-py3-none-any.whl (6.6 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: buildcpp-0.1.1.tar.gz
  • Upload date:
  • Size: 6.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.1.1.tar.gz
Algorithm Hash digest
SHA256 9a0071a839eb8bb6d3c810228efa061b9efc4e93447af18127399b50984d6455
MD5 53a3147c084cd8164b3bf642dfdcdc92
BLAKE2b-256 c7e758d617e117e5106eddccc61edfbb13038f011fb33bb92ff94d1470092a98

See more details on using hashes here.

File details

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

File metadata

  • Download URL: buildcpp-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 6.6 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.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 87217893ea68c1f4cc0e834f21906cf26c5093ba86c1632b13bd49dcec7a4589
MD5 cb7889674dfc85f224b93e61d008de5b
BLAKE2b-256 c3c483e73387485b20a7ae74a88703b3dca6e127d24bce18e348313a2ce83eab

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