Skip to content

Commit

Permalink
Remove deprecated kind in IDE aspect.
Browse files Browse the repository at this point in the history
--
MOS_MIGRATED_REVID=137178015
  • Loading branch information
Googler authored and katre committed Oct 25, 2016
1 parent 6da46f0 commit 03d6302
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 131 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -55,19 +55,16 @@
import com.google.devtools.build.lib.ideinfo.androidstudio.AndroidStudioIdeInfo.JavaToolchainIdeInfo;
import com.google.devtools.build.lib.ideinfo.androidstudio.AndroidStudioIdeInfo.LibraryArtifact;
import com.google.devtools.build.lib.ideinfo.androidstudio.AndroidStudioIdeInfo.RuleIdeInfo;
import com.google.devtools.build.lib.ideinfo.androidstudio.AndroidStudioIdeInfo.RuleIdeInfo.Kind;
import com.google.devtools.build.lib.ideinfo.androidstudio.AndroidStudioIdeInfo.TestInfo;
import com.google.devtools.build.lib.packages.AspectDefinition;
import com.google.devtools.build.lib.packages.AspectParameters;
import com.google.devtools.build.lib.packages.BuildType;
import com.google.devtools.build.lib.packages.NativeAspectClass;
import com.google.devtools.build.lib.packages.NonconfigurableAttributeMapper;
import com.google.devtools.build.lib.packages.Package;
import com.google.devtools.build.lib.packages.Rule;
import com.google.devtools.build.lib.packages.TargetUtils;
import com.google.devtools.build.lib.rules.android.AndroidIdeInfoProvider;
import com.google.devtools.build.lib.rules.android.AndroidIdeInfoProvider.SourceDirectory;
import com.google.devtools.build.lib.rules.android.AndroidSdkProvider;
import com.google.devtools.build.lib.rules.cpp.CcToolchainProvider;
import com.google.devtools.build.lib.rules.cpp.CppCompilationContext;
import com.google.devtools.build.lib.rules.cpp.CppConfiguration;
Expand Down Expand Up @@ -190,17 +187,10 @@ public ConfiguredAspect create(
AndroidStudioInfoFilesProvider.Builder providerBuilder =
new AndroidStudioInfoFilesProvider.Builder();

RuleIdeInfo.Kind ruleKind = getRuleKind(ruleContext.getRule(), base);
DependenciesResult dependenciesResult = processDependencies(base, ruleContext, providerBuilder);

DependenciesResult dependenciesResult = processDependencies(
base, ruleContext, providerBuilder);

AndroidStudioInfoFilesProvider provider = createIdeBuildArtifact(
base,
ruleContext,
ruleKind,
dependenciesResult,
providerBuilder);
AndroidStudioInfoFilesProvider provider =
createIdeBuildArtifact(base, ruleContext, dependenciesResult, providerBuilder);

NestedSetBuilder<Artifact> ideCompileArtifacts = NestedSetBuilder.stableOrder();
// Add artifacts required for compilation
Expand Down Expand Up @@ -316,15 +306,12 @@ private DependenciesResult processDependencies(
}

return new DependenciesResult(
dependencies,
runtimeDepsBuilder.build(),
resources != null ? resources.getLabel() : null);
dependencies, runtimeDepsBuilder.build(), resources != null ? resources.getLabel() : null);
}

