diff options
author | Lukacs Berki <lberki@google.com> | 2016-04-06 12:31:07 +0000 |
---|---|---|
committer | Lukacs Berki <lberki@google.com> | 2016-04-07 11:45:11 +0000 |
commit | c0e5bc50f946c6b127485aeee133c149283ae352 (patch) | |
tree | cd382125be5cc2a5132646312c164f2c95be90c1 /src/main/java/com/google/devtools/build/lib/rules/cpp/CppHelper.java | |
parent | c23ba45553699b5d8b8ac1520adb307fd7e4e7ee (diff) |
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
Diffstat (limited to 'src/main/java/com/google/devtools/build/lib/rules/cpp/CppHelper.java')
-rw-r--r-- | src/main/java/com/google/devtools/build/lib/rules/cpp/CppHelper.java | 12 |
1 files changed, 10 insertions, 2 deletions
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()) { |