@@ -129,13 +129,14 @@ def generate_rb_binary_script(ctx, binary, bundler = False, args = [], env = {},
129129# buildifier: disable=function-docstring
130130def rb_binary_impl (ctx ):
131131 bundler = False
132+ bundler_srcs = []
132133 env = {}
133134 java_bin = ""
134135
135136 # TODO: avoid expanding the depset to a list, it may be expensive in a large graph
136- transitive_data = get_transitive_data (ctx .files .data , ctx .attr .deps ). to_list ()
137- transitive_deps = get_transitive_deps (ctx .attr .deps ). to_list ()
138- transitive_srcs = get_transitive_srcs (ctx .files .srcs , ctx .attr .deps ). to_list ()
137+ transitive_data = get_transitive_data (ctx .files .data , ctx .attr .deps )
138+ transitive_deps = get_transitive_deps (ctx .attr .deps )
139+ transitive_srcs = get_transitive_srcs (ctx .files .srcs , ctx .attr .deps )
139140
140141 ruby_toolchain = ctx .toolchains ["@rules_ruby//ruby:toolchain_type" ]
141142 if ctx .attr .ruby != None :
@@ -148,28 +149,30 @@ def rb_binary_impl(ctx):
148149 tools .extend (java_toolchain .java_runtime .files .to_list ())
149150 java_bin = java_toolchain .java_runtime .java_executable_runfiles_path [3 :]
150151
151- for dep in transitive_deps :
152+ for dep in transitive_deps . to_list () :
152153 # TODO: Remove workspace name check together with `rb_bundle()`
153154 if dep .label .workspace_name .endswith ("bundle" ):
154155 bundler = True
155156
156157 if BundlerInfo in dep :
157158 info = dep [BundlerInfo ]
158- transitive_srcs .extend ([info .gemfile , info .bin , info .path ])
159+ bundler_srcs .extend ([info .gemfile , info .bin , info .path ])
159160 bundler = True
160161
161162 # See https://bundler.io/v2.5/man/bundle-config.1.html for confiugration keys.
162163 env .update ({
163164 "BUNDLE_GEMFILE" : _to_rlocation_path (info .gemfile ),
164165 "BUNDLE_PATH" : _to_rlocation_path (info .path ),
165166 })
167+ if len (bundler_srcs ) > 0 :
168+ transitive_srcs = depset (bundler_srcs , transitive = [transitive_srcs ])
166169
167170 bundle_env = get_bundle_env (ctx .attr .env , ctx .attr .deps )
168171 env .update (bundle_env )
169172 env .update (ruby_toolchain .env )
170173 env .update (ctx .attr .env )
171174
172- runfiles = ctx .runfiles (transitive_srcs + transitive_data + tools )
175+ runfiles = ctx .runfiles (tools , transitive_files = depset ( transitive = [ transitive_srcs , transitive_data ]) )
173176 runfiles = get_transitive_runfiles (runfiles , ctx .attr .srcs , ctx .attr .deps , ctx .attr .data )
174177
175178 # Propagate executable from source rb_binary() targets.
@@ -188,14 +191,13 @@ def rb_binary_impl(ctx):
188191 return [
189192 DefaultInfo (
190193 executable = script ,
191- files = depset (transitive_srcs + transitive_data + tools ),
192194 runfiles = runfiles ,
193195 ),
194196 RubyFilesInfo (
195197 binary = executable ,
196- transitive_data = depset (transitive_data + tools ),
197- transitive_deps = depset ( transitive_deps ) ,
198- transitive_srcs = depset ( transitive_srcs ) ,
198+ transitive_data = depset (tools , transitive = [ transitive_data ] ),
199+ transitive_deps = transitive_deps ,
200+ transitive_srcs = transitive_srcs ,
199201 bundle_env = bundle_env ,
200202 ),
201203 RunEnvironmentInfo (
0 commit comments