Skip to content

Commit

Permalink
Tiny optimization when handling errors (#7243)
Browse files Browse the repository at this point in the history
Do not parse build output twice.

Bug: n/a
Test: n/a
Change-Id: I1a002a69cd6e3f2fbbbe445c7e1d4833449c2b9f

AOSP: a63da90df16ee9a14c116045b95dcb60c0992b27

Co-authored-by: Googler <[email protected]>
  • Loading branch information
LeFrosch and Googler authored Jan 22, 2025
1 parent 8a893a6 commit 79a0262
Showing 1 changed file with 17 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -48,35 +48,31 @@ public AndroidDeployInfo readDeployInfoProtoForTarget(
Label target, BuildResultHelper buildResultHelper, Predicate<String> pathFilter)
throws GetDeployInfoException {
ImmutableList<OutputArtifact> outputArtifacts;
ParsedBepOutput bepOutput;
try {
outputArtifacts =
buildResultHelper.getBuildOutput(Optional.empty(), Interners.STRING).getDirectArtifactsForTarget(target, pathFilter).asList();
bepOutput = buildResultHelper.getBuildOutput(Optional.empty(), Interners.STRING);
outputArtifacts = bepOutput.getDirectArtifactsForTarget(target, pathFilter).asList();
} catch (GetArtifactsException e) {
throw new GetDeployInfoException(e.getMessage());
}

if (outputArtifacts.isEmpty()) {
Logger log = Logger.getInstance(BlazeApkDeployInfoProtoHelper.class.getName());
try {
ParsedBepOutput bepOutput = buildResultHelper.getBuildOutput(Optional.empty(), Interners.STRING);
log.warn("Local execroot: " + bepOutput.getLocalExecRoot());
log.warn("All output artifacts:");
for (OutputArtifact outputArtifact : bepOutput.getAllOutputArtifacts(path -> true)) {
log.warn(outputArtifact.getBazelOutRelativePath() + " -> " + outputArtifact.getBazelOutRelativePath());
}
log.warn("All local artifacts for " + target + ":");
List<OutputArtifact> allBuildArtifacts =
buildResultHelper.getBuildOutput(Optional.empty(), Interners.STRING).getDirectArtifactsForTarget(target, path1 -> true).asList();
List<File> allLocalFiles = LocalFileArtifact.getLocalFiles(allBuildArtifacts);
for (File file : allLocalFiles) {
String path = file.getPath();
log.warn(path);
if (pathFilter.test(path)) {
log.warn("Note: " + path + " passes pathFilter but was not recognized!");
}
log.warn("Local execroot: " + bepOutput.getLocalExecRoot());
log.warn("All output artifacts:");
for (OutputArtifact outputArtifact : bepOutput.getAllOutputArtifacts(path -> true)) {
log.warn(outputArtifact.getBazelOutRelativePath() + " -> " + outputArtifact.getBazelOutRelativePath());
}
log.warn("All local artifacts for " + target + ":");
List<OutputArtifact> allBuildArtifacts =
bepOutput.getDirectArtifactsForTarget(target, path1 -> true).asList();
List<File> allLocalFiles = LocalFileArtifact.getLocalFiles(allBuildArtifacts);
for (File file : allLocalFiles) {
String path = file.getPath();
log.warn(path);
if (pathFilter.test(path)) {
log.warn("Note: " + path + " passes pathFilter but was not recognized!");
}
} catch (GetArtifactsException e) {
log.warn("Error occured when gathering logs:", e);
}
throw new GetDeployInfoException(
"No deploy info proto artifact found. Was android_deploy_info in the output groups?");
Expand Down

0 comments on commit 79a0262

Please sign in to comment.