blob: 38dc5d978f9aeca23e2a8b292c6e93405cf6ac76 (
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
30
31
32
33
34
35
36
37
38
39
|
# Copyright (c) 2020 Egor Tensin <egor@tensin.name>
# This file is part of the "cmake-common" project.
# For details, see https://github.com/egor-tensin/cmake-common
# Distributed under the MIT License.
from enum import StrEnum
import platform
class OS(StrEnum):
WINDOWS = "Windows"
LINUX = "Linux"
MACOS = "Darwin"
@staticmethod
def current():
system = platform.system()
try:
return OS(system)
except ValueError:
raise NotImplementedError(f"unsupported OS: {system}")
def on_windows():
return OS.current() is OS.WINDOWS
def on_windows_like():
os = OS.current()
return os is OS.WINDOWS
def on_linux():
return OS.current() is OS.LINUX
def on_linux_like():
os = OS.current()
return os is OS.LINUX or os is OS.MACOS
|