aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/main/java/com/google/devtools/build
diff options
context:
space:
mode:
authorGravatar Googler <noreply@google.com>2016-12-07 16:53:32 +0000
committerGravatar Kristina Chodorow <kchodorow@google.com>2016-12-07 22:20:17 +0000
commit2c2d19007818204e552f47ffe8721322a7ff8558 (patch)
treea771fab4309e184b4e55fa3a4ffadb0cdc1201cf /src/main/java/com/google/devtools/build
parentdc388246ff56d4cdd95fbeebba7f78ff3097e0c4 (diff)
Pass isExternal field to blaze ide info proto
Roll forward after fixing tests. Changes from rolled-back CL: Native aspect now determines 'isExternal' identically to skylark aspect. RepositoryName.isMain was unreliable (at least in testing environment), because unknown repos (occurring due to some race condition) are flagged as being in the 'default' repo, distinct from the 'main' repo. We now bypass RepositoryName entirely, and use the same label string heuristic as used in the Skylark aspect. -- PiperOrigin-RevId: 141314075 MOS_MIGRATED_REVID=141314075
Diffstat (limited to 'src/main/java/com/google/devtools/build')
-rw-r--r--src/main/java/com/google/devtools/build/lib/ideinfo/AndroidStudioInfoAspect.java21
1 files changed, 16 insertions, 5 deletions
diff --git a/src/main/java/com/google/devtools/build/lib/ideinfo/AndroidStudioInfoAspect.java b/src/main/java/com/google/devtools/build/lib/ideinfo/AndroidStudioInfoAspect.java
index ea7ae872b0..4c2dc81ef2 100644
--- a/src/main/java/com/google/devtools/build/lib/ideinfo/AndroidStudioInfoAspect.java
+++ b/src/main/java/com/google/devtools/build/lib/ideinfo/AndroidStudioInfoAspect.java
@@ -19,6 +19,7 @@ import static com.google.devtools.build.lib.packages.Attribute.ConfigurationTran
import static com.google.devtools.build.lib.packages.Attribute.attr;
import static com.google.devtools.build.lib.packages.BuildType.LABEL;
+import com.google.common.annotations.VisibleForTesting;
import com.google.common.base.Function;
import com.google.common.base.Joiner;
import com.google.common.collect.ImmutableList;
@@ -328,7 +329,7 @@ public class AndroidStudioInfoAspect extends NativeAspectClass implements Config
outputBuilder.setLabel(base.getLabel().toString());
outputBuilder.setBuildFileArtifactLocation(
- makeArtifactLocation(ruleContext.getRule().getPackage()));
+ makeArtifactLocation(ruleContext.getRule().getPackage(), ruleContext.getLabel()));
outputBuilder.setKindString(ruleContext.getRule().getRuleClass());
@@ -620,21 +621,25 @@ public class AndroidStudioInfoAspect extends NativeAspectClass implements Config
}
public static ArtifactLocation makeArtifactLocation(Artifact artifact) {
- return makeArtifactLocation(artifact.getRoot(), artifact.getRootRelativePath());
+ return makeArtifactLocation(
+ artifact.getRoot(), artifact.getRootRelativePath(), isExternal(artifact.getOwner()));
}
- private static ArtifactLocation makeArtifactLocation(Package pkg) {
+ private static ArtifactLocation makeArtifactLocation(Package pkg, Label label) {
Root root =
Root.asSourceRoot(pkg.getSourceRoot(), pkg.getPackageIdentifier().getRepository().isMain());
PathFragment relativePath = pkg.getBuildFile().getPath().relativeTo(root.getPath());
- return makeArtifactLocation(root, relativePath);
+ return makeArtifactLocation(root, relativePath, isExternal(label));
}
- private static ArtifactLocation makeArtifactLocation(Root root, PathFragment relativePath) {
+ @VisibleForTesting
+ static ArtifactLocation makeArtifactLocation(
+ Root root, PathFragment relativePath, boolean isExternal) {
return ArtifactLocation.newBuilder()
.setRootExecutionPathFragment(root.getExecPath().toString())
.setRelativePath(relativePath.toString())
.setIsSource(root.isSourceRoot())
+ .setIsExternal(isExternal)
.build();
}
@@ -643,9 +648,15 @@ public class AndroidStudioInfoAspect extends NativeAspectClass implements Config
.setRootExecutionPathFragment(resourceDir.getRootExecutionPathFragment().toString())
.setRelativePath(resourceDir.getRelativePath().toString())
.setIsSource(resourceDir.isSource())
+ .setIsExternal(false)
.build();
}
+ /** Returns whether this {@link Label} refers to an external repository. */
+ private static boolean isExternal(Label label) {
+ return label.getWorkspaceRoot().startsWith("external");
+ }
+
private JavaIdeInfo makeJavaIdeInfo(
ConfiguredTarget base,
RuleContext ruleContext,