use of com.google.devtools.build.lib.analysis.ConfiguredTarget in project bazel by bazelbuild.
the class LinkBuildVariablesTest method testInterfaceLibraryBuildingVariablesWhenGenerationNotAllowed.
@Test
public void testInterfaceLibraryBuildingVariablesWhenGenerationNotAllowed() throws Exception {
// Make sure the interface shared object generation is enabled in the configuration
// (which it is not by default for some windows toolchains)
AnalysisMock.get().ccSupport().setupCrosstool(mockToolsConfig, "supports_interface_shared_objects: true");
useConfiguration();
scratch.file("x/BUILD", "cc_library(name = 'foo', srcs = ['a.cc'])");
scratch.file("x/a.cc");
ConfiguredTarget target = getConfiguredTarget("//x:foo");
Variables variables = getLinkBuildVariables(target, LinkTargetType.STATIC_LIBRARY);
String interfaceLibraryBuilder = Iterables.getOnlyElement(getVariableValue(variables, CppLinkActionBuilder.INTERFACE_LIBRARY_BUILDER_VARIABLE));
String interfaceLibraryInput = Iterables.getOnlyElement(getVariableValue(variables, CppLinkActionBuilder.INTERFACE_LIBRARY_INPUT_VARIABLE));
String interfaceLibraryOutput = Iterables.getOnlyElement(getVariableValue(variables, CppLinkActionBuilder.INTERFACE_LIBRARY_OUTPUT_VARIABLE));
String generateInterfaceLibrary = Iterables.getOnlyElement(getVariableValue(variables, CppLinkActionBuilder.GENERATE_INTERFACE_LIBRARY_VARIABLE));
assertThat(generateInterfaceLibrary).isEqualTo("no");
assertThat(interfaceLibraryInput).endsWith("ignored");
assertThat(interfaceLibraryOutput).endsWith("ignored");
assertThat(interfaceLibraryBuilder).endsWith("ignored");
}
use of com.google.devtools.build.lib.analysis.ConfiguredTarget in project bazel by bazelbuild.
the class LinkBuildVariablesTest method testIsCcTestLinkActionBuildVariable.
@Test
public void testIsCcTestLinkActionBuildVariable() throws Exception {
scratch.file("x/BUILD", "cc_test(name = 'foo_test', srcs = ['a.cc'])", "cc_binary(name = 'foo', srcs = ['a.cc'])");
scratch.file("x/a.cc");
ConfiguredTarget testTarget = getConfiguredTarget("//x:foo_test");
Variables testVariables = getLinkBuildVariables(testTarget, LinkTargetType.EXECUTABLE);
assertThat(testVariables.isAvailable(CppLinkActionBuilder.IS_CC_TEST_LINK_ACTION_VARIABLE)).isTrue();
ConfiguredTarget binaryTarget = getConfiguredTarget("//x:foo");
Variables binaryVariables = getLinkBuildVariables(binaryTarget, LinkTargetType.EXECUTABLE);
assertThat(binaryVariables.isAvailable(CppLinkActionBuilder.IS_CC_TEST_LINK_ACTION_VARIABLE)).isFalse();
}
use of com.google.devtools.build.lib.analysis.ConfiguredTarget in project bazel by bazelbuild.
the class LinkBuildVariablesTest method assertStripBinaryVariableIsPresent.
private void assertStripBinaryVariableIsPresent(String stripMode, String compilationMode, boolean isEnabled) throws Exception {
useConfiguration("--strip=" + stripMode, "--compilation_mode=" + compilationMode);
ConfiguredTarget target = getConfiguredTarget("//x:foo");
Variables variables = getLinkBuildVariables(target, LinkTargetType.EXECUTABLE);
assertThat(variables.isAvailable(CppLinkActionBuilder.STRIP_DEBUG_SYMBOLS_VARIABLE)).isEqualTo(isEnabled);
}
use of com.google.devtools.build.lib.analysis.ConfiguredTarget in project bazel by bazelbuild.
the class LinkBuildVariablesTest method testLinkerParamFileIsExported.
@Test
public void testLinkerParamFileIsExported() throws Exception {
AnalysisMock.get().ccSupport().setupCrosstool(mockToolsConfig);
useConfiguration();
scratch.file("x/BUILD", "cc_binary(name = 'bin', srcs = ['some-dir/bar.so'])");
scratch.file("x/some-dir/bar.so");
ConfiguredTarget target = getConfiguredTarget("//x:bin");
Variables variables = getLinkBuildVariables(target, Link.LinkTargetType.EXECUTABLE);
List<String> variableValue = getVariableValue(variables, CppLinkActionBuilder.LINKER_PARAM_FILE_VARIABLE);
assertThat(Iterables.getOnlyElement(variableValue)).matches(".*bin/x/bin" + OsUtils.executableExtension() + "-2.params$");
}
use of com.google.devtools.build.lib.analysis.ConfiguredTarget in project bazel by bazelbuild.
the class CppLinkActionTest method testExposesRuntimeLibrarySearchDirectoriesVariable.
@Test
public void testExposesRuntimeLibrarySearchDirectoriesVariable() throws Exception {
scratch.file("x/BUILD", "cc_binary(", " name = 'foo',", " srcs = ['some-dir/bar.so', 'some-other-dir/qux.so'],", ")");
scratch.file("x/some-dir/bar.so");
scratch.file("x/some-other-dir/qux.so");
ConfiguredTarget configuredTarget = getConfiguredTarget("//x:foo");
CppLinkAction linkAction = (CppLinkAction) getGeneratingAction(configuredTarget, "x/foo" + OsUtils.executableExtension());
Iterable<? extends VariableValue> runtimeLibrarySearchDirectories = linkAction.getLinkCommandLine().getBuildVariables().getSequenceVariable(CppLinkActionBuilder.RUNTIME_LIBRARY_SEARCH_DIRECTORIES_VARIABLE);
List<String> directories = new ArrayList<>();
for (VariableValue value : runtimeLibrarySearchDirectories) {
directories.add(value.getStringValue("runtime_library_search_directory"));
}
assertThat(Joiner.on(" ").join(directories)).matches(".*some-dir .*some-other-dir");
}
Aggregations