diff --git a/third_party/repo.bzl b/third_party/repo.bzl index 4ab132c39f4..4fc91afb36c 100644 --- a/third_party/repo.bzl +++ b/third_party/repo.bzl @@ -61,12 +61,13 @@ def _repos_are_siblings(): return Label("@foo//bar").workspace_root.startswith("../") # Apply a patch_file to the repository root directory -# Runs 'git apply' +# Runs 'git apply' on Unix, 'patch -p1' on Windows. def _apply_patch(ctx, patch_file): - cmd = _wrap_bash_cmd( - ctx, - ["git", "apply", "-v", ctx.path(patch_file)], - ) + if _is_windows(ctx): + patch_command = ["patch", "-p1", "-d", ctx.path("."), "-i", ctx.path(patch_file)] + else: + patch_command = ["git", "apply", "-v", ctx.path(patch_file)] + cmd = _wrap_bash_cmd(ctx, patch_command) _execute_and_check_ret_code(ctx, cmd) def _apply_delete(ctx, paths):