Skip to content

Commit

Permalink
C++: Adds ctx to cc_link_params creation.
Browse files Browse the repository at this point in the history
This is done so that we can check whether the current target can use the C++
Skylark API.

Rolling forward: BlazeInvocationPolicy is not used in host configuration. We simply ignore host configuration and not give an error when we are building there.

RELNOTES:none
PiperOrigin-RevId: 202652552
  • Loading branch information
oquenchil authored and Copybara-Service committed Jun 29, 2018
1 parent 1458c61 commit c39af25
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,14 @@ public static void checkRuleWhitelisted(SkylarkRuleContext skylarkRuleContext)
throws EvalException {
RuleContext context = skylarkRuleContext.getRuleContext();
Rule rule = context.getRule();
if (!context.getConfiguration().isHostConfiguration()
&& !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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -923,6 +923,10 @@ public boolean getExpandLinkoptsLabels() {
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.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -789,6 +789,17 @@ public Label getFdoPrefetchHintsLabel() {
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();
Expand Down

0 comments on commit c39af25

Please sign in to comment.