Skip to content

Commit e8278ed

Browse files
coeuvrecopybara-github
authored andcommitted
Update flag --experimental_remote_download_regex to accept multiple regular expressions.
PiperOrigin-RevId: 470707773 Change-Id: I9cec072e32b641fc4cc068d53d83d95a5fe9c55d
1 parent 6ad7054 commit e8278ed

File tree

2 files changed

+20
-13
lines changed

2 files changed

+20
-13
lines changed

src/main/java/com/google/devtools/build/lib/remote/RemoteExecutionService.java

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,6 @@
144144
import java.util.concurrent.Phaser;
145145
import java.util.concurrent.atomic.AtomicBoolean;
146146
import java.util.function.Predicate;
147-
import java.util.regex.Matcher;
148147
import java.util.regex.Pattern;
149148
import javax.annotation.Nullable;
150149

@@ -217,18 +216,25 @@ public RemoteExecutionService(
217216

218217
this.scheduler = Schedulers.from(executor, /*interruptibleWorker=*/ true);
219218

220-
String regex = remoteOptions.remoteDownloadRegex;
221219
// TODO(bazel-team): Consider adding a warning or more validation if the remoteDownloadRegex is
222-
// used without RemoteOutputsMode.MINIMAL.
223-
this.shouldForceDownloads =
224-
!regex.isEmpty()
225-
&& (remoteOptions.remoteOutputsMode == RemoteOutputsMode.MINIMAL
226-
|| remoteOptions.remoteOutputsMode == RemoteOutputsMode.TOPLEVEL);
227-
Pattern pattern = Pattern.compile(regex);
220+
// used without Build without the Bytes.
221+
ImmutableList.Builder<Pattern> builder = ImmutableList.builder();
222+
if (remoteOptions.remoteOutputsMode == RemoteOutputsMode.MINIMAL
223+
|| remoteOptions.remoteOutputsMode == RemoteOutputsMode.TOPLEVEL) {
224+
for (String regex : remoteOptions.remoteDownloadRegex) {
225+
builder.add(Pattern.compile(regex));
226+
}
227+
}
228+
ImmutableList<Pattern> patterns = builder.build();
229+
this.shouldForceDownloads = !patterns.isEmpty();
228230
this.shouldForceDownloadPredicate =
229231
path -> {
230-
Matcher m = pattern.matcher(path);
231-
return m.matches();
232+
for (Pattern pattern : patterns) {
233+
if (pattern.matcher(path).find()) {
234+
return true;
235+
}
236+
}
237+
return false;
232238
};
233239
}
234240

src/main/java/com/google/devtools/build/lib/remote/options/RemoteOptions.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -589,15 +589,16 @@ public RemoteOutputsStrategyConverter() {
589589

590590
@Option(
591591
name = "experimental_remote_download_regex",
592-
defaultValue = "",
592+
defaultValue = "null",
593+
allowMultiple = true,
593594
documentationCategory = OptionDocumentationCategory.UNDOCUMENTED,
594595
effectTags = {OptionEffectTag.AFFECTS_OUTPUTS},
595596
help =
596597
"Force Bazel to download the artifacts that match the given regexp. To be used in"
597-
+ " conjunction with --remote_download_minimal or --remote_download_toplevel to allow"
598+
+ " conjunction with Build without the Bytes (or the internal equivalent) to allow"
598599
+ " the client to request certain artifacts that might be needed locally (e.g. IDE"
599600
+ " support)")
600-
public String remoteDownloadRegex;
601+
public List<String> remoteDownloadRegex;
601602

602603
// The below options are not configurable by users, only tests.
603604
// This is part of the effort to reduce the overall number of flags.

0 commit comments

Comments
 (0)