Search in sources :

Example 1 with ProtocolStringList

use of com.google.protobuf.ProtocolStringList in project bazel by bazelbuild.

the class AndroidStudioInfoAspectTest method testSimpleCCLibraryWithIncludes.

@Test
public void testSimpleCCLibraryWithIncludes() throws Exception {
    scratch.file("com/google/example/BUILD", "cc_library(", "    name = 'simple',", "    srcs = ['simple/simple.cc'],", "    hdrs = ['simple/simple.h'],", "    includes = ['foo/bar'],", ")");
    Map<String, TargetIdeInfo> targetIdeInfos = buildIdeInfo("//com/google/example:simple");
    assertThat(targetIdeInfos).hasSize(2);
    TargetIdeInfo targetIdeInfo = getTargetIdeInfoAndVerifyLabel("//com/google/example:simple", targetIdeInfos);
    assertThat(targetIdeInfo.hasCIdeInfo()).isTrue();
    CIdeInfo cTargetIdeInfo = targetIdeInfo.getCIdeInfo();
    assertThat(cTargetIdeInfo.getTargetIncludeList()).containsExactly("foo/bar");
    // 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 builtInIncludeDirectoryList = cToolchainIdeInfo.getBuiltInIncludeDirectoryList();
    assertThat(builtInIncludeDirectoryList).doesNotContain("foo/bar");
    assertThat(builtInIncludeDirectoryList).doesNotContain("com/google/example/foo/bar");
    ProtocolStringList transIncludeDirList = cTargetIdeInfo.getTransitiveIncludeDirectoryList();
    assertThat(transIncludeDirList).doesNotContain("foo/bar");
    assertThat(transIncludeDirList).doesNotContain("com/google/example/foo/bar");
    ProtocolStringList transQuoteIncludeDirList = cTargetIdeInfo.getTransitiveQuoteIncludeDirectoryList();
    assertThat(transQuoteIncludeDirList).doesNotContain("foo/bar");
    assertThat(transQuoteIncludeDirList).doesNotContain("com/google/example/foo/bar");
    ProtocolStringList transSysIncludeDirList = cTargetIdeInfo.getTransitiveSystemIncludeDirectoryList();
    assertThat(transSysIncludeDirList).doesNotContain("foo/bar");
    assertThat(transSysIncludeDirList).contains("com/google/example/foo/bar");
}
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 2 with ProtocolStringList

use of com.google.protobuf.ProtocolStringList in project bazel by bazelbuild.

the class AndroidStudioInfoAspectTest method testSimpleCCLibraryWithCompilerFlags.

@Test
public void testSimpleCCLibraryWithCompilerFlags() throws Exception {
    scratch.file("com/google/example/BUILD", "cc_library(", "    name = 'simple',", "    srcs = ['simple/simple.cc'],", "    hdrs = ['simple/simple.h'],", "    copts = ['-DGOPT', '-Ifoo/baz/'],", ")");
    Map<String, TargetIdeInfo> targetIdeInfos = buildIdeInfo("//com/google/example:simple");
    assertThat(targetIdeInfos).hasSize(2);
    TargetIdeInfo targetIdeInfo = getTargetIdeInfoAndVerifyLabel("//com/google/example:simple", targetIdeInfos);
    assertThat(targetIdeInfo.hasCIdeInfo()).isTrue();
    CIdeInfo cTargetIdeInfo = targetIdeInfo.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/");
    ProtocolStringList cOptionList = cToolchainIdeInfo.getCOptionList();
    assertThat(cOptionList).doesNotContain("-DGOPT");
    assertThat(cOptionList).doesNotContain("-Ifoo/baz/");
    ProtocolStringList cppOptionList = cToolchainIdeInfo.getCppOptionList();
    assertThat(cppOptionList).doesNotContain("-DGOPT");
    assertThat(cppOptionList).doesNotContain("-Ifoo/baz/");
}
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 3 with ProtocolStringList

use of com.google.protobuf.ProtocolStringList in project bazel by bazelbuild.

the class AndroidStudioInfoAspectTest method testSimpleCCLibraryWithDefines.

@Test
public void testSimpleCCLibraryWithDefines() throws Exception {
    scratch.file("com/google/example/BUILD", "cc_library(", "    name = 'simple',", "    srcs = ['simple/simple.cc'],", "    hdrs = ['simple/simple.h'],", "    defines = ['VERSION2'],", ")");
    Map<String, TargetIdeInfo> targetIdeInfos = buildIdeInfo("//com/google/example:simple");
    assertThat(targetIdeInfos).hasSize(2);
    TargetIdeInfo targetIdeInfo = getTargetIdeInfoAndVerifyLabel("//com/google/example:simple", targetIdeInfos);
    assertThat(targetIdeInfo.hasCIdeInfo()).isTrue();
    CIdeInfo cTargetIdeInfo = targetIdeInfo.getCIdeInfo();
    assertThat(cTargetIdeInfo.getTargetDefineList()).containsExactly("VERSION2");
    // Make sure our understanding of where this attributes show up in other providers is correct.
    ProtocolStringList transDefineList = cTargetIdeInfo.getTransitiveDefineList();
    assertThat(transDefineList).contains("VERSION2");
}
Also used : TargetIdeInfo(com.google.devtools.intellij.ideinfo.IntellijIdeInfo.TargetIdeInfo) CIdeInfo(com.google.devtools.intellij.ideinfo.IntellijIdeInfo.CIdeInfo) ByteString(com.google.protobuf.ByteString) ProtocolStringList(com.google.protobuf.ProtocolStringList) Test(org.junit.Test)

Example 4 with ProtocolStringList

use of com.google.protobuf.ProtocolStringList 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 5 with ProtocolStringList

use of com.google.protobuf.ProtocolStringList 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)

Aggregations

ProtocolStringList (com.google.protobuf.ProtocolStringList)12 CIdeInfo (com.google.devtools.intellij.ideinfo.IntellijIdeInfo.CIdeInfo)7 TargetIdeInfo (com.google.devtools.intellij.ideinfo.IntellijIdeInfo.TargetIdeInfo)7 ByteString (com.google.protobuf.ByteString)7 Test (org.junit.Test)7 CToolchainIdeInfo (com.google.devtools.intellij.ideinfo.IntellijIdeInfo.CToolchainIdeInfo)4 InvocationTargetException (java.lang.reflect.InvocationTargetException)2 ArtifactLocation (com.google.devtools.intellij.ideinfo.IntellijIdeInfo.ArtifactLocation)1 FieldMask (com.google.protobuf.FieldMask)1 Message (com.google.protobuf.Message)1 Impression (com.xrtb.pojo.Impression)1 FieldPath (io.spine.base.FieldPath)1 LinkedList (java.util.LinkedList)1 Nonnull (javax.annotation.Nonnull)1