Skip to content

Commit

Permalink
Description redacted.
Browse files Browse the repository at this point in the history
--
MOS_MIGRATED_REVID=89680998
  • Loading branch information
lberki committed Mar 27, 2015
1 parent bd0174f commit 84c94a2
Showing 1 changed file with 21 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
// limitations under the License.
package com.google.devtools.build.lib.analysis.util;

import static com.google.devtools.build.lib.actions.util.ActionsTestUtil.getFirstArtifactEndingWith;

import com.google.common.base.Function;
import com.google.common.base.Preconditions;
import com.google.common.base.Predicate;
Expand Down Expand Up @@ -1386,4 +1388,23 @@ protected Iterable<String> baselineCoverageArtifactBasenames(ConfiguredTarget ta

return basenames.build();
}

/**
* Finds an artifact in the transitive closure of a set of other artifacts by following a path
* based on artifact name suffixes.
*
* <p>This selects the first artifact in the input set that matches the first suffix, then selects
* the first artifact in the inputs of its generating action that matches the second suffix etc.,
* and repeats this until the supplied suffixes run out.
*/
protected Artifact artifactByPath(Iterable<Artifact> artifacts, String... suffixes) {
Artifact artifact = getFirstArtifactEndingWith(artifacts, suffixes[0]);

for (int i = 1; i < suffixes.length; i++) {
artifacts = getGeneratingAction(artifact).getInputs();
artifact = getFirstArtifactEndingWith(artifacts, suffixes[i]);
}

return artifact;
}
}

0 comments on commit 84c94a2

Please sign in to comment.