// Copyright 2017 The Bazel Authors. All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. package com.google.devtools.build.lib.skyframe; import static com.google.common.collect.ImmutableList.toImmutableList; import static java.util.stream.Collectors.joining; import com.google.auto.value.AutoValue; import com.google.common.base.Joiner; import com.google.common.base.Optional; import com.google.common.collect.HashBasedTable; import com.google.common.collect.ImmutableBiMap; import com.google.common.collect.ImmutableList; import com.google.common.collect.Table; import com.google.devtools.build.lib.analysis.PlatformConfiguration; import com.google.devtools.build.lib.analysis.PlatformOptions; import com.google.devtools.build.lib.analysis.ToolchainContext; import com.google.devtools.build.lib.analysis.config.BuildConfiguration; import com.google.devtools.build.lib.analysis.platform.ConstraintValueInfo; import com.google.devtools.build.lib.analysis.platform.PlatformInfo; import com.google.devtools.build.lib.cmdline.Label; import com.google.devtools.build.lib.events.Event; import com.google.devtools.build.lib.skyframe.ConstraintValueLookupUtil.InvalidConstraintValueException; import com.google.devtools.build.lib.skyframe.PlatformLookupUtil.InvalidPlatformException; import com.google.devtools.build.lib.skyframe.RegisteredToolchainsFunction.InvalidToolchainLabelException; import com.google.devtools.build.lib.skyframe.ToolchainResolutionFunction.NoToolchainFoundException; import com.google.devtools.build.skyframe.SkyFunction.Environment; import com.google.devtools.build.skyframe.SkyKey; import com.google.devtools.build.skyframe.ValueOrException2; import java.util.ArrayList; import java.util.List; import java.util.Map; import java.util.Set; import java.util.stream.Collectors; import javax.annotation.Nullable; /** * Common code to create a {@link ToolchainContext} given a set of required toolchain type labels. */ // TODO(katre): Refactor this and ToolchainContext into something nicer to work with and with // fewer static methods everywhere. public class ToolchainUtil { /** * Returns a new {@link ToolchainContext}, containing: * * * * @param env the Skyframe environment to use to acquire dependencies * @param targetDescription a description of the target use, for error and debug message context * @param requiredToolchains the required toolchain types that must be resolved * @param execConstraintLabels extra constraints on the execution platform to select * @param configurationKey the build configuration to use for resolving other targets */ @Nullable static ToolchainContext createToolchainContext( Environment env, String targetDescription, Set