Add mechanism to override OS (for testing purposes) (#993)
Similar to `EMSDK_ARCH` which I added in #935.
This commit is contained in:
30
emsdk.py
30
emsdk.py
@@ -58,10 +58,6 @@ extra_release_tag = None
|
|||||||
VERBOSE = int(os.getenv('EMSDK_VERBOSE', '0'))
|
VERBOSE = int(os.getenv('EMSDK_VERBOSE', '0'))
|
||||||
TTY_OUTPUT = not os.getenv('EMSDK_NOTTY', not sys.stdout.isatty())
|
TTY_OUTPUT = not os.getenv('EMSDK_NOTTY', not sys.stdout.isatty())
|
||||||
|
|
||||||
WINDOWS = False
|
|
||||||
if os.name == 'nt' or (os.getenv('SYSTEMROOT') is not None and 'windows' in os.getenv('SYSTEMROOT').lower()) or (os.getenv('COMSPEC') is not None and 'windows' in os.getenv('COMSPEC').lower()):
|
|
||||||
WINDOWS = True
|
|
||||||
|
|
||||||
|
|
||||||
def errlog(msg):
|
def errlog(msg):
|
||||||
print(msg, file=sys.stderr)
|
print(msg, file=sys.stderr)
|
||||||
@@ -72,9 +68,27 @@ def exit_with_error(msg):
|
|||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
|
|
||||||
|
WINDOWS = False
|
||||||
MINGW = False
|
MINGW = False
|
||||||
MSYS = False
|
MSYS = False
|
||||||
if os.getenv('MSYSTEM'):
|
MACOS = False
|
||||||
|
LINUX = False
|
||||||
|
|
||||||
|
if 'EMSDK_OS' in os.environ:
|
||||||
|
EMSDK_OS = os.environ['EMSDK_OS']
|
||||||
|
if EMSDK_OS == 'windows':
|
||||||
|
WINDOWS = True
|
||||||
|
elif EMSDK_OS == 'linux':
|
||||||
|
LINUX = True
|
||||||
|
elif EMSDK_OS == 'macos':
|
||||||
|
MACOS = True
|
||||||
|
else:
|
||||||
|
assert False
|
||||||
|
else:
|
||||||
|
if os.name == 'nt' or (os.getenv('SYSTEMROOT') is not None and 'windows' in os.getenv('SYSTEMROOT').lower()) or (os.getenv('COMSPEC') is not None and 'windows' in os.getenv('COMSPEC').lower()):
|
||||||
|
WINDOWS = True
|
||||||
|
|
||||||
|
if os.getenv('MSYSTEM'):
|
||||||
MSYS = True
|
MSYS = True
|
||||||
# Some functions like os.path.normpath() exhibit different behavior between
|
# Some functions like os.path.normpath() exhibit different behavior between
|
||||||
# different versions of Python, so we need to distinguish between the MinGW
|
# different versions of Python, so we need to distinguish between the MinGW
|
||||||
@@ -85,12 +99,10 @@ if os.getenv('MSYSTEM'):
|
|||||||
# https://stackoverflow.com/questions/37460073/msys-vs-mingw-internal-environment-variables
|
# https://stackoverflow.com/questions/37460073/msys-vs-mingw-internal-environment-variables
|
||||||
errlog('Warning: MSYSTEM environment variable is present, and is set to "' + os.getenv('MSYSTEM') + '". This shell has not been tested with emsdk and may not work.')
|
errlog('Warning: MSYSTEM environment variable is present, and is set to "' + os.getenv('MSYSTEM') + '". This shell has not been tested with emsdk and may not work.')
|
||||||
|
|
||||||
MACOS = False
|
if platform.mac_ver()[0] != '':
|
||||||
if platform.mac_ver()[0] != '':
|
|
||||||
MACOS = True
|
MACOS = True
|
||||||
|
|
||||||
LINUX = False
|
if not MACOS and (platform.system() == 'Linux'):
|
||||||
if not MACOS and (platform.system() == 'Linux'):
|
|
||||||
LINUX = True
|
LINUX = True
|
||||||
|
|
||||||
UNIX = (MACOS or LINUX)
|
UNIX = (MACOS or LINUX)
|
||||||
|
|||||||
Reference in New Issue
Block a user