ROOTDIR = os.path.abspath(os.path.dirname(__file__))
+if os.name is 'nt':
+ import ctypes
+ from ctypes import wintypes
+ _GetShortPathNameW = ctypes.windll.kernel32.GetShortPathNameW
+ _GetShortPathNameW.argtypes = [wintypes.LPCWSTR, wintypes.LPWSTR, wintypes.DWORD]
+ _GetShortPathNameW.restype = wintypes.DWORD
+
+def win32_get_short_path_name(long_name):
+ """
+ Gets the short path name of a given long path.
+ http://stackoverflow.com/a/23598461/200291
+ """
+ output_buf_size = 0
+ while True:
+ output_buf = ctypes.create_unicode_buffer(output_buf_size)
+ needed = _GetShortPathNameW(long_name, output_buf, output_buf_size)
+ if output_buf_size >= needed:
+ return output_buf.value
+ else:
+ output_buf_size = needed
+
class Colors:
HEADER = '\033[95m'
OKBLUE = '\033[94m'
from common import get_meson
from common import git
+from common import win32_get_short_path_name
SCRIPTDIR = os.path.dirname(os.path.realpath(__file__))
PREFIX_DIR = os.path.join(SCRIPTDIR, 'prefix')
raise AssertionError('Object {!r} must be a string or a list'.format(o))
def prepend_env_var(env, var, value):
+ # Try not to exceed maximum length limits for env vars on Windows
+ if os.name is 'nt':
+ value = win32_get_short_path_name(value)
env_val = env.get(var, '')
val = os.pathsep + value + os.pathsep
# Don't add the same value twice