Skip to content

Commit d29034e

Browse files
Update flag --experimental_remote_download_regex to accept multiple regular expressions. (bazelbuild#16478)
PiperOrigin-RevId: 470707773 Change-Id: I9cec072e32b641fc4cc068d53d83d95a5fe9c55d (cherry picked from commit e8278ed) Also includes the change in bazelbuild#16476. Co-authored-by: Googler <[email protected]>
1 parent 4657931 commit d29034e

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

+16-10
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,6 @@
142142
import java.util.concurrent.Phaser;
143143
import java.util.concurrent.atomic.AtomicBoolean;
144144
import java.util.function.Predicate;
145-
import java.util.regex.Matcher;
146145
import java.util.regex.Pattern;
147146
import javax.annotation.Nullable;
148147

@@ -215,18 +214,25 @@ public RemoteExecutionService(
215214

216215
this.scheduler = Schedulers.from(executor, /*interruptibleWorker=*/ true);
217216

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

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

+4-3
Original file line numberDiff line numberDiff line change
@@ -581,15 +581,16 @@ public RemoteOutputsStrategyConverter() {
581581

582582
@Option(
583583
name = "experimental_remote_download_regex",
584-
defaultValue = "",
584+
defaultValue = "null",
585+
allowMultiple = true,
585586
documentationCategory = OptionDocumentationCategory.UNDOCUMENTED,
586587
effectTags = {OptionEffectTag.AFFECTS_OUTPUTS},
587588
help =
588589
"Force Bazel to download the artifacts that match the given regexp. To be used in"
589-
+ " conjunction with --remote_download_minimal or --remote_download_toplevel to allow"
590+
+ " conjunction with Build without the Bytes (or the internal equivalent) to allow"
590591
+ " the client to request certain artifacts that might be needed locally (e.g. IDE"
591592
+ " support)")
592-
public String remoteDownloadRegex;
593+
public List<String> remoteDownloadRegex;
593594

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

0 commit comments

Comments
 (0)