use of com.google.devtools.build.lib.analysis.ConfiguredTarget in project bazel by bazelbuild.
the class AndroidSkylarkSplitTransitionTest method testAndroidSplitTransitionNoTransition.
@Test
public void testAndroidSplitTransitionNoTransition() throws Exception {
writeAndroidSplitTransitionTestFiles();
useConfiguration("--fat_apk_cpu=", "--android_crosstool_top=", "--cpu=k8");
ConfiguredTarget target = getConfiguredTarget("//test/skylark:test");
@SuppressWarnings("unchecked") Map<Object, List<ConfiguredTarget>> splitDeps = (Map<Object, List<ConfiguredTarget>>) target.get("split_attr_deps");
// Split transition isn't in effect, so the deps are compiled normally (i.e. using --cpu).
assertThat(splitDeps.get(Runtime.NONE)).hasSize(2);
assertThat(splitDeps.get(Runtime.NONE).get(0).getConfiguration().getCpu()).isEqualTo("k8");
assertThat(splitDeps.get(Runtime.NONE).get(1).getConfiguration().getCpu()).isEqualTo("k8");
}
use of com.google.devtools.build.lib.analysis.ConfiguredTarget in project bazel by bazelbuild.
the class AndroidSkylarkSplitTransitionTest method testAndroidSplitTransition.
@Test
public void testAndroidSplitTransition() throws Exception {
writeAndroidSplitTransitionTestFiles();
useConfiguration("--fat_apk_cpu=k8,armeabi-v7a");
ConfiguredTarget target = getConfiguredTarget("//test/skylark:test");
// Check that ctx.split_attr.deps has this structure:
// {
// "k8": [ConfiguredTarget],
// "armeabi-v7a": [ConfiguredTarget],
// }
@SuppressWarnings("unchecked") Map<String, List<ConfiguredTarget>> splitDeps = (Map<String, List<ConfiguredTarget>>) target.get("split_attr_deps");
assertThat(splitDeps).containsKey("k8");
assertThat(splitDeps).containsKey("armeabi-v7a");
assertThat(splitDeps.get("k8")).hasSize(2);
assertThat(splitDeps.get("armeabi-v7a")).hasSize(2);
assertThat(splitDeps.get("k8").get(0).getConfiguration().getCpu()).isEqualTo("k8");
assertThat(splitDeps.get("k8").get(1).getConfiguration().getCpu()).isEqualTo("k8");
assertThat(splitDeps.get("armeabi-v7a").get(0).getConfiguration().getCpu()).isEqualTo("armeabi-v7a");
assertThat(splitDeps.get("armeabi-v7a").get(1).getConfiguration().getCpu()).isEqualTo("armeabi-v7a");
// Check that ctx.split_attr.dep has this structure (that is, that the values are not lists):
// {
// "k8": ConfiguredTarget,
// "armeabi-v7a": ConfiguredTarget,
// }
@SuppressWarnings("unchecked") Map<String, ConfiguredTarget> splitDep = (Map<String, ConfiguredTarget>) target.get("split_attr_dep");
assertThat(splitDep).containsKey("k8");
assertThat(splitDep).containsKey("armeabi-v7a");
assertThat(splitDep.get("k8").getConfiguration().getCpu()).isEqualTo("k8");
assertThat(splitDep.get("armeabi-v7a").getConfiguration().getCpu()).isEqualTo("armeabi-v7a");
// The regular ctx.attr.deps should be a single list with all the branches of the split merged
// together (i.e. for aspects).
@SuppressWarnings("unchecked") List<ConfiguredTarget> attrDeps = (List<ConfiguredTarget>) target.get("attr_deps");
assertThat(attrDeps).hasSize(4);
ListMultimap<String, Object> attrDepsMap = ArrayListMultimap.create();
for (ConfiguredTarget ct : attrDeps) {
attrDepsMap.put(ct.getConfiguration().getCpu(), target);
}
assertThat(attrDepsMap.get("k8")).hasSize(2);
assertThat(attrDepsMap.get("armeabi-v7a")).hasSize(2);
// Check that even though my_rule.dep is defined as a single label, ctx.attr.dep is still a list
// with multiple ConfiguredTarget objects because of the two different CPUs.
@SuppressWarnings("unchecked") List<ConfiguredTarget> attrDep = (List<ConfiguredTarget>) target.get("attr_dep");
assertThat(attrDep).hasSize(2);
ListMultimap<String, Object> attrDepMap = ArrayListMultimap.create();
for (ConfiguredTarget ct : attrDep) {
attrDepMap.put(ct.getConfiguration().getCpu(), target);
}
assertThat(attrDepMap.get("k8")).hasSize(1);
assertThat(attrDepMap.get("armeabi-v7a")).hasSize(1);
// Check that the deps were correctly accessed from within Skylark.
@SuppressWarnings("unchecked") List<ConfiguredTarget> k8Deps = (List<ConfiguredTarget>) target.get("k8_deps");
assertThat(k8Deps).hasSize(2);
assertThat(k8Deps.get(0).getConfiguration().getCpu()).isEqualTo("k8");
assertThat(k8Deps.get(1).getConfiguration().getCpu()).isEqualTo("k8");
}
use of com.google.devtools.build.lib.analysis.ConfiguredTarget in project bazel by bazelbuild.
the class CcCommonTest method testEmptyLibrary.
@Test
public void testEmptyLibrary() throws Exception {
ConfiguredTarget emptylib = getConfiguredTarget("//empty:emptylib");
// because those have a potentially significant run-time startup cost.
if (emptyShouldOutputStaticLibrary()) {
assertEquals("libemptylib.a", baseNamesOf(getFilesToBuild(emptylib)));
} else {
assertThat(getFilesToBuild(emptylib)).isEmpty();
}
assertTrue(emptylib.getProvider(CcExecutionDynamicLibrariesProvider.class).getExecutionDynamicLibraryArtifacts().isEmpty());
}
use of com.google.devtools.build.lib.analysis.ConfiguredTarget in project bazel by bazelbuild.
the class CcCommonTest method testCcLibraryThirdPartyIncludesNotWarned.
@Test
public void testCcLibraryThirdPartyIncludesNotWarned() throws Exception {
eventCollector.clear();
ConfiguredTarget target = scratchConfiguredTarget("third_party/pkg", "lib", "licenses(['unencumbered'])", "cc_library(name = 'lib',", " srcs = ['foo.cc'],", " includes = ['./'])");
assertThat(view.hasErrors(target)).isFalse();
assertNoEvents();
}
use of com.google.devtools.build.lib.analysis.ConfiguredTarget in project bazel by bazelbuild.
the class CcCommonTest method testDylibLibrarySuffixIsStripped.
@Test
public void testDylibLibrarySuffixIsStripped() throws Exception {
ConfiguredTarget archiveInSrcsTest = scratchConfiguredTarget("archive_in_src_darwin", "archive_in_srcs", "cc_binary(name = 'archive_in_srcs',", " srcs = ['libarchive.34.dylib'])");
Artifact executable = getExecutable(archiveInSrcsTest);
CppLinkAction linkAction = (CppLinkAction) getGeneratingAction(executable);
assertThat(linkAction.getLinkCommandLine().toString()).contains(" -larchive.34 ");
}
Aggregations