diff options
author | Thibault Saunier <tsaunier@igalia.com> | 2019-08-02 19:22:16 -0700 |
---|---|---|
committer | Thibault Saunier <tsaunier@igalia.com> | 2019-10-01 09:20:25 -0300 |
commit | 3d8662ebfe778c85319c473b16ecd4d60cb6d137 (patch) | |
tree | 4bc1602d27a3345ba6707884e810c311fee15e1e /scripts | |
parent | fe39bd302779d30c876ef028ab321b4565d15b10 (diff) | |
download | gstreamer-3d8662ebfe778c85319c473b16ecd4d60cb6d137.tar.gz |
Add support for wine+mingw environments
Diffstat (limited to 'scripts')
-rw-r--r-- | scripts/common.py | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/scripts/common.py b/scripts/common.py index 5cea742027..4fea527359 100644 --- a/scripts/common.py +++ b/scripts/common.py @@ -5,6 +5,7 @@ import shutil import argparse import platform import subprocess +import uuid ROOTDIR = os.path.abspath(os.path.dirname(__file__)) @@ -31,6 +32,33 @@ def win32_get_short_path_name(long_name): else: output_buf_size = needed + +def get_wine_shortpath(winecmd, wine_paths): + seen = set() + wine_paths += [p for p in wine_paths if not (p in seen or seen.add(p))] + + getShortPathScript = '%s.bat' % str(uuid.uuid4()).lower()[:5] + with open(getShortPathScript, mode='w') as f: + f.write("@ECHO OFF\nfor %%x in (%*) do (\n echo|set /p=;%~sx\n)\n") + f.flush() + try: + with open(os.devnull, 'w') as stderr: + wine_path = subprocess.check_output( + winecmd + + ['cmd', '/C', getShortPathScript] + wine_paths, + stderr=stderr).decode('utf-8') + except subprocess.CalledProcessError as e: + print("Could not get short paths: %s" % e) + wine_path = ';'.join(wine_paths) + finally: + os.remove(getShortPathScript) + if len(wine_path) > 2048: + raise AssertionError('WINEPATH size {} > 2048' + ' this will cause random failure.'.format( + len(wine_path))) + return wine_path + + class Colors: HEADER = '\033[95m' OKBLUE = '\033[94m' |