From ff1ad48eb765e81ee04588cdac97a51f18c1e819 Mon Sep 17 00:00:00 2001 From: Zvonimir Pervan Date: Thu, 1 Sep 2022 13:13:39 +0200 Subject: [PATCH] Disable echoing CMD code in copy_directory and copy_file rules on Windows --- rules/private/copy_directory_private.bzl | 13 +++++++------ rules/private/copy_file_private.bzl | 5 ++++- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/rules/private/copy_directory_private.bzl b/rules/private/copy_directory_private.bzl index da60c8b..cc518be 100644 --- a/rules/private/copy_directory_private.bzl +++ b/rules/private/copy_directory_private.bzl @@ -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}" diff --git a/rules/private/copy_file_private.bzl b/rules/private/copy_file_private.bzl index 250418a..2d29d32 100644 --- a/rules/private/copy_file_private.bzl +++ b/rules/private/copy_file_private.bzl @@ -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("/", "\\"), ),