diff options
author | plf <plf@google.com> | 2018-06-29 05:23:01 -0700 |
---|---|---|
committer | Copybara-Service <copybara-piper@google.com> | 2018-06-29 05:24:09 -0700 |
commit | 908682a743d5a1c31b17bc199f9003a6b00114b8 (patch) | |
tree | b087a49fbef321e17b01949742d62cec3c7c44fd | |
parent | 13028b6c906574786cb52e636cfd24e50596c162 (diff) |
C++: Adds ctx to cc_link_params creation.
This is done so that we can check whether the current target can use the C++
Skylark API.
RELNOTES:none
PiperOrigin-RevId: 202632582
3 files changed, 22 insertions, 0 deletions
diff --git a/src/main/java/com/google/devtools/build/lib/rules/cpp/CcCommon.java b/src/main/java/com/google/devtools/build/lib/rules/cpp/CcCommon.java index 856ae0965f..e9266913e6 100644 --- a/src/main/java/com/google/devtools/build/lib/rules/cpp/CcCommon.java +++ b/src/main/java/com/google/devtools/build/lib/rules/cpp/CcCommon.java @@ -208,6 +208,13 @@ public final class CcCommon { throws EvalException { RuleContext context = skylarkRuleContext.getRuleContext(); Rule rule = context.getRule(); + if (!context.getFragment(CppConfiguration.class).getEnableCcSkylarkApi()) { + throw new EvalException( + rule.getLocation(), + "Pass --experimental_enable_cc_skylark_api in " + + "order to use the C++ API. Beware that we will be making breaking " + + "changes to this API without prior warning."); + } RuleClass ruleClass = rule.getRuleClassObject(); Label label = ruleClass.getRuleDefinitionEnvironmentLabel(); if (label != null diff --git a/src/main/java/com/google/devtools/build/lib/rules/cpp/CppConfiguration.java b/src/main/java/com/google/devtools/build/lib/rules/cpp/CppConfiguration.java index db39874630..965317c0fe 100644 --- a/src/main/java/com/google/devtools/build/lib/rules/cpp/CppConfiguration.java +++ b/src/main/java/com/google/devtools/build/lib/rules/cpp/CppConfiguration.java @@ -923,6 +923,10 @@ public final class CppConfiguration extends BuildConfiguration.Fragment return cppOptions.expandLinkoptsLabels; } + public boolean getEnableCcSkylarkApi() { + return cppOptions.enableCcSkylarkApi; + } + /** * Returns the path to the GNU binutils 'objcopy' binary to use for this build. (Corresponds to * $(OBJCOPY) in make-dbg.) Relative paths are relative to the execution root. diff --git a/src/main/java/com/google/devtools/build/lib/rules/cpp/CppOptions.java b/src/main/java/com/google/devtools/build/lib/rules/cpp/CppOptions.java index 4c54850f81..c9c05c179c 100644 --- a/src/main/java/com/google/devtools/build/lib/rules/cpp/CppOptions.java +++ b/src/main/java/com/google/devtools/build/lib/rules/cpp/CppOptions.java @@ -789,6 +789,17 @@ public class CppOptions extends FragmentOptions { help = "If true, entries in linkopts that are not preceded by - or $ will be expanded.") public boolean expandLinkoptsLabels; + @Option( + name = "experimental_enable_cc_skylark_api", + defaultValue = "false", + documentationCategory = OptionDocumentationCategory.UNDOCUMENTED, + effectTags = {OptionEffectTag.LOADING_AND_ANALYSIS}, + metadataTags = {OptionMetadataTag.EXPERIMENTAL}, + help = + "If true, the C++ Skylark API can be used. Don't enable this flag yet, we will be making " + + "breaking changes.") + public boolean enableCcSkylarkApi; + @Override public FragmentOptions getHost() { CppOptions host = (CppOptions) getDefault(); |