private AndroidStudioInfoFilesProvider createIdeBuildArtifact(
ConfiguredTarget base,
RuleContext ruleContext,
Kind ruleKind,
DependenciesResult dependenciesResult,
AndroidStudioInfoFilesProvider.Builder providerBuilder) {

Expand All @@ -341,9 +328,6 @@ private AndroidStudioInfoFilesProvider createIdeBuildArtifact(
outputBuilder.setBuildFileArtifactLocation(
makeArtifactLocation(ruleContext.getRule().getPackage()));

if (ruleKind != Kind.UNRECOGNIZED) {
outputBuilder.setKind(ruleKind);
}
outputBuilder.setKindString(ruleContext.getRule().getRuleClass());

// Java rules
Expand All @@ -359,8 +343,8 @@ private AndroidStudioInfoFilesProvider createIdeBuildArtifact(
if (isCppRule(base)) {
CppCompilationContext cppCompilationContext = base.getProvider(CppCompilationContext.class);
if (cppCompilationContext != null) {
CRuleIdeInfo cRuleIdeInfo = makeCRuleIdeInfo(base, ruleContext, cppCompilationContext,
ideResolveArtifacts);
CRuleIdeInfo cRuleIdeInfo =
makeCRuleIdeInfo(base, ruleContext, cppCompilationContext, ideResolveArtifacts);
outputBuilder.setCRuleIdeInfo(cRuleIdeInfo);
}
}
Expand Down Expand Up @@ -925,52 +909,4 @@ private static void addResolveArtifact(
ideResolveArtifacts.add(artifact);
}
}

@Deprecated
private RuleIdeInfo.Kind getRuleKind(Rule rule, ConfiguredTarget base) {
switch (rule.getRuleClassObject().getName()) {
case "java_library":
return Kind.JAVA_LIBRARY;
case "java_import":
return Kind.JAVA_IMPORT;
case "java_test":
return Kind.JAVA_TEST;
case "java_binary":
return Kind.JAVA_BINARY;
case "android_library":
return Kind.ANDROID_LIBRARY;
case "android_binary":
return Kind.ANDROID_BINARY;
case "android_test":
return Kind.ANDROID_TEST;
case "android_robolectric_test":
return Kind.ANDROID_ROBOELECTRIC_TEST;
case "proto_library":
return Kind.PROTO_LIBRARY;
case "java_plugin":
return Kind.JAVA_PLUGIN;
case "android_resources":
return Kind.ANDROID_RESOURCES;
case "cc_library":
return Kind.CC_LIBRARY;
case "cc_binary":
return Kind.CC_BINARY;
case "cc_test":
return Kind.CC_TEST;
case "cc_inc_library":
return Kind.CC_INC_LIBRARY;
case "cc_toolchain":
return Kind.CC_TOOLCHAIN;
case "java_wrap_cc":
return Kind.JAVA_WRAP_CC;
default:
{
if (base.getProvider(AndroidSdkProvider.class) != null) {
return RuleIdeInfo.Kind.ANDROID_SDK;
} else {
return RuleIdeInfo.Kind.UNRECOGNIZED;
}
}
}
}
}
22 changes: 0 additions & 22 deletions src/main/protobuf/android_studio_ide_info.proto
Original file line number Diff line number Diff line change
Expand Up @@ -107,29 +107,7 @@ message JavaToolchainIdeInfo {
}

message RuleIdeInfo {
enum Kind {
ANDROID_BINARY = 0;
ANDROID_LIBRARY = 1;
ANDROID_TEST = 2;
ANDROID_ROBOELECTRIC_TEST = 3;
JAVA_LIBRARY = 4;
JAVA_TEST = 5;
JAVA_IMPORT = 6;
JAVA_BINARY = 7;
PROTO_LIBRARY = 8;
ANDROID_SDK = 9;
JAVA_PLUGIN = 10;
ANDROID_RESOURCES = 11;
CC_LIBRARY = 12;
CC_BINARY = 13;
CC_TEST = 14;
CC_INC_LIBRARY = 15;
CC_TOOLCHAIN = 16;
JAVA_WRAP_CC = 17;
}

string label = 1;
Kind kind = 2 [deprecated=true];
repeated string dependencies = 4;

// kind is one of {JAVA,ANDROID}_{LIBRARY,BINARY,TEST} and JAVA_IMPORT
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
import com.google.devtools.build.lib.ideinfo.androidstudio.AndroidStudioIdeInfo.CToolchainIdeInfo;
import com.google.devtools.build.lib.ideinfo.androidstudio.AndroidStudioIdeInfo.JavaRuleIdeInfo;
import com.google.devtools.build.lib.ideinfo.androidstudio.AndroidStudioIdeInfo.RuleIdeInfo;
import com.google.devtools.build.lib.ideinfo.androidstudio.AndroidStudioIdeInfo.RuleIdeInfo.Kind;
import com.google.protobuf.ByteString;
import com.google.protobuf.ProtocolStringList;
import java.nio.file.Paths;
Expand Down Expand Up @@ -388,9 +387,6 @@ public void testJavaImport() throws Exception {
final RuleIdeInfo libInfo = getRuleInfoAndVerifyLabel("//com/google/example:lib", ruleIdeInfos);
RuleIdeInfo impInfo = getRuleInfoAndVerifyLabel("//com/google/example:imp", ruleIdeInfos);

if (testLegacyAswbPluginVersionCompatibility()) {
assertThat(impInfo.getKind()).isEqualTo(Kind.JAVA_IMPORT);
}
assertThat(impInfo.getKindString()).isEqualTo("java_import");
assertThat(libInfo.getDependenciesList()).contains("//com/google/example:imp");

Expand Down Expand Up @@ -443,9 +439,6 @@ public void testJavaImportWithExports() throws Exception {
RuleIdeInfo libInfo = getRuleInfoAndVerifyLabel("//com/google/example:lib", ruleIdeInfos);
RuleIdeInfo impInfo = getRuleInfoAndVerifyLabel("//com/google/example:imp", ruleIdeInfos);

if (testLegacyAswbPluginVersionCompatibility()) {
assertThat(impInfo.getKind()).isEqualTo(Kind.JAVA_IMPORT);
}
assertThat(impInfo.getKindString()).isEqualTo("java_import");
assertThat(impInfo.getDependenciesList()).contains("//com/google/example:foobar");
assertThat(libInfo.getDependenciesList())
Expand Down Expand Up @@ -543,9 +536,6 @@ public void testJavaTest() throws Exception {
buildRuleIdeInfo("//java/com/google/example:FooBarTest");
RuleIdeInfo testInfo =
getRuleInfoAndVerifyLabel("//java/com/google/example:FooBarTest", ruleIdeInfos);
if (testLegacyAswbPluginVersionCompatibility()) {
assertThat(testInfo.getKind()).isEqualTo(Kind.JAVA_TEST);
}
assertThat(testInfo.getKindString()).isEqualTo("java_test");
assertThat(relativePathsForJavaSourcesOf(testInfo))
.containsExactly("java/com/google/example/FooBarTest.java");
Expand Down Expand Up @@ -585,9 +575,6 @@ public void testJavaBinary() throws Exception {
RuleIdeInfo binaryInfo =
getRuleInfoAndVerifyLabel("//com/google/example:foobar-exe", ruleIdeInfos);

if (testLegacyAswbPluginVersionCompatibility()) {
assertThat(binaryInfo.getKind()).isEqualTo(Kind.JAVA_BINARY);
}
assertThat(binaryInfo.getKindString()).isEqualTo("java_binary");
assertThat(relativePathsForJavaSourcesOf(binaryInfo))
.containsExactly("com/google/example/FooBarMain.java");
Expand Down Expand Up @@ -671,9 +658,6 @@ public void testAndroidLibrary() throws Exception {
")");
Map<String, RuleIdeInfo> ruleIdeInfos = buildRuleIdeInfo("//com/google/example:l");
RuleIdeInfo ruleInfo = getRuleInfoAndVerifyLabel("//com/google/example:l", ruleIdeInfos);
if (testLegacyAswbPluginVersionCompatibility()) {
assertThat(ruleInfo.getKind()).isEqualTo(Kind.ANDROID_LIBRARY);
}
assertThat(ruleInfo.getKindString()).isEqualTo("android_library");
assertThat(relativePathsForJavaSourcesOf(ruleInfo))
.containsExactly("com/google/example/Main.java");
Expand Down Expand Up @@ -728,9 +712,6 @@ public void testAndroidBinary() throws Exception {
Map<String, RuleIdeInfo> ruleIdeInfos = buildRuleIdeInfo("//com/google/example:b");
RuleIdeInfo ruleInfo = getRuleInfoAndVerifyLabel("//com/google/example:b", ruleIdeInfos);

if (testLegacyAswbPluginVersionCompatibility()) {
assertThat(ruleInfo.getKind()).isEqualTo(Kind.ANDROID_BINARY);
}
assertThat(ruleInfo.getKindString()).isEqualTo("android_binary");
assertThat(relativePathsForJavaSourcesOf(ruleInfo))
.containsExactly("com/google/example/Main.java");
Expand Down Expand Up @@ -1126,10 +1107,6 @@ public void testJavaPlugin() throws Exception {
RuleIdeInfo plugin =
getRuleInfoAndVerifyLabel("//java/com/google/example:plugin", ruleIdeInfos);

if (testLegacyAswbPluginVersionCompatibility()) {
assertThat(plugin.getKind()).isEqualTo(Kind.JAVA_PLUGIN);
}

assertThat(plugin.getKindString()).isEqualTo("java_plugin");
assertThat(transform(plugin.getJavaRuleIdeInfo().getJarsList(), LIBRARY_ARTIFACT_TO_STRING))
.containsExactly(
Expand Down Expand Up @@ -1597,24 +1574,15 @@ public void testMacroDoesntAffectRuleClass() throws Exception {
Map<String, RuleIdeInfo> ruleIdeInfos = buildRuleIdeInfo("//java/com/google/example:simple");
RuleIdeInfo ruleIdeInfo =
getRuleInfoAndVerifyLabel("//java/com/google/example:simple", ruleIdeInfos);
if (testLegacyAswbPluginVersionCompatibility()) {
assertThat(ruleIdeInfo.getKind()).isEqualTo(Kind.ANDROID_BINARY);
}
assertThat(ruleIdeInfo.getKindString()).isEqualTo("android_binary");
}

@Test
public void testAndroidBinaryIsSerialized() throws Exception {
RuleIdeInfo.Builder builder = RuleIdeInfo.newBuilder();
if (testLegacyAswbPluginVersionCompatibility()) {
builder.setKind(Kind.ANDROID_BINARY);
}
builder.setKindString("android_binary");
ByteString byteString = builder.build().toByteString();
RuleIdeInfo result = RuleIdeInfo.parseFrom(byteString);
if (testLegacyAswbPluginVersionCompatibility()) {
assertThat(result.getKind()).isEqualTo(Kind.ANDROID_BINARY);
}
assertThat(result.getKindString()).isEqualTo("android_binary");
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -286,11 +286,4 @@ protected static List<RuleIdeInfo> findJavaToolchain(Map<String, RuleIdeInfo> ru
}

protected abstract boolean isNativeTest();

// We only need to test legacy functionality for the native aspect.
// To make it easier to tally missing skylark aspect functionality,
// we give this switch a different name.
protected boolean testLegacyAswbPluginVersionCompatibility() {
return isNativeTest();
}
}

0 comments on commit 03d6302

Please sign in to comment.