Skip to content

Commit

Permalink
Allow toggling setting rule inputs/outputs in query --output=proto
Browse files Browse the repository at this point in the history
If users don't need them they can save a significant amount of query
output/storage space by omitting them.

RELNOTES: None
PiperOrigin-RevId: 259848294
  • Loading branch information
michajlo authored and copybara-github committed Jul 25, 2019
1 parent 3da1568 commit ae14ea1
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,14 @@ public Set<Setting> toSettings() {
)
public List<String> protoOutputRuleAttributes = ImmutableList.of("all");

@Option(
name = "proto:rule_inputs_and_outputs",
defaultValue = "true",
documentationCategory = OptionDocumentationCategory.QUERY,
effectTags = {OptionEffectTag.TERMINAL_OUTPUT},
help = "Whether or not to populate the rule_input and rule_output fields.")
public boolean protoIncludeRuleInputsAndOutputs;

/** An enum converter for {@code AspectResolver.Mode} . Should be used internally only. */
public static class AspectResolutionModeConverter extends EnumConverter<Mode> {
public AspectResolutionModeConverter() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ public class ProtoOutputFormatter extends AbstractUnorderedFormatter {
private Predicate<String> ruleAttributePredicate = Predicates.alwaysTrue();
private boolean flattenSelects = true;
private boolean includeLocations = true;
private boolean includeRuleInputsAndOutputs = true;

protected void setDependencyFilter(QueryOptions options) {
this.dependencyFilter = OutputFormatter.getDependencyFilter(options);
Expand All @@ -111,6 +112,7 @@ public void setOptions(CommonQueryOptions options, AspectResolver aspectResolver
this.ruleAttributePredicate = newAttributePredicate(options.protoOutputRuleAttributes);
this.flattenSelects = options.protoFlattenSelects;
this.includeLocations = options.protoIncludeLocations;
this.includeRuleInputsAndOutputs = options.protoIncludeRuleInputsAndOutputs;
}

private static Predicate<String> newAttributePredicate(List<String> outputAttributes) {
Expand Down Expand Up @@ -402,7 +404,7 @@ protected boolean includeRuleDefinitionEnvironment() {
}

protected boolean includeRuleInputsAndOutputs() {
return true;
return includeRuleInputsAndOutputs;
}

protected boolean includeLocation() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ public final void setUpCqueryOptions() {
this.options = new CqueryOptions();
options.aspectDeps = Mode.OFF;
options.protoIncludeConfigurations = true;
options.protoIncludeRuleInputsAndOutputs = true;

this.reporter = new Reporter(new EventBus(), events::add);
}
Expand Down

0 comments on commit ae14ea1

Please sign in to comment.