]> granicus.if.org Git - icu/commitdiff
ICU-20858 Fix Windows data build failure with long paths
authorJeff Genovy <29107334+jefgen@users.noreply.github.com>
Thu, 10 Oct 2019 01:40:38 +0000 (18:40 -0700)
committerJeff Genovy <29107334+jefgen@users.noreply.github.com>
Fri, 11 Oct 2019 18:43:04 +0000 (11:43 -0700)
icu4c/source/python/icutools/databuilder/renderers/common_exec.py

index 838b121afe565856ab9dbca347a0ce420ce3feed..3623441555df2e09eaa8e909cfab407b2567a662 100644 (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(