@@ -49,23 +49,24 @@ def copy_cmd(ctx, src, dst):
4949
5050 # Flags are documented at
5151 # https://docs.microsoft.com/en-us/windows-server/administration/windows-commands/copy
52- # https://docs.microsoft.com/en-us/windows-server/administration/windows-commands/xcopy
52+ # https://docs.microsoft.com/en-us/windows-server/administration/windows-commands/robocopy
53+ # NB: robocopy return non-zero exit codes on success so we must exit 0 after calling it
5354 if dst .is_directory :
54- cmd_tmpl = "@xcopy \" %s \" \" %s \\ \ " /V /E /H /Y /Q >NUL "
55+ cmd_tmpl = "@robocopy \" {src} \" \" {dst} \ " /E >NUL & @exit 0 "
5556 mnemonic = "CopyDirectory"
5657 progress_message = "Copying directory %s" % src .path
5758 else :
58- cmd_tmpl = "@copy /Y \" %s \" \" %s \" >NUL"
59+ cmd_tmpl = "@copy /Y \" {src} \" \" {dst} \" >NUL"
5960 mnemonic = "CopyFile"
6061 progress_message = "Copying file %s" % src .path
6162
6263 ctx .actions .write (
6364 output = bat ,
6465 # Do not use lib/shell.bzl's shell.quote() method, because that uses
6566 # Bash quoting syntax, which is different from cmd.exe's syntax.
66- content = cmd_tmpl % (
67- src .path .replace ("/" , "\\ " ),
68- dst .path .replace ("/" , "\\ " ),
67+ content = cmd_tmpl . format (
68+ src = src .path .replace ("/" , "\\ " ),
69+ dst = dst .path .replace ("/" , "\\ " ),
6970 ),
7071 is_executable = True ,
7172 )
0 commit comments