aboutsummaryrefslogtreecommitdiff
path: root/toolsrc/include/PostBuildLint_BuildType.h
blob: 58bb20766ec650cb91629e0152432b4a45f249a6 (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
#pragma once
#include "CStringView.h"
#include "PostBuildLint_ConfigurationType.h"
#include "PostBuildLint_LinkageType.h"
#include <array>
#include <regex>

namespace vcpkg::PostBuildLint
{
    struct BuildType
    {
        enum class BackingEnum
        {
            DEBUG_STATIC = 1,
            DEBUG_DYNAMIC,
            RELEASE_STATIC,
            RELEASE_DYNAMIC
        };

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

        BuildType() = delete;

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

        constexpr operator BackingEnum() const { return backing_enum; }

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

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

    namespace BuildTypeC
    {
        namespace CC = ConfigurationTypeC;
        namespace LC = LinkageTypeC;
        using BE = BuildType::BackingEnum;

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

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

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