aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/project/linkage.py
blob: 29e1fffe087a5463ec044bbca075c7900359c930 (plain) (blame)
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
# Copyright (c) 2020 Egor Tensin <Egor.Tensin@gmail.com>
# This file is part of the "cmake-common" project.
# For details, see https://github.com/egor-tensin/cmake-common.
# Distributed under the MIT License.

import argparse
from enum import Enum


class Linkage(Enum):
    STATIC = 'static'
    SHARED = 'shared'

    def __str__(self):
        return str(self.value)

    @staticmethod
    def all():
        return tuple(Linkage)

    @staticmethod
    def parse(s):
        try:
            return Linkage(s)
        except ValueError as e:
            raise argparse.ArgumentTypeError(f'invalid linkage: {s}') from e

    def b2_args(self, name='link'):
        return [f'{name}={self}']