From c0e5bc50f946c6b127485aeee133c149283ae352 Mon Sep 17 00:00:00 2001 From: Lukacs Berki Date: Wed, 6 Apr 2016 12:31:07 +0000 Subject: Move FDO support to the analysis phase by wrapping FdoSupport in its own SkyFunction. This removes one of the two reasons for the existence of BuildConfiguration#prepareToBuild() which makes implementing dynamic configurations impossible and also makes FDO support halfway sane; now FDO is exactly as ugly as remote repositories, that is to say, reasonably okay. Ideally, we'd implement the zip extraction as an Action and make it a TreeArtifact, but support for TreeArtifacts is not mature yet enough, so it's not possible at the moment. -- MOS_MIGRATED_REVID=119150223 --- .../com/google/devtools/build/lib/rules/cpp/CppHelper.java | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'src/main/java/com/google/devtools/build/lib/rules/cpp/CppHelper.java') diff --git a/src/main/java/com/google/devtools/build/lib/rules/cpp/CppHelper.java b/src/main/java/com/google/devtools/build/lib/rules/cpp/CppHelper.java index 97db3a514f..300c87e122 100644 --- a/src/main/java/com/google/devtools/build/lib/rules/cpp/CppHelper.java +++ b/src/main/java/com/google/devtools/build/lib/rules/cpp/CppHelper.java @@ -214,6 +214,13 @@ public class CppHelper { return false; } + @Nullable public static FdoSupport getFdoSupport(RuleContext ruleContext) { + return ruleContext + .getPrerequisite(":cc_toolchain", Mode.TARGET) + .getProvider(FdoSupportProvider.class) + .getFdoSupport(); + } + /** * This almost trivial method looks up the :cc_toolchain attribute on the rule context, makes sure * that it refers to a rule that has a {@link CcToolchainProvider} (gives an error otherwise), and @@ -508,8 +515,9 @@ public class CppHelper { /** * Returns the FDO build subtype. */ - public static String getFdoBuildStamp(CppConfiguration cppConfiguration) { - if (cppConfiguration.getFdoSupport().isAutoFdoEnabled()) { + public static String getFdoBuildStamp(RuleContext ruleContext) { + CppConfiguration cppConfiguration = ruleContext.getFragment(CppConfiguration.class); + if (getFdoSupport(ruleContext).isAutoFdoEnabled()) { return (cppConfiguration.getLipoMode() == LipoMode.BINARY) ? "ALIPO" : "AFDO"; } if (cppConfiguration.isFdo()) { -- cgit v1.2.3