From cded15b1d06e743ebd8bf4dd4e4a317a67b3b29f Mon Sep 17 00:00:00 2001 From: Greg Magolan Date: Wed, 26 Jan 2022 23:12:53 -0800 Subject: [PATCH] fix: use robocopy in copy_file#is_directory so we don't hit 254 file path limit of xcopy --- .../rules/private/copy_file_private.bzl | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/third_party/github.com/bazelbuild/bazel-skylib/rules/private/copy_file_private.bzl b/third_party/github.com/bazelbuild/bazel-skylib/rules/private/copy_file_private.bzl index 4df6e68289..1a4fdd63e5 100644 --- a/third_party/github.com/bazelbuild/bazel-skylib/rules/private/copy_file_private.bzl +++ b/third_party/github.com/bazelbuild/bazel-skylib/rules/private/copy_file_private.bzl @@ -49,13 +49,14 @@ def copy_cmd(ctx, src, dst): # Flags are documented at # https://docs.microsoft.com/en-us/windows-server/administration/windows-commands/copy - # https://docs.microsoft.com/en-us/windows-server/administration/windows-commands/xcopy + # https://docs.microsoft.com/en-us/windows-server/administration/windows-commands/robocopy + # NB: robocopy return non-zero exit codes on success so we must exit 0 after calling it if dst.is_directory: - cmd_tmpl = "@xcopy \"%s\" \"%s\\\" /V /E /H /Y /Q >NUL" + cmd_tmpl = "@robocopy \"{src}\" \"{dst}\" /E >NUL & @exit 0" mnemonic = "CopyDirectory" progress_message = "Copying directory %s" % src.path else: - cmd_tmpl = "@copy /Y \"%s\" \"%s\" >NUL" + cmd_tmpl = "@copy /Y \"{src}\" \"{dst}\" >NUL" mnemonic = "CopyFile" progress_message = "Copying file %s" % src.path @@ -63,9 +64,9 @@ def copy_cmd(ctx, src, dst): output = bat, # Do not use lib/shell.bzl's shell.quote() method, because that uses # Bash quoting syntax, which is different from cmd.exe's syntax. - content = cmd_tmpl % ( - src.path.replace("/", "\\"), - dst.path.replace("/", "\\"), + content = cmd_tmpl.format( + src = src.path.replace("/", "\\"), + dst = dst.path.replace("/", "\\"), ), is_executable = True, )