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

Improve toolchain API: defaults #137

Open GPMueller opened 2 years ago

GPMueller commented 2 years ago

This is a follow-up to issue #123, which was implemented on PR #129. An open point that wasn't addressed:

refactor the way default flags etc. work to make custom toolchains safer and easier to create

Currently, the default clang toolchain specifies

DEFAULT_COMPILE_FLAGS = {
    BuildType.Default: [],
    BuildType.Release: [],
    BuildType.RelWithDebInfo: [],
    BuildType.Debug: [],
    BuildType.Coverage: [],
}

DEFAULT_LINK_FLAGS = {
    BuildType.Default: [],
    BuildType.Release: [],
    BuildType.RelWithDebInfo: [],
    BuildType.Debug: [],
    BuildType.Coverage: [],
}

PLATFORM_DEFAULTS = {
    "linux": {
        "PLATFORM": "linux",
        "EXECUTABLE_PREFIX": "",
        "EXECUTABLE_SUFFIX": "",
        "SHARED_LIBRARY_PREFIX": "lib",
...

which, in a sense, specifies an implicit API through these dictionaries being used across the codebase. We should make this a more explicit API and make it easier to override parts of it, without having to copy-paste entire dictionaries from our sources.