aboutsummaryrefslogtreecommitdiff
path: root/toolsrc/include/PostBuildLint_BuildType.h
blob: 38ad3084e2ae4f228ce5d9b66b7b1a0abd81a8d8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
#pragma once
#include "CStringView.h"
#include "vcpkg_Build.h"
#include <array>
#include <regex>

namespace vcpkg::PostBuildLint
{
    enum class ConfigurationType
    {
        DEBUG,
        RELEASE,
    };

    struct BuildType
    {
        enum class BackingEnum
        {
            DEBUG_STATIC = 1,
            DEBUG_DYNAMIC,
            RELEASE_STATIC,
            RELEASE_DYNAMIC
        };

        static BuildType value_of(const ConfigurationType& config, const Build::LinkageType& linkage);

        BuildType() = delete;

        constexpr BuildType(const BackingEnum backing_enum,
                            const ConfigurationType config,
                            const Build::LinkageType linkage)
            : backing_enum(backing_enum), m_config(config), m_linkage(linkage)
        {
        }

        constexpr operator BackingEnum() const { return backing_enum; }

        const ConfigurationType& config() const;
        const Build::LinkageType& linkage() const;
        const std::regex& crt_regex() const;
        const std::string& to_string() const;

    private:
        BackingEnum backing_enum;
        ConfigurationType m_config;
        Build::LinkageType m_linkage;
    };

    namespace BuildTypeC
    {
        using Build::LinkageType;
        using BE = BuildType::BackingEnum;

        static constexpr CStringView ENUM_NAME = "vcpkg::PostBuildLint::BuildType";

        static constexpr BuildType DEBUG_STATIC = {BE::DEBUG_STATIC, ConfigurationType::DEBUG, LinkageType::STATIC};
        static constexpr BuildType DEBUG_DYNAMIC = {BE::DEBUG_DYNAMIC, ConfigurationType::DEBUG, LinkageType::DYNAMIC};
        static constexpr BuildType RELEASE_STATIC = {
            BE::RELEASE_STATIC, ConfigurationType::RELEASE, LinkageType::STATIC};
        static constexpr BuildType RELEASE_DYNAMIC = {
            BE::RELEASE_DYNAMIC, ConfigurationType::RELEASE, LinkageType::DYNAMIC};

        static constexpr std::array<BuildType, 4> VALUES = {
            DEBUG_STATIC, DEBUG_DYNAMIC, RELEASE_STATIC, RELEASE_DYNAMIC};
    }
}