@@ -520,7 +520,11 @@ private ActionSpawn(
520
520
parent .getRunfilesSupplier (),
521
521
parent ,
522
522
parent .resourceSetOrBuilder );
523
- this .inputs = getNonFilesetInputs (inputs ).addAll (additionalInputs ).build ();
523
+ NestedSetBuilder <ActionInput > inputsBuilder = NestedSetBuilder .stableOrder ();
524
+ addNonFilesetInputs (inputsBuilder , inputs , filesetMappings );
525
+ inputsBuilder .addAll (additionalInputs );
526
+
527
+ this .inputs = inputsBuilder .build ();
524
528
this .filesetMappings = filesetMappings ;
525
529
this .pathMapper = pathMapper ;
526
530
@@ -535,25 +539,21 @@ private ActionSpawn(
535
539
this .reportOutputs = reportOutputs ;
536
540
}
537
541
538
- /** Returns a {@link NestedSetBuilder} containing only the non-fileset inputs. */
539
- private static NestedSetBuilder <ActionInput > getNonFilesetInputs (NestedSet <Artifact > inputs ) {
540
- NestedSetBuilder <ActionInput > builder = NestedSetBuilder .stableOrder ();
541
- // TODO(tjgq): Investigate whether we can avoid flattening when filesetMappings is empty.
542
- // This requires auditing getSpawnForExtraAction(), which doesn't appear to propagate the
543
- // filesetMappings from the shadowed action.
544
- boolean hasFilesets = false ;
542
+ private static void addNonFilesetInputs (
543
+ NestedSetBuilder <ActionInput > builder ,
544
+ NestedSet <Artifact > inputs ,
545
+ Map <Artifact , ImmutableList <FilesetOutputSymlink >> filesetMappings ) {
546
+ if (filesetMappings .isEmpty ()) {
547
+ // Keep the original nested set intact. This aids callers that exploit the nested set
548
+ // structure to perform optimizations (see SpawnInputExpander#walkInputs and its callers).
549
+ builder .addTransitive (inputs );
550
+ return ;
551
+ }
545
552
for (Artifact input : inputs .toList ()) {
546
553
if (!input .isFileset ()) {
547
554
builder .add (input );
548
- } else {
549
- hasFilesets = true ;
550
555
}
551
556
}
552
- // If possible, keep the original nested set. This aids callers that exploit the nested set
553
- // structure to perform optimizations (see SpawnInputExpander#walkInputs and its callers).
554
- return hasFilesets
555
- ? builder
556
- : NestedSetBuilder .<ActionInput >stableOrder ().addTransitive (inputs );
557
557
}
558
558
559
559
@ Override
0 commit comments