@@ -18,7 +18,7 @@ This rule copies a directory to another location using Bash (on Linux/macOS) or
1818cmd.exe (on Windows).
1919"""
2020
21- load (":copy_common.bzl" , "COPY_EXECUTION_REQUIREMENTS" )
21+ load (":copy_common.bzl" , "COPY_EXECUTION_REQUIREMENTS" , "OsInfo" )
2222
2323def _copy_cmd (ctx , src , dst ):
2424 # Most Windows binaries built with MSVC use a certain argument quoting
@@ -108,7 +108,7 @@ def copy_directory_action(ctx, src, dst, is_windows = False):
108108
109109def _copy_directory_impl (ctx ):
110110 dst = ctx .actions .declare_directory (ctx .attr .out )
111- copy_directory_action (ctx , ctx .file .src , dst , ctx .attr .is_windows )
111+ copy_directory_action (ctx , ctx .file .src , dst , ctx .attr ._exec_is_windows [ OsInfo ]. is_windows )
112112
113113 files = depset (direct = [dst ])
114114 runfiles = ctx .runfiles (files = [dst ])
@@ -120,10 +120,15 @@ _copy_directory = rule(
120120 provides = [DefaultInfo ],
121121 attrs = {
122122 "src" : attr .label (mandatory = True , allow_single_file = True ),
123- "is_windows" : attr .bool (mandatory = True ),
124123 # Cannot declare out as an output here, because there's no API for declaring
125124 # TreeArtifact outputs.
126125 "out" : attr .string (mandatory = True ),
126+ "_exec_is_windows" : attr .label (
127+ default = ":is_windows" ,
128+ # The exec transition must match the exec group of the actions, which in
129+ # this case is the default exec group.
130+ cfg = "exec" ,
131+ ),
127132 },
128133)
129134
@@ -147,10 +152,6 @@ def copy_directory(name, src, out, **kwargs):
147152 _copy_directory (
148153 name = name ,
149154 src = src ,
150- is_windows = select ({
151- "@bazel_tools//src/conditions:host_windows" : True ,
152- "//conditions:default" : False ,
153- }),
154155 out = out ,
155156 ** kwargs
156157 )
0 commit comments