From 3d8662ebfe778c85319c473b16ecd4d60cb6d137 Mon Sep 17 00:00:00 2001 From: Thibault Saunier Date: Fri, 2 Aug 2019 19:22:16 -0700 Subject: Add support for wine+mingw environments --- scripts/common.py | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) (limited to 'scripts') 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' -- cgit v1.2.1