Search in sources :

Example 6 with CrosstoolRelease

use of com.google.devtools.build.lib.view.config.crosstool.CrosstoolConfig.CrosstoolRelease in project bazel by bazelbuild.

the class AndroidNdkCrosstoolsTest method testCrosstoolTriples.

/**
   * Tests that each (cpu, compiler, glibc) triple in each crosstool is unique in that crosstool.
   */
@Test
public void testCrosstoolTriples() {
    StringBuilder errorBuilder = new StringBuilder();
    for (CrosstoolRelease crosstool : crosstoolReleases) {
        // Create a map of (cpu, compiler, glibc) triples -> toolchain.
        ImmutableMultimap.Builder<String, CToolchain> triples = ImmutableMultimap.builder();
        for (CToolchain toolchain : crosstool.getToolchainList()) {
            String triple = "(" + Joiner.on(", ").join(toolchain.getTargetCpu(), toolchain.getCompiler(), toolchain.getTargetLibc()) + ")";
            triples.put(triple, toolchain);
        }
        // Collect all the duplicate triples.
        for (Entry<String, Collection<CToolchain>> entry : triples.build().asMap().entrySet()) {
            if (entry.getValue().size() > 1) {
                errorBuilder.append(entry.getKey() + ": " + Joiner.on(", ").join(Collections2.transform(entry.getValue(), new Function<CToolchain, String>() {

                    @Override
                    public String apply(CToolchain toolchain) {
                        return toolchain.getToolchainIdentifier();
                    }
                })));
                errorBuilder.append("\n");
            }
        }
        errorBuilder.append("\n");
    }
    // This is a rather awkward condition to test on, but collecting all the duplicates first is
    // the only way to make a useful error message rather than finding the errors one by one.
    String error = errorBuilder.toString().trim();
    if (!error.isEmpty()) {
        fail("Toolchains contain duplicate (cpu, compiler, glibc) triples:\n" + error);
    }
}
Also used : Function(com.google.common.base.Function) CToolchain(com.google.devtools.build.lib.view.config.crosstool.CrosstoolConfig.CToolchain) Collection(java.util.Collection) ImmutableMultimap(com.google.common.collect.ImmutableMultimap) CrosstoolRelease(com.google.devtools.build.lib.view.config.crosstool.CrosstoolConfig.CrosstoolRelease) Test(org.junit.Test)

Aggregations

CrosstoolRelease (com.google.devtools.build.lib.view.config.crosstool.CrosstoolConfig.CrosstoolRelease)6 CToolchain (com.google.devtools.build.lib.view.config.crosstool.CrosstoolConfig.CToolchain)4 Test (org.junit.Test)3 ToolPath (com.google.devtools.build.lib.view.config.crosstool.CrosstoolConfig.ToolPath)2 Function (com.google.common.base.Function)1 ImmutableList (com.google.common.collect.ImmutableList)1 ImmutableMultimap (com.google.common.collect.ImmutableMultimap)1 InvalidConfigurationException (com.google.devtools.build.lib.analysis.config.InvalidConfigurationException)1 NdkCrosstoolsException (com.google.devtools.build.lib.bazel.rules.android.ndkcrosstools.AndroidNdkCrosstools.NdkCrosstoolsException)1 ApiLevel (com.google.devtools.build.lib.bazel.rules.android.ndkcrosstools.ApiLevel)1 NdkMajorRevision (com.google.devtools.build.lib.bazel.rules.android.ndkcrosstools.NdkMajorRevision)1 NdkPaths (com.google.devtools.build.lib.bazel.rules.android.ndkcrosstools.NdkPaths)1 NdkRelease (com.google.devtools.build.lib.bazel.rules.android.ndkcrosstools.NdkRelease)1 StlImpl (com.google.devtools.build.lib.bazel.rules.android.ndkcrosstools.StlImpl)1 WorkspaceAttributeMapper (com.google.devtools.build.lib.rules.repository.WorkspaceAttributeMapper)1 DirectoryListingValue (com.google.devtools.build.lib.skyframe.DirectoryListingValue)1 EvalException (com.google.devtools.build.lib.syntax.EvalException)1 Path (com.google.devtools.build.lib.vfs.Path)1 PathFragment (com.google.devtools.build.lib.vfs.PathFragment)1 RootedPath (com.google.devtools.build.lib.vfs.RootedPath)1