mirror of
https://github.com/intel/llvm.git
synced 2026-01-15 12:25:46 +08:00
*** to conform to clang-format’s LLVM style. This kind of mass change has
*** two obvious implications:
Firstly, merging this particular commit into a downstream fork may be a huge
effort. Alternatively, it may be worth merging all changes up to this commit,
performing the same reformatting operation locally, and then discarding the
merge for this particular commit. The commands used to accomplish this
reformatting were as follows (with current working directory as the root of
the repository):
find . \( -iname "*.c" -or -iname "*.cpp" -or -iname "*.h" -or -iname "*.mm" \) -exec clang-format -i {} +
find . -iname "*.py" -exec autopep8 --in-place --aggressive --aggressive {} + ;
The version of clang-format used was 3.9.0, and autopep8 was 1.2.4.
Secondly, “blame” style tools will generally point to this commit instead of
a meaningful prior commit. There are alternatives available that will attempt
to look through this change and find the appropriate prior commit. YMMV.
llvm-svn: 280751
96 lines
2.8 KiB
Python
96 lines
2.8 KiB
Python
""" Utility module to determine the OS Python running on
|
|
|
|
--------------------------------------------------------------------------
|
|
File: utilsOsType.py
|
|
|
|
Overview: Python module to supply functions and an enumeration to
|
|
help determine the platform type, bit size and OS currently
|
|
being used.
|
|
--------------------------------------------------------------------------
|
|
|
|
"""
|
|
|
|
# Python modules:
|
|
import sys # Provide system information
|
|
|
|
# Third party modules:
|
|
|
|
# In-house modules:
|
|
|
|
# Instantiations:
|
|
|
|
# Enumerations:
|
|
#-----------------------------------------------------------------------------
|
|
# Details: Class to implement a 'C' style enumeration type.
|
|
# Gotchas: None.
|
|
# Authors: Illya Rudkin 28/11/2013.
|
|
# Changes: None.
|
|
#--
|
|
if sys.version_info.major >= 3:
|
|
from enum import Enum
|
|
|
|
class EnumOsType(Enum):
|
|
Unknown = 0
|
|
Darwin = 1
|
|
FreeBSD = 2
|
|
Linux = 3
|
|
NetBSD = 4
|
|
Windows = 5
|
|
else:
|
|
class EnumOsType(object):
|
|
values = ["Unknown",
|
|
"Darwin",
|
|
"FreeBSD",
|
|
"Linux",
|
|
"NetBSD",
|
|
"Windows"]
|
|
|
|
class __metaclass__(type):
|
|
#++----------------------------------------------------------------
|
|
# Details: Fn acts as an enumeration.
|
|
# Args: vName - (R) Enumeration to match.
|
|
# Returns: Int - Matching enumeration/index.
|
|
# Throws: None.
|
|
#--
|
|
|
|
def __getattr__(cls, vName):
|
|
return cls.values.index(vName)
|
|
|
|
#++---------------------------------------------------------------------------
|
|
# Details: Reverse fast lookup of the values list.
|
|
# Args: vI - (R) Index / enumeration.
|
|
# Returns: Str - text description matching enumeration.
|
|
# Throws: None.
|
|
#--
|
|
def name_of(cls, vI):
|
|
return EnumOsType.values[vI]
|
|
|
|
#-----------------------------------------------------------------------------
|
|
#-----------------------------------------------------------------------------
|
|
#-----------------------------------------------------------------------------
|
|
|
|
#++---------------------------------------------------------------------------
|
|
# Details: Determine what operating system is currently running on.
|
|
# Args: None.
|
|
# Returns: EnumOsType - The OS type being used ATM.
|
|
# Throws: None.
|
|
#--
|
|
|
|
|
|
def determine_os_type():
|
|
eOSType = EnumOsType.Unknown
|
|
|
|
strOS = sys.platform
|
|
if strOS == "darwin":
|
|
eOSType = EnumOsType.Darwin
|
|
elif strOS.startswith("freebsd"):
|
|
eOSType = EnumOsType.FreeBSD
|
|
elif strOS.startswith("linux"):
|
|
eOSType = EnumOsType.Linux
|
|
elif strOS.startswith("netbsd"):
|
|
eOSType = EnumOsType.NetBSD
|
|
elif strOS == "win32":
|
|
eOSType = EnumOsType.Windows
|
|
|
|
return eOSType
|