ICU-20858 Fix Windows data build failure with long paths

This commit is contained in:
Jeff Genovy 2019-10-09 18:40:38 -07:00
parent c6d2de5222
commit 1e65be7d1a

View File

@ -120,12 +120,15 @@ def run_shell_command(command_line, platform, verbose):
# If the command line length on Windows exceeds the absolute maximum that CMD supports (8191), then
# we temporarily switch over to use PowerShell for the command, and then switch back to CMD.
# We don't want to use PowerShell for everything though, as it tends to be slower.
if (platform == "windows") and (len(command_line) > 8190):
if verbose:
print("Command length exceeds the max length for CMD on Windows, using PowerShell instead.")
if (platform == "windows"):
previous_comspec = os.environ["COMSPEC"]
os.environ["COMSPEC"] = 'powershell'
changed_windows_comspec = True
# Add 7 to the length for the argument /c with quotes.
# For example: C:\WINDOWS\system32\cmd.exe /c "<command_line>"
if ((len(previous_comspec) + len(command_line) + 7) > 8190):
if verbose:
print("Command length exceeds the max length for CMD on Windows, using PowerShell instead.")
os.environ["COMSPEC"] = 'powershell'
changed_windows_comspec = True
if verbose:
print("Running: %s" % command_line)
returncode = subprocess.call(