@@ -269,6 +269,12 @@ def _run_sphinx(ctx, format, source_path, inputs, output_prefix, use_persistent_
269269 run_args = [] # Copy of the args to forward along to debug runner
270270 args = ctx .actions .args () # Args passed to the action
271271
272+ # An args file is required for persistent workers, but we don't know if
273+ # the action will use worker mode or not (settings we can't see may
274+ # force non-worker mode). For consistency, always use a params file.
275+ args .use_param_file ("@%s" , use_always = True )
276+ args .set_param_file_format ("multiline" )
277+
272278 # NOTE: sphinx_build.py relies on the first two args being the srcdir and
273279 # outputdir, in that order.
274280 args .add (source_path )
@@ -289,7 +295,8 @@ def _run_sphinx(ctx, format, source_path, inputs, output_prefix, use_persistent_
289295
290296 if use_persistent_workers :
291297 # * Normally Sphinx puts doctrees in the output dir. We can't do that
292- # because Bazel will clear the output directory every invocation.
298+ # because Bazel will clear the output directory every invocation. To
299+ # work around that, create it as a sibling directory.
293300 # * Use a non-dot prefixed name so it shows up more visibly.
294301 args .add (paths .join (output_dir .path + "_doctrees" ), format = "--doctree-dir=%s" )
295302
@@ -318,10 +325,11 @@ def _run_sphinx(ctx, format, source_path, inputs, output_prefix, use_persistent_
318325 for tool in ctx .attr .tools :
319326 tools .append (tool [DefaultInfo ].files_to_run )
320327
328+ # NOTE: Command line flags or RBE capabilities may override the execution
329+ # requirements and disable workers. Thus, we can't assume that these
330+ # exec requirements will actually be respected.
321331 execution_requirements = {}
322332 if use_persistent_workers :
323- args .use_param_file ("@%s" , use_always = True )
324- args .set_param_file_format ("multiline" )
325333 execution_requirements ["supports-workers" ] = "1"
326334 execution_requirements ["requires-worker-protocol" ] = "json"
327335
0 commit comments