1414
1515"""Common code for sh_binary and sh_test rules."""
1616
17+ load (":providers.bzl" , "ShBinaryInfo" , "ShInfo" )
18+
1719visibility (["//shell" ])
1820
1921_SH_TOOLCHAIN_TYPE = Label ("//shell:toolchain_type" )
@@ -24,6 +26,9 @@ def _to_rlocation_path(ctx, file):
2426 else :
2527 return ctx .workspace_name + "/" + file .short_path
2628
29+ # A memory optimization for an empty provider
30+ _SHARED_PROVIDER = ShBinaryInfo ()
31+
2732def _sh_executable_impl (ctx ):
2833 if len (ctx .files .srcs ) != 1 :
2934 fail ("you must specify exactly one file in 'srcs'" , attr = "srcs" )
@@ -117,6 +122,7 @@ exec "$(rlocation "{src}")" "$@"
117122 default_info ,
118123 instrumented_files_info ,
119124 run_environment_info ,
125+ _SHARED_PROVIDER ,
120126 ]
121127
122128_WINDOWS_EXECUTABLE_EXTENSIONS = [
@@ -200,7 +206,7 @@ The file containing the shell script.
200206 flags = ["SKIP_CONSTRAINTS_OVERRIDE" ],
201207 ),
202208 "deps" : attr .label_list (
203- allow_rules = ["sh_library" ],
209+ providers = [ShInfo ],
204210 doc = """
205211The list of "library" targets to be aggregated into this target.
206212See general comments about <code>deps</code>
@@ -228,5 +234,6 @@ most build rules</a>.
228234 toolchains = [
229235 config_common .toolchain_type (_SH_TOOLCHAIN_TYPE , mandatory = False ),
230236 ],
237+ provides = [ShBinaryInfo ],
231238 ** kwargs
232239 )
0 commit comments