Skip to content

Commit

Permalink
Disable echoing CMD code in copy_directory and copy_file rules on Win…
Browse files Browse the repository at this point in the history
…dows
  • Loading branch information
zpervan committed Sep 15, 2022
1 parent 31ab4c8 commit e83bf25
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
13 changes: 7 additions & 6 deletions rules/private/copy_directory_private.bzl
Expand Up @@ -34,12 +34,13 @@ def _copy_cmd(ctx, src, dst):
# 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
cmd_tmpl = """\
if not exist \"{src}\\\" (
echo Error: \"{src}\" is not a directory
@exit 1
)
@robocopy \"{src}\" \"{dst}\" /E /MIR >NUL & @exit 0
"""
@ECHO OFF
if not exist \"{src}\\\" (
echo Error: \"{src}\" is not a directory
@exit 1
)
@robocopy \"{src}\" \"{dst}\" /E /MIR >NUL & @exit 0
"""
mnemonic = "CopyDirectory"
progress_message = "Copying directory %{input}"

Expand Down
5 changes: 4 additions & 1 deletion rules/private/copy_file_private.bzl
Expand Up @@ -32,7 +32,10 @@ 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 = "@copy /Y \"%s\" \"%s\" >NUL" % (
content = """\
@ECHO OFF
@copy /Y \"%s\" \"%s\" >NUL
""" % (
src.path.replace("/", "\\"),
dst.path.replace("/", "\\"),
),
Expand Down

0 comments on commit e83bf25

Please sign in to comment.