Trick-17 / clang-build

Clang-based cross platform build system written in Python
https://clang-build.readthedocs.io
MIT License
8 stars 3 forks source link
build-system c-plus-plus clang cpp cross-platform python

Clang-build

PyPI version CI Code quality Coverage

[Demonstration]()

Find the full documentation at https://clang-build.readthedocs.io

Motivation:

Goals:

What it's not designed to do:

Related resources:

Usage

In order to run clang-build, you only need Clang and Python3. Install via pip install clang-build (add the --user flag if you don't have admin rights).

Running clang-build will try to build the current directory. The command-line options include

The given directory will be searched for a clang-build.toml file, which you can use to configure your build targets, if necessary. However, if you only want to build an executable, you will likely not even need a build file.

clang-build tries to use sane defaults, designed to make most projects very easy to configure and even complex projects far easier than with common build or meta-build systems.

Real-World Examples

Examples of real-world used and tested projects, which can be easily be integrated into your project using clang-build:

General Ideas

Note: not all of these are implemented, yet.

What should be trivial

This would be things that require only the invocation of clang-build and no build file.

Sane defaults and default behaviour:

What should be easy

This would be things that only require a minimal TOML project file

What should be possible

Steps that would involve more effort from the user, including possibly some python code

Project File By Example

A single target

Note:

# Top-level brackets indicate a target
[hello]
output_name = "runHello"

Two targets with linking

# Build a library
[mylib]
target_type = "shared library"

# Build an executable and link the library
[myexe]
output_name = "runExe"
target_type = "executable"
dependencies = ["mylib"]
[myexe.flags]
link = ["-DMYEXE_SOME_DEFINE"]

Adding external dependencies

Note:

[mylib]
url = "https://github.com/trick-17/mylib"
version = 1.1 # will try to `git checkout 1.1`
directory = "sources"           # will point to "build/mylib/external_sources/sources"
include_directories = ["mylib/include"] # will point to "build/mylib/external_sources/sources/mylib/include"
sources = ["mylib/src/*"]     # will list everything inside "build/mylib/external_sources/sources/mylib/src"
# Maybe we need to deactivate annoying warnings coming from the library
[mylib.flags]
compile = ["-Wno-deprecated-declarations", "-Wno-self-assign"]

# Build an executable and link the library
[myexe]
dependencies = ["mylib"]