aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/main/java/com/google/devtools
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/com/google/devtools')
-rw-r--r--src/main/java/com/google/devtools/build/lib/analysis/featurecontrol/BUILD1
-rw-r--r--src/main/java/com/google/devtools/build/lib/analysis/featurecontrol/FeaturePolicyOptions.java4
-rw-r--r--src/main/java/com/google/devtools/build/lib/remote/RemoteOptions.java12
-rw-r--r--src/main/java/com/google/devtools/common/options/IsolatedOptionsData.java32
-rw-r--r--src/main/java/com/google/devtools/common/options/Option.java11
5 files changed, 54 insertions, 6 deletions
diff --git a/src/main/java/com/google/devtools/build/lib/analysis/featurecontrol/BUILD b/src/main/java/com/google/devtools/build/lib/analysis/featurecontrol/BUILD
index a20987fbe4..eaf4ed6d5e 100644
--- a/src/main/java/com/google/devtools/build/lib/analysis/featurecontrol/BUILD
+++ b/src/main/java/com/google/devtools/build/lib/analysis/featurecontrol/BUILD
@@ -19,6 +19,7 @@ java_library(
"//src/main/java/com/google/devtools/build/lib:util",
"//src/main/java/com/google/devtools/build/lib/cmdline",
"//src/main/java/com/google/devtools/common/options",
+ "//src/main/protobuf:option_filters_java_proto",
"//third_party:auto_value",
"//third_party:guava",
"//third_party:jsr305",
diff --git a/src/main/java/com/google/devtools/build/lib/analysis/featurecontrol/FeaturePolicyOptions.java b/src/main/java/com/google/devtools/build/lib/analysis/featurecontrol/FeaturePolicyOptions.java
index 2b43fc2e06..4bfbacbed4 100644
--- a/src/main/java/com/google/devtools/build/lib/analysis/featurecontrol/FeaturePolicyOptions.java
+++ b/src/main/java/com/google/devtools/build/lib/analysis/featurecontrol/FeaturePolicyOptions.java
@@ -17,7 +17,9 @@ package com.google.devtools.build.lib.analysis.featurecontrol;
import com.google.common.collect.ImmutableList;
import com.google.devtools.build.lib.analysis.config.FragmentOptions;
import com.google.devtools.common.options.Option;
+import com.google.devtools.common.options.OptionDocumentationCategory;
import com.google.devtools.common.options.OptionsParser.OptionUsageRestrictions;
+import com.google.devtools.common.options.proto.OptionFilters.OptionEffectTag;
import java.util.List;
/** The options fragment which defines {@link FeaturePolicyConfiguration}. */
@@ -34,6 +36,8 @@ public final class FeaturePolicyOptions extends FragmentOptions {
+ "features, but each feature must be specified only once.",
valueHelp = "a feature=label pair",
optionUsageRestrictions = OptionUsageRestrictions.UNDOCUMENTED,
+ documentationCategory = OptionDocumentationCategory.UNCATEGORIZED,
+ effectTags = {OptionEffectTag.UNKNOWN},
converter = PolicyEntryConverter.class,
defaultValue = "n/a (default ignored for allowMultiple)",
allowMultiple = true
diff --git a/src/main/java/com/google/devtools/build/lib/remote/RemoteOptions.java b/src/main/java/com/google/devtools/build/lib/remote/RemoteOptions.java
index d472adae09..203128dab1 100644
--- a/src/main/java/com/google/devtools/build/lib/remote/RemoteOptions.java
+++ b/src/main/java/com/google/devtools/build/lib/remote/RemoteOptions.java
@@ -159,6 +159,8 @@ public final class RemoteOptions extends OptionsBase {
name = "experimental_remote_retry",
defaultValue = "true",
category = "remote",
+ documentationCategory = OptionDocumentationCategory.UNCATEGORIZED,
+ effectTags = {OptionEffectTag.UNKNOWN},
help = "Whether to retry transient remote execution/cache errors."
)
public boolean experimentalRemoteRetry;
@@ -167,6 +169,8 @@ public final class RemoteOptions extends OptionsBase {
name = "experimental_remote_retry_start_delay_millis",
defaultValue = "100",
category = "remote",
+ documentationCategory = OptionDocumentationCategory.UNCATEGORIZED,
+ effectTags = {OptionEffectTag.UNKNOWN},
help = "The initial delay before retrying a transient error."
)
public long experimentalRemoteRetryStartDelayMillis;
@@ -175,6 +179,8 @@ public final class RemoteOptions extends OptionsBase {
name = "experimental_remote_retry_max_delay_millis",
defaultValue = "5000",
category = "remote",
+ documentationCategory = OptionDocumentationCategory.UNCATEGORIZED,
+ effectTags = {OptionEffectTag.UNKNOWN},
help = "The maximum delay before retrying a transient error."
)
public long experimentalRemoteRetryMaxDelayMillis;
@@ -183,6 +189,8 @@ public final class RemoteOptions extends OptionsBase {
name = "experimental_remote_retry_max_attempts",
defaultValue = "5",
category = "remote",
+ documentationCategory = OptionDocumentationCategory.UNCATEGORIZED,
+ effectTags = {OptionEffectTag.UNKNOWN},
help = "The maximum number of attempts to retry a transient error."
)
public int experimentalRemoteRetryMaxAttempts;
@@ -191,6 +199,8 @@ public final class RemoteOptions extends OptionsBase {
name = "experimental_remote_retry_multiplier",
defaultValue = "2",
category = "remote",
+ documentationCategory = OptionDocumentationCategory.UNCATEGORIZED,
+ effectTags = {OptionEffectTag.UNKNOWN},
help = "The multiplier by which to increase the retry delay on transient errors."
)
public double experimentalRemoteRetryMultiplier;
@@ -199,6 +209,8 @@ public final class RemoteOptions extends OptionsBase {
name = "experimental_remote_retry_jitter",
defaultValue = "0.1",
category = "remote",
+ documentationCategory = OptionDocumentationCategory.UNCATEGORIZED,
+ effectTags = {OptionEffectTag.UNKNOWN},
help = "The random factor to apply to retry delays on transient errors."
)
public double experimentalRemoteRetryJitter;
diff --git a/src/main/java/com/google/devtools/common/options/IsolatedOptionsData.java b/src/main/java/com/google/devtools/common/options/IsolatedOptionsData.java
index 2d3b4ceed9..6f682ea5ae 100644
--- a/src/main/java/com/google/devtools/common/options/IsolatedOptionsData.java
+++ b/src/main/java/com/google/devtools/common/options/IsolatedOptionsData.java
@@ -18,6 +18,7 @@ import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.Ordering;
import com.google.devtools.common.options.OptionsParser.ConstructionException;
+import com.google.devtools.common.options.proto.OptionFilters.OptionEffectTag;
import java.lang.reflect.Constructor;
import java.lang.reflect.Field;
import java.lang.reflect.Method;
@@ -360,6 +361,35 @@ public class IsolatedOptionsData extends OpaqueOptionsData {
booleanAliasMap.put("no" + optionName, optionName);
}
+ private static void checkEffectTagRationality(String optionName, OptionEffectTag[] effectTags) {
+ // Check that there is at least one OptionEffectTag listed.
+ if (effectTags.length < 1) {
+ throw new ConstructionException(
+ "Option "
+ + optionName
+ + " does not list at least one OptionEffectTag. If the option has no effect, "
+ + "please add NO_OP, otherwise, add a tag representing its effect.");
+ } else if (effectTags.length > 1) {
+ // If there are more than 1 tag, make sure that NO_OP and UNKNOWN is not one of them.
+ // These don't make sense if other effects are listed.
+ ImmutableList<OptionEffectTag> tags = ImmutableList.copyOf(effectTags);
+ if (tags.contains(OptionEffectTag.UNKNOWN)) {
+ throw new ConstructionException(
+ "Option "
+ + optionName
+ + " includes UNKNOWN with other, known, effects. Please remove UNKNOWN from "
+ + "the list.");
+ }
+ if (tags.contains(OptionEffectTag.NO_OP)) {
+ throw new ConstructionException(
+ "Option "
+ + optionName
+ + " includes NO_OP with other effects. This doesn't make much sense. Please "
+ + "remove NO_OP or the actual effects from the list, whichever is correct.");
+ }
+ }
+ }
+
/**
* Constructs an {@link IsolatedOptionsData} object for a parser that knows about the given
* {@link OptionsBase} classes. No inter-option analysis is done. Performs basic sanity checking
@@ -407,6 +437,8 @@ public class IsolatedOptionsData extends OpaqueOptionsData {
+ annotation.category() + "\" in option \"" + optionName + "\" is disallowed.");
}
+ checkEffectTagRationality(optionName, annotation.effectTags());
+
Type fieldType = getFieldSingularType(field, annotation);
// For simple, static expansions, don't accept non-Void types.
if (annotation.expansion().length != 0 && !isVoidField(field)) {
diff --git a/src/main/java/com/google/devtools/common/options/Option.java b/src/main/java/com/google/devtools/common/options/Option.java
index 7489bd668d..e6c9207d98 100644
--- a/src/main/java/com/google/devtools/common/options/Option.java
+++ b/src/main/java/com/google/devtools/common/options/Option.java
@@ -92,24 +92,23 @@ public @interface Option {
*
* <p>For undocumented flags that aren't listed anywhere, this is currently a no-op. Feel free to
* set the value that it would have if it were documented, which might be helpful if a flag is
- * part of an experimental feature that might become documented in the future, or just leave it
- * unset as the default.
+ * part of an experimental feature that might become documented in the future, or just leave it as
+ * OptionDocumentationCategory.UNCATEGORIZED.
*
* <p>For hidden or internal options, use the category field only if it is helpful for yourself or
* other Bazel developers.
*/
- OptionDocumentationCategory documentationCategory() default
- OptionDocumentationCategory.UNCATEGORIZED;
+ OptionDocumentationCategory documentationCategory();
/**
* Tag about the intent or effect of this option. Unless this option is a no-op (and the reason
* for this should be documented) all options should have some effect, so this needs to have at
* least one value.
*
- * <p>No option should list NO_OP_OR_UNKNOWN with other effects listed, but all other combinations
+ * <p>No option should list NO_OP or UNKNOWN with other effects listed, but all other combinations
* are allowed.
*/
- OptionEffectTag[] effectTags() default {OptionEffectTag.UNKNOWN};
+ OptionEffectTag[] effectTags();
/**
* Tag about the state of this option, such as if it gates an experimental feature, or is