Search in sources :

Example 21 with TargetIdeInfo

use of com.google.devtools.intellij.ideinfo.IntellijIdeInfo.TargetIdeInfo in project bazel by bazelbuild.

the class AndroidStudioInfoAspectTest method testSimpleCCLibrary.

@Test
public void testSimpleCCLibrary() throws Exception {
    scratch.file("com/google/example/BUILD", "cc_library(", "    name = 'simple',", "    srcs = ['simple/simple.cc'],", "    hdrs = ['simple/simple.h'],", ")");
    Map<String, TargetIdeInfo> targetIdeInfos = buildIdeInfo("//com/google/example:simple");
    assertThat(targetIdeInfos).hasSize(2);
    TargetIdeInfo targetIdeInfo = getTargetIdeInfoAndVerifyLabel("//com/google/example:simple", targetIdeInfos);
    ArtifactLocation location = targetIdeInfo.getBuildFileArtifactLocation();
    assertThat(Paths.get(location.getRelativePath()).toString()).isEqualTo(Paths.get("com/google/example/BUILD").toString());
    assertThat(targetIdeInfo.getKindString()).isEqualTo("cc_library");
    assertThat(targetIdeInfo.getDependenciesCount()).isEqualTo(1);
    assertThat(relativePathsForCSourcesOf(targetIdeInfo)).containsExactly("com/google/example/simple/simple.cc");
    assertThat(targetIdeInfo.hasCIdeInfo()).isTrue();
    assertThat(targetIdeInfo.hasJavaIdeInfo()).isFalse();
    assertThat(targetIdeInfo.hasAndroidIdeInfo()).isFalse();
    CIdeInfo cTargetIdeInfo = targetIdeInfo.getCIdeInfo();
    assertThat(cTargetIdeInfo.getTargetCoptList()).isEmpty();
    assertThat(cTargetIdeInfo.getTargetDefineList()).isEmpty();
    assertThat(cTargetIdeInfo.getTargetIncludeList()).isEmpty();
    ProtocolStringList transQuoteIncludeDirList = cTargetIdeInfo.getTransitiveQuoteIncludeDirectoryList();
    assertThat(transQuoteIncludeDirList).contains(".");
    assertThat(targetIdeInfo.getJavaIdeInfo().getJarsList()).isEmpty();
    assertThat(getIdeResolveFiles()).containsExactly("com/google/example/simple/simple.h");
}
Also used : TargetIdeInfo(com.google.devtools.intellij.ideinfo.IntellijIdeInfo.TargetIdeInfo) ArtifactLocation(com.google.devtools.intellij.ideinfo.IntellijIdeInfo.ArtifactLocation) CIdeInfo(com.google.devtools.intellij.ideinfo.IntellijIdeInfo.CIdeInfo) ByteString(com.google.protobuf.ByteString) ProtocolStringList(com.google.protobuf.ProtocolStringList) Test(org.junit.Test)

Example 22 with TargetIdeInfo

use of com.google.devtools.intellij.ideinfo.IntellijIdeInfo.TargetIdeInfo in project bazel by bazelbuild.

the class AndroidStudioInfoAspectTest method testTransitiveCLibraryWithCompilerFlags.

@Test
public void testTransitiveCLibraryWithCompilerFlags() throws Exception {
    scratch.file("com/google/example/BUILD", "cc_library(", "    name = 'lib2',", "    srcs = ['lib2/lib2.cc'],", "    hdrs = ['lib2/lib2.h'],", "    copts = ['-v23', '-DDEV'],", ")", "cc_library(", "    name = 'lib1',", "    srcs = ['lib1/lib1.cc'],", "    hdrs = ['lib1/lib1.h'],", "    copts = ['-DGOPT', '-Ifoo/baz/'],", "    deps = [':lib2'],", ")");
    Map<String, TargetIdeInfo> targetIdeInfos = buildIdeInfo("//com/google/example:lib1");
    assertThat(targetIdeInfos).hasSize(3);
    TargetIdeInfo lib1 = getTargetIdeInfoAndVerifyLabel("//com/google/example:lib1", targetIdeInfos);
    assertThat(lib1.hasCIdeInfo()).isTrue();
    CIdeInfo cTargetIdeInfo = lib1.getCIdeInfo();
    assertThat(cTargetIdeInfo.getTargetCoptList()).containsExactly("-DGOPT", "-Ifoo/baz/");
    // Make sure our understanding of where this attributes show up in other providers is correct.
    Entry<String, TargetIdeInfo> toolchainEntry = getCcToolchainRuleAndVerifyThereIsOnlyOne(targetIdeInfos);
    TargetIdeInfo toolchainInfo = toolchainEntry.getValue();
    assertThat(toolchainInfo.hasCToolchainIdeInfo()).isTrue();
    CToolchainIdeInfo cToolchainIdeInfo = toolchainInfo.getCToolchainIdeInfo();
    ProtocolStringList baseCompilerOptionList = cToolchainIdeInfo.getBaseCompilerOptionList();
    assertThat(baseCompilerOptionList).doesNotContain("-DGOPT");
    assertThat(baseCompilerOptionList).doesNotContain("-Ifoo/baz/");
    assertThat(baseCompilerOptionList).doesNotContain("-v23");
    assertThat(baseCompilerOptionList).doesNotContain("-DDEV");
    ProtocolStringList cOptionList = cToolchainIdeInfo.getCOptionList();
    assertThat(cOptionList).doesNotContain("-DGOPT");
    assertThat(cOptionList).doesNotContain("-Ifoo/baz/");
    assertThat(cOptionList).doesNotContain("-v23");
    assertThat(cOptionList).doesNotContain("-DDEV");
    ProtocolStringList cppOptionList = cToolchainIdeInfo.getCppOptionList();
    assertThat(cppOptionList).doesNotContain("-DGOPT");
    assertThat(cppOptionList).doesNotContain("-Ifoo/baz/");
    assertThat(cppOptionList).doesNotContain("-v23");
    assertThat(cppOptionList).doesNotContain("-DDEV");
}
Also used : TargetIdeInfo(com.google.devtools.intellij.ideinfo.IntellijIdeInfo.TargetIdeInfo) CToolchainIdeInfo(com.google.devtools.intellij.ideinfo.IntellijIdeInfo.CToolchainIdeInfo) CIdeInfo(com.google.devtools.intellij.ideinfo.IntellijIdeInfo.CIdeInfo) ByteString(com.google.protobuf.ByteString) ProtocolStringList(com.google.protobuf.ProtocolStringList) Test(org.junit.Test)

Example 23 with TargetIdeInfo

use of com.google.devtools.intellij.ideinfo.IntellijIdeInfo.TargetIdeInfo in project bazel by bazelbuild.

the class AndroidStudioInfoAspectTest method testSimpleCCLibraryForCCToolchainExistence.

@Test
public void testSimpleCCLibraryForCCToolchainExistence() throws Exception {
    scratch.file("com/google/example/BUILD", "cc_library(", "    name = 'simple',", "    srcs = ['simple/simple.cc'],", "    hdrs = ['simple/simple.h'],", ")");
    Map<String, TargetIdeInfo> targetIdeInfos = buildIdeInfo("//com/google/example:simple");
    assertThat(targetIdeInfos).hasSize(2);
    TargetIdeInfo target = getTargetIdeInfoAndVerifyLabel("//com/google/example:simple", targetIdeInfos);
    Entry<String, TargetIdeInfo> toolchainEntry = getCcToolchainRuleAndVerifyThereIsOnlyOne(targetIdeInfos);
    TargetIdeInfo toolchainInfo = toolchainEntry.getValue();
    ArtifactLocation location = target.getBuildFileArtifactLocation();
    assertThat(Paths.get(location.getRelativePath()).toString()).isEqualTo(Paths.get("com/google/example/BUILD").toString());
    assertThat(target.hasCIdeInfo()).isTrue();
    assertThat(target.getDependenciesList()).hasSize(1);
    assertThat(toolchainInfo.hasCToolchainIdeInfo()).isTrue();
}
Also used : TargetIdeInfo(com.google.devtools.intellij.ideinfo.IntellijIdeInfo.TargetIdeInfo) ArtifactLocation(com.google.devtools.intellij.ideinfo.IntellijIdeInfo.ArtifactLocation) ByteString(com.google.protobuf.ByteString) Test(org.junit.Test)

Example 24 with TargetIdeInfo

use of com.google.devtools.intellij.ideinfo.IntellijIdeInfo.TargetIdeInfo in project bazel by bazelbuild.

the class AndroidStudioInfoAspectTest method testJavaLibraryDoesNotHaveCInfo.

@Test
public void testJavaLibraryDoesNotHaveCInfo() throws Exception {
    scratch.file("com/google/example/BUILD", "java_library(", "    name = 'simple',", "    srcs = ['simple/Simple.java']", ")");
    Map<String, TargetIdeInfo> targetIdeInfos = buildIdeInfo("//com/google/example:simple");
    TargetIdeInfo targetIdeInfo = getTargetIdeInfoAndVerifyLabel("//com/google/example:simple", targetIdeInfos);
    assertThat(targetIdeInfo.hasCIdeInfo()).isFalse();
}
Also used : TargetIdeInfo(com.google.devtools.intellij.ideinfo.IntellijIdeInfo.TargetIdeInfo) ByteString(com.google.protobuf.ByteString) Test(org.junit.Test)

Example 25 with TargetIdeInfo

use of com.google.devtools.intellij.ideinfo.IntellijIdeInfo.TargetIdeInfo in project bazel by bazelbuild.

the class AndroidStudioInfoAspectTest method testAndroidLibraryWithoutAidlHasNoIdlJars.

@Test
public void testAndroidLibraryWithoutAidlHasNoIdlJars() throws Exception {
    scratch.file("java/com/google/example/BUILD", "android_library(", "  name = 'no_idl',", "  srcs = ['Test.java'],", ")");
    String noIdlTarget = "//java/com/google/example:no_idl";
    Map<String, TargetIdeInfo> targetIdeInfos = buildIdeInfo(noIdlTarget);
    TargetIdeInfo noIdlTargetIdeInfo = getTargetIdeInfoAndVerifyLabel(noIdlTarget, targetIdeInfos);
    assertThat(noIdlTargetIdeInfo.getAndroidIdeInfo().getHasIdlSources()).isFalse();
}
Also used : TargetIdeInfo(com.google.devtools.intellij.ideinfo.IntellijIdeInfo.TargetIdeInfo) ByteString(com.google.protobuf.ByteString) Test(org.junit.Test)

Aggregations

TargetIdeInfo (com.google.devtools.intellij.ideinfo.IntellijIdeInfo.TargetIdeInfo)58 ByteString (com.google.protobuf.ByteString)55 Test (org.junit.Test)55 ArtifactLocation (com.google.devtools.intellij.ideinfo.IntellijIdeInfo.ArtifactLocation)12 CIdeInfo (com.google.devtools.intellij.ideinfo.IntellijIdeInfo.CIdeInfo)10 ProtocolStringList (com.google.protobuf.ProtocolStringList)7 CToolchainIdeInfo (com.google.devtools.intellij.ideinfo.IntellijIdeInfo.CToolchainIdeInfo)5 JavaIdeInfo (com.google.devtools.intellij.ideinfo.IntellijIdeInfo.JavaIdeInfo)3 Artifact (com.google.devtools.build.lib.actions.Artifact)2 LibraryArtifact (com.google.devtools.intellij.ideinfo.IntellijIdeInfo.LibraryArtifact)2 Action (com.google.devtools.build.lib.actions.Action)1 BinaryFileWriteAction (com.google.devtools.build.lib.analysis.actions.BinaryFileWriteAction)1 SpawnAction (com.google.devtools.build.lib.analysis.actions.SpawnAction)1 AndroidIdeInfoProvider (com.google.devtools.build.lib.rules.android.AndroidIdeInfoProvider)1 CcToolchainProvider (com.google.devtools.build.lib.rules.cpp.CcToolchainProvider)1 CppCompilationContext (com.google.devtools.build.lib.rules.cpp.CppCompilationContext)1 CppConfiguration (com.google.devtools.build.lib.rules.cpp.CppConfiguration)1 JavaRuleOutputJarsProvider (com.google.devtools.build.lib.rules.java.JavaRuleOutputJarsProvider)1 JavaToolchainProvider (com.google.devtools.build.lib.rules.java.JavaToolchainProvider)1 TestInfo (com.google.devtools.intellij.ideinfo.IntellijIdeInfo.TestInfo)1