use of com.google.devtools.build.lib.analysis.ConfiguredTarget in project bazel by bazelbuild.
the class CcLibraryConfiguredTargetTest method dontAddStaticLibraryToStaticSharedLinkParamsWhenWrappingSameLibraryIdentifier.
@Test
public void dontAddStaticLibraryToStaticSharedLinkParamsWhenWrappingSameLibraryIdentifier() throws Exception {
ConfiguredTarget target = scratchConfiguredTarget("a", "foo", "cc_library(name = 'foo', srcs = ['libfoo.so'])");
Iterable<Artifact> libraries = LinkerInputs.toNonSolibArtifacts(target.getProvider(CcLinkParamsProvider.class).getCcLinkParams(true, true).getLibraries());
assertThat(artifactsToStrings(libraries)).doesNotContain("bin a/libfoo.a");
assertThat(artifactsToStrings(libraries)).contains("src a/libfoo.so");
}
use of com.google.devtools.build.lib.analysis.ConfiguredTarget in project bazel by bazelbuild.
the class CcLibraryConfiguredTargetTest method testFilesToBuildWithoutDSO.
@Test
public void testFilesToBuildWithoutDSO() throws Exception {
CrosstoolConfig.CrosstoolRelease.Builder release = CrosstoolConfig.CrosstoolRelease.newBuilder().mergeFrom(CrosstoolConfigurationHelper.simpleCompleteToolchainProto());
release.getToolchainBuilder(0).setTargetCpu("k8").setCompiler("compiler").clearLinkingModeFlags();
scratch.file("crosstool/BUILD", "cc_toolchain_suite(", " name = 'crosstool',", " toolchains = {'k8|compiler': ':cc-compiler-k8'})", "filegroup(name = 'empty')", "cc_toolchain(", " name = 'cc-compiler-k8',", " output_licenses = ['unencumbered'],", " cpu = 'k8',", " compiler_files = ':empty',", " dwp_files = ':empty',", " linker_files = ':empty',", " strip_files = ':empty',", " objcopy_files = ':empty',", " static_runtime_libs = [':empty'],", " dynamic_runtime_libs = [':empty'],", " all_files = ':empty',", " licenses = ['unencumbered'])");
scratch.file("crosstool/CROSSTOOL", TextFormat.printToString(release));
// This is like the preceding test, but with a toolchain that can't build '.so' files
useConfiguration("--crosstool_top=//crosstool:crosstool", "--compiler=compiler", "--cpu=k8", "--host_cpu=k8");
ConfiguredTarget hello = getConfiguredTarget("//hello:hello");
Artifact archive = getBinArtifact("libhello.a", hello);
assertThat(getFilesToBuild(hello)).containsExactly(archive);
}
use of com.google.devtools.build.lib.analysis.ConfiguredTarget in project bazel by bazelbuild.
the class CcLibraryConfiguredTargetTest method testProcessHeadersInDependencies.
@Test
public void testProcessHeadersInDependencies() throws Exception {
AnalysisMock.get().ccSupport().setupCrosstool(mockToolsConfig, MockCcSupport.HEADER_PROCESSING_FEATURE_CONFIGURATION);
useConfiguration("--features=parse_headers", "--process_headers_in_dependencies");
ConfiguredTarget x = scratchConfiguredTarget("foo", "x", "cc_library(name = 'x', deps = [':y'])", "cc_library(name = 'y', hdrs = ['y.h'])");
assertThat(ActionsTestUtil.baseNamesOf(getOutputGroup(x, OutputGroupProvider.HIDDEN_TOP_LEVEL))).isEqualTo("y.h.processed");
}
use of com.google.devtools.build.lib.analysis.ConfiguredTarget in project bazel by bazelbuild.
the class CcLibraryConfiguredTargetTest method testTransitiveArtifactsToAlwaysBuildStatic.
@Test
public void testTransitiveArtifactsToAlwaysBuildStatic() throws Exception {
useConfiguration("--cpu=k8");
ConfiguredTarget x = scratchConfiguredTarget("foo", "x", "cc_library(name = 'x', srcs = ['x.cc'], deps = [':y'], linkstatic = 1)", "cc_library(name = 'y', srcs = ['y.cc'], deps = [':z'])", "cc_library(name = 'z', srcs = ['z.cc'])");
assertEquals(ImmutableSet.of("bin foo/_objs/x/foo/x.pic.o", "bin foo/_objs/y/foo/y.pic.o", "bin foo/_objs/z/foo/z.pic.o"), artifactsToStrings(getOutputGroup(x, OutputGroupProvider.HIDDEN_TOP_LEVEL)));
}
use of com.google.devtools.build.lib.analysis.ConfiguredTarget in project bazel by bazelbuild.
the class CcLibraryConfiguredTargetTest method testFilesToBuildWithPrecompiledStaticLibrary.
/**
* Historically, blaze hasn't added the pre-compiled libraries from srcs to the files to build.
* This test ensures that we do not accidentally break that - we may do so intentionally.
*/
@Test
public void testFilesToBuildWithPrecompiledStaticLibrary() throws Exception {
ConfiguredTarget hello = scratchConfiguredTarget("precompiled", "library", "cc_library(name = 'library', ", " srcs = ['missing.a'])");
assertThat(artifactsToStrings(getFilesToBuild(hello))).doesNotContain("src precompiled/missing.a");
}
Aggregations