Skip to content

Commit

Permalink
Do not NPE crash when C++ actions are not configured in crosstool
Browse files Browse the repository at this point in the history
Show meaningful message instead.

RELNOTES: None.
PiperOrigin-RevId: 161196096
  • Loading branch information
hlopko authored and katre committed Jul 7, 2017
1 parent 2936047 commit 7d58bdc
Show file tree
Hide file tree
Showing 14 changed files with 410 additions and 198 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,15 @@
* </ol>
*/
public interface ActionTemplate<T extends Action> extends ActionAnalysisMetadata {

/** An exception signalling that the template expansion failed during execution phase */
class ActionTemplateExpansionException extends Exception {

public ActionTemplateExpansionException(String cause) {
super(cause);
}
}

/**
* Given a list of input TreeFileArtifacts resolved at execution time, returns a list of expanded
* SpawnActions to be executed.
Expand All @@ -65,7 +74,8 @@ public interface ActionTemplate<T extends Action> extends ActionAnalysisMetadata
* {@link TreeFileArtifact}
*/
Iterable<T> generateActionForInputArtifacts(
Iterable<TreeFileArtifact> inputTreeFileArtifacts, ArtifactOwner artifactOwner);
Iterable<TreeFileArtifact> inputTreeFileArtifacts, ArtifactOwner artifactOwner)
throws ActionTemplateExpansionException;

/** Returns the input TreeArtifact. */
Artifact getInputTreeArtifact();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
import com.google.devtools.build.lib.packages.TargetUtils;
import com.google.devtools.build.lib.rules.RuleConfiguredTargetFactory;
import com.google.devtools.build.lib.rules.apple.Platform;
import com.google.devtools.build.lib.rules.cpp.CcLibraryHelper.Info;
import com.google.devtools.build.lib.rules.cpp.CcToolchainFeatures.FeatureConfiguration;
import com.google.devtools.build.lib.rules.cpp.CppConfiguration.DynamicMode;
import com.google.devtools.build.lib.rules.cpp.Link.LinkStaticness;
Expand Down Expand Up @@ -236,6 +237,7 @@ public static ConfiguredTarget init(CppSemantics semantics, RuleContext ruleCont
determineLinkerArguments(
ruleContext,
ccToolchain,
featureConfiguration,
fdoSupport,
common,
precompiledFiles,
Expand Down Expand Up @@ -268,7 +270,6 @@ public static ConfiguredTarget init(CppSemantics semantics, RuleContext ruleCont
linkActionBuilder.setLinkType(linkType);
linkActionBuilder.setLinkStaticness(linkStaticness);
linkActionBuilder.setFake(fake);
linkActionBuilder.setFeatureConfiguration(featureConfiguration);

if (CppLinkAction.enableSymbolsCounts(cppConfiguration, fake, linkType)) {
linkActionBuilder.setSymbolCountsOutput(ruleContext.getBinArtifact(
Expand Down Expand Up @@ -450,10 +451,11 @@ public static ConfiguredTarget init(CppSemantics semantics, RuleContext ruleCont
private static CppLinkActionBuilder determineLinkerArguments(
RuleContext context,
CcToolchainProvider toolchain,
FeatureConfiguration featureConfiguration,
FdoSupportProvider fdoSupport,
CcCommon common,
PrecompiledFiles precompiledFiles,
CcLibraryHelper.Info info,
Info info,
ImmutableSet<Artifact> compilationPrerequisites,
boolean fake,
Artifact binary,
Expand All @@ -462,7 +464,7 @@ private static CppLinkActionBuilder determineLinkerArguments(
boolean linkCompileOutputSeparately)
throws InterruptedException {
CppLinkActionBuilder builder =
new CppLinkActionBuilder(context, binary, toolchain, fdoSupport)
new CppLinkActionBuilder(context, binary, toolchain, fdoSupport, featureConfiguration)
.setCrosstoolInputs(toolchain.getLink())
.addNonCodeInputs(compilationPrerequisites);

Expand Down
Loading

0 comments on commit 7d58bdc

Please sign in to comment.