@@ -49,23 +49,24 @@ def copy_cmd(ctx, src, dst):
49
49
50
50
# Flags are documented at
51
51
# 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
53
54
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 "
55
56
mnemonic = "CopyDirectory"
56
57
progress_message = "Copying directory %s" % src .path
57
58
else :
58
- cmd_tmpl = "@copy /Y \" %s \" \" %s \" >NUL"
59
+ cmd_tmpl = "@copy /Y \" {src} \" \" {dst} \" >NUL"
59
60
mnemonic = "CopyFile"
60
61
progress_message = "Copying file %s" % src .path
61
62
62
63
ctx .actions .write (
63
64
output = bat ,
64
65
# Do not use lib/shell.bzl's shell.quote() method, because that uses
65
66
# 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 ("/" , "\\ " ),
69
70
),
70
71
is_executable = True ,
71
72
)
0 commit comments