use of com.google.devtools.build.lib.analysis.ConfiguredTarget in project bazel by bazelbuild.
the class CcCommonTest method testLinkStaticStatically.
@Test
public void testLinkStaticStatically() throws Exception {
ConfiguredTarget statically = scratchConfiguredTarget("statically", "statically", "cc_library(name = 'statically',", " srcs = ['statically.cc'],", " linkstatic=1)");
assertTrue(statically.getProvider(CcExecutionDynamicLibrariesProvider.class).getExecutionDynamicLibraryArtifacts().isEmpty());
Artifact staticallyDotA = getOnlyElement(getFilesToBuild(statically));
assertThat(getGeneratingAction(staticallyDotA)).isInstanceOf(CppLinkAction.class);
PathFragment dotAPath = staticallyDotA.getExecPath();
assertThat(dotAPath.getPathString()).endsWith(STATIC_LIB);
}
use of com.google.devtools.build.lib.analysis.ConfiguredTarget in project bazel by bazelbuild.
the class ConstraintTest method testConstraint.
@Test
public void testConstraint() throws Exception {
scratch.file("constraint/BUILD", "constraint_setting(name = 'basic')", "constraint_value(name = 'foo',", " constraint_setting = ':basic',", " )", "constraint_value(name = 'bar',", " constraint_setting = ':basic',", " )");
ConfiguredTarget setting = getConfiguredTarget("//constraint:basic");
assertThat(setting).isNotNull();
assertThat(setting.getProvider(ConstraintSettingProvider.class)).isNotNull();
assertThat(setting.getProvider(ConstraintSettingProvider.class).constraintSetting()).isEqualTo(Label.parseAbsolute("//constraint:basic"));
ConfiguredTarget fooValue = getConfiguredTarget("//constraint:foo");
assertThat(fooValue).isNotNull();
assertThat(fooValue.getProvider(ConstraintValueProvider.class)).isNotNull();
assertThat(fooValue.getProvider(ConstraintValueProvider.class).constraint().constraintSetting()).isEqualTo(Label.parseAbsolute("//constraint:basic"));
assertThat(fooValue.getProvider(ConstraintValueProvider.class).value()).isEqualTo(Label.parseAbsolute("//constraint:foo"));
ConfiguredTarget barValue = getConfiguredTarget("//constraint:bar");
assertThat(barValue).isNotNull();
assertThat(barValue.getProvider(ConstraintValueProvider.class).constraint().constraintSetting()).isEqualTo(Label.parseAbsolute("//constraint:basic"));
assertThat(barValue.getProvider(ConstraintValueProvider.class).value()).isEqualTo(Label.parseAbsolute("//constraint:bar"));
}
use of com.google.devtools.build.lib.analysis.ConfiguredTarget in project bazel by bazelbuild.
the class BazelProtoLibraryTest method testDescriptorSetOutput_strict_deps_multipleSrcs.
/**
* When building a proto_library with multiple srcs (say foo.proto and bar.proto), we should allow
* foo.proto to import bar.proto without tripping strict-deps checking. This means that
* --direct_dependencies should list the srcs.
*/
@Test
public void testDescriptorSetOutput_strict_deps_multipleSrcs() throws Exception {
useConfiguration("--proto_compiler=//proto:compiler", "--strict_proto_deps=error");
ConfiguredTarget target = scratchConfiguredTarget("x", "foo", "proto_library(name='foo', srcs=['foo.proto', 'bar.proto'])");
Artifact file = getFirstArtifactEndingWith(getFilesToBuild(target), ".proto.bin");
assertThat(file.getRootRelativePathString()).isEqualTo("x/foo-descriptor-set.proto.bin");
assertThat(getGeneratingSpawnAction(file).getRemainingArguments()).contains("--direct_dependencies=x/foo.proto:x/bar.proto");
}
use of com.google.devtools.build.lib.analysis.ConfiguredTarget in project bazel by bazelbuild.
the class CppOutputGroupsTest method testSharedAndDynamicLibraryOutputGroups.
@Test
public void testSharedAndDynamicLibraryOutputGroups() throws Exception {
scratch.file("src.cc");
scratch.file("a/BUILD", "cc_library(name='lib', srcs=['src.cc'], linkstatic=0, alwayslink=1)", "filegroup(name='group_archive', srcs=[':lib'], output_group = 'archive')", "filegroup(name='group_dynamic', srcs=[':lib'], output_group = 'dynamic_library')");
ConfiguredTarget groupArchive = getConfiguredTarget("//a:group_archive");
ConfiguredTarget groupDynamic = getConfiguredTarget("//a:group_dynamic");
assertThat(ActionsTestUtil.prettyArtifactNames(getFilesToBuild(groupArchive))).containsExactly("a/liblib.lo");
assertThat(ActionsTestUtil.prettyArtifactNames(getFilesToBuild(groupDynamic))).containsExactly("a/liblib.so");
}
use of com.google.devtools.build.lib.analysis.ConfiguredTarget in project bazel by bazelbuild.
the class CppOutputGroupsTest method testStaticAndDynamicLibraryOutputGroups.
@Test
public void testStaticAndDynamicLibraryOutputGroups() throws Exception {
scratch.file("src.cc");
scratch.file("a/BUILD", "cc_library(name='lib', srcs=['src.cc'], linkstatic=0, alwayslink=0)", "filegroup(name='group_archive', srcs=[':lib'], output_group = 'archive')", "filegroup(name='group_dynamic', srcs=[':lib'], output_group = 'dynamic_library')");
ConfiguredTarget groupArchive = getConfiguredTarget("//a:group_archive");
ConfiguredTarget groupDynamic = getConfiguredTarget("//a:group_dynamic");
assertThat(ActionsTestUtil.prettyArtifactNames(getFilesToBuild(groupArchive))).containsExactly("a/liblib.a");
assertThat(ActionsTestUtil.prettyArtifactNames(getFilesToBuild(groupDynamic))).containsExactly("a/liblib.so");
}
Aggregations