From 2eaa02e8b630ce94fff39422334c47726ead6324 Mon Sep 17 00:00:00 2001 From: ccalvarin Date: Mon, 17 Apr 2017 23:37:46 +0200 Subject: Split out option usage restriction from option category. These are two different concepts. Do not remove category overload compatibility in this CL, to keep this change limited to converting the current uses of category. With some flyby formatting fixes on affected OptionsBases. RELNOTES: None. PiperOrigin-RevId: 153390002 --- .../devtools/build/lib/analysis/BuildView.java | 90 +-- .../build/lib/analysis/WorkspaceStatusAction.java | 34 +- .../lib/analysis/config/BuildConfiguration.java | 690 ++++++++++++--------- .../lib/bazel/repository/RepositoryOptions.java | 16 +- .../rules/python/BazelPythonConfiguration.java | 9 +- .../transports/BuildEventStreamOptions.java | 23 +- .../devtools/build/lib/buildtool/BuildRequest.java | 308 +++++---- .../devtools/build/lib/exec/ExecutionOptions.java | 278 +++++---- .../lib/exec/local/LocalExecutionOptions.java | 31 +- .../build/lib/pkgcache/LoadingOptions.java | 173 +++--- .../build/lib/pkgcache/PackageCacheOptions.java | 124 ++-- .../build/lib/query2/output/QueryOptions.java | 234 ++++--- .../lib/rules/android/AndroidConfiguration.java | 349 ++++++----- .../lib/rules/apple/AppleCommandLineOptions.java | 201 +++--- .../config/ConfigFeatureFlagConfiguration.java | 10 +- .../devtools/build/lib/rules/cpp/CppOptions.java | 5 +- .../devtools/build/lib/rules/java/JavaOptions.java | 296 +++++---- .../lib/rules/objc/J2ObjcCommandLineOptions.java | 66 +- .../lib/rules/objc/ObjcCommandLineOptions.java | 175 +++--- .../lib/runtime/BlazeCommandEventHandler.java | 149 +++-- .../lib/runtime/BlazeServerStartupOptions.java | 325 ++++++---- .../build/lib/runtime/CommonCommandOptions.java | 260 ++++---- .../lib/runtime/commands/CanonicalizeCommand.java | 11 +- 23 files changed, 2222 insertions(+), 1635 deletions(-) (limited to 'src/main/java/com/google/devtools/build/lib') diff --git a/src/main/java/com/google/devtools/build/lib/analysis/BuildView.java b/src/main/java/com/google/devtools/build/lib/analysis/BuildView.java index 036e7473b1..5d56cf31d4 100644 --- a/src/main/java/com/google/devtools/build/lib/analysis/BuildView.java +++ b/src/main/java/com/google/devtools/build/lib/analysis/BuildView.java @@ -95,6 +95,7 @@ import com.google.devtools.build.skyframe.WalkableGraph; import com.google.devtools.common.options.Converter; import com.google.devtools.common.options.Option; import com.google.devtools.common.options.OptionsBase; +import com.google.devtools.common.options.OptionsParser.OptionUsageRestrictions; import com.google.devtools.common.options.OptionsParsingException; import java.util.ArrayList; import java.util.Collection; @@ -156,9 +157,9 @@ import javax.annotation.Nullable; public class BuildView { /** - * Options that affect the mechanism of analysis. These are distinct from {@link - * com.google.devtools.build.lib.analysis.config.BuildOptions}, which affect the value - * of a BuildConfiguration. + * Options that affect the mechanism of analysis. These are distinct from {@link + * com.google.devtools.build.lib.analysis.config.BuildOptions}, which affect the value of a + * BuildConfiguration. */ public static class Options extends OptionsBase { @Option( @@ -170,42 +171,54 @@ public class BuildView { ) public int loadingPhaseThreads; - @Option(name = "keep_going", - abbrev = 'k', - defaultValue = "false", - category = "strategy", - help = "Continue as much as possible after an error. While the" - + " target that failed, and those that depend on it, cannot be" - + " analyzed (or built), the other prerequisites of these" - + " targets can be analyzed (or built) all the same.") + @Option( + name = "keep_going", + abbrev = 'k', + defaultValue = "false", + category = "strategy", + help = + "Continue as much as possible after an error. While the target that failed, and those " + + "that depend on it, cannot be analyzed (or built), the other prerequisites of " + + "these targets can be analyzed (or built) all the same." + ) public boolean keepGoing; - @Option(name = "analysis_warnings_as_errors", - deprecationWarning = "analysis_warnings_as_errors is now a no-op and will be removed in" - + " an upcoming Blaze release", - defaultValue = "false", - category = "strategy", - help = "Treat visible analysis warnings as errors.") + @Option( + name = "analysis_warnings_as_errors", + deprecationWarning = + "analysis_warnings_as_errors is now a no-op and will be removed in" + + " an upcoming Blaze release", + defaultValue = "false", + category = "strategy", + help = "Treat visible analysis warnings as errors." + ) public boolean analysisWarningsAsErrors; - @Option(name = "discard_analysis_cache", - defaultValue = "false", - category = "strategy", - help = "Discard the analysis cache immediately after the analysis phase completes." - + " Reduces memory usage by ~10%, but makes further incremental builds slower.") + @Option( + name = "discard_analysis_cache", + defaultValue = "false", + category = "strategy", + help = + "Discard the analysis cache immediately after the analysis phase completes." + + " Reduces memory usage by ~10%, but makes further incremental builds slower." + ) public boolean discardAnalysisCache; - @Option(name = "experimental_extra_action_filter", - defaultValue = "", - category = "experimental", - converter = RegexFilter.RegexFilterConverter.class, - help = "Filters set of targets to schedule extra_actions for.") + @Option( + name = "experimental_extra_action_filter", + defaultValue = "", + category = "experimental", + converter = RegexFilter.RegexFilterConverter.class, + help = "Filters set of targets to schedule extra_actions for." + ) public RegexFilter extraActionFilter; - @Option(name = "experimental_extra_action_top_level_only", - defaultValue = "false", - category = "experimental", - help = "Only schedules extra_actions for top level targets.") + @Option( + name = "experimental_extra_action_top_level_only", + defaultValue = "false", + category = "experimental", + help = "Only schedules extra_actions for top level targets." + ) public boolean extraActionTopLevelOnly; @Option( @@ -220,12 +233,15 @@ public class BuildView { ) public boolean extraActionTopLevelOnlyWithAspects; - @Option(name = "version_window_for_dirty_node_gc", - defaultValue = "0", - category = "undocumented", - help = "Nodes that have been dirty for more than this many versions will be deleted" - + " from the graph upon the next update. Values must be non-negative long integers," - + " or -1 indicating the maximum possible window.") + @Option( + name = "version_window_for_dirty_node_gc", + defaultValue = "0", + optionUsageRestrictions = OptionUsageRestrictions.UNDOCUMENTED, + help = + "Nodes that have been dirty for more than this many versions will be deleted" + + " from the graph upon the next update. Values must be non-negative long integers," + + " or -1 indicating the maximum possible window." + ) public long versionWindowForDirtyNodeGc; @Deprecated diff --git a/src/main/java/com/google/devtools/build/lib/analysis/WorkspaceStatusAction.java b/src/main/java/com/google/devtools/build/lib/analysis/WorkspaceStatusAction.java index 21d3d38730..b02bf3b4af 100644 --- a/src/main/java/com/google/devtools/build/lib/analysis/WorkspaceStatusAction.java +++ b/src/main/java/com/google/devtools/build/lib/analysis/WorkspaceStatusAction.java @@ -29,6 +29,7 @@ import com.google.devtools.build.lib.vfs.Path; import com.google.devtools.build.lib.vfs.PathFragment; import com.google.devtools.common.options.Option; import com.google.devtools.common.options.OptionsBase; +import com.google.devtools.common.options.OptionsParser.OptionUsageRestrictions; import java.io.IOException; import java.util.HashMap; import java.util.List; @@ -55,29 +56,34 @@ public abstract class WorkspaceStatusAction extends AbstractAction { * Options controlling the workspace status command. */ public static class Options extends OptionsBase { - @Option(name = "embed_label", - defaultValue = "", - category = "misc", - valueHelp = "", - help = "Embed source control revision or release label in binary") + @Option( + name = "embed_label", + defaultValue = "", + category = "misc", + valueHelp = "", + help = "Embed source control revision or release label in binary" + ) public String embedLabel; @Option( name = "experimental_embed_timestamp_epoch", defaultValue = "-1", - category = "undocumented", + optionUsageRestrictions = OptionUsageRestrictions.UNDOCUMENTED, help = "Alternative timestamp to be used in stamping the binary" ) public long embedTimestampEpoch; - @Option(name = "workspace_status_command", - defaultValue = "", - category = "misc", - converter = OptionsUtils.PathFragmentConverter.class, - valueHelp = "", - help = "A command invoked at the beginning of the build to provide status " - + "information about the workspace in the form of key/value pairs. " - + "See the User's Manual for the full specification.") + @Option( + name = "workspace_status_command", + defaultValue = "", + category = "misc", + converter = OptionsUtils.PathFragmentConverter.class, + valueHelp = "", + help = + "A command invoked at the beginning of the build to provide status " + + "information about the workspace in the form of key/value pairs. " + + "See the User's Manual for the full specification." + ) public PathFragment workspaceStatusCommand; } diff --git a/src/main/java/com/google/devtools/build/lib/analysis/config/BuildConfiguration.java b/src/main/java/com/google/devtools/build/lib/analysis/config/BuildConfiguration.java index c38cfc2e5e..8c733c5db1 100644 --- a/src/main/java/com/google/devtools/build/lib/analysis/config/BuildConfiguration.java +++ b/src/main/java/com/google/devtools/build/lib/analysis/config/BuildConfiguration.java @@ -75,6 +75,7 @@ import com.google.devtools.common.options.Converter; import com.google.devtools.common.options.Converters; import com.google.devtools.common.options.EnumConverter; import com.google.devtools.common.options.Option; +import com.google.devtools.common.options.OptionsParser.OptionUsageRestrictions; import com.google.devtools.common.options.OptionsParsingException; import com.google.devtools.common.options.TriState; import java.util.ArrayList; @@ -479,123 +480,153 @@ public final class BuildConfiguration { */ public static class Options extends FragmentOptions implements Cloneable { @Option( - name = "define", - converter = Converters.AssignmentConverter.class, - defaultValue = "", - category = "semantics", - allowMultiple = true, - help = "Each --define option specifies an assignment for a build variable." + name = "define", + converter = Converters.AssignmentConverter.class, + defaultValue = "", + category = "semantics", + allowMultiple = true, + help = "Each --define option specifies an assignment for a build variable." ) public List> commandLineBuildVariables; - @Option(name = "cpu", - defaultValue = "", - category = "semantics", - converter = AutoCpuConverter.class, - help = "The target CPU.") + @Option( + name = "cpu", + defaultValue = "", + category = "semantics", + converter = AutoCpuConverter.class, + help = "The target CPU." + ) public String cpu; /** * Allows a configuration to record if --experimental_multi_cpu was used to set a cpu value. - * This is necessary to ensure that a configuration transition that sets cpu does not erase - * the difference between a pair of configurations created by --experimental_multi_cpu, leading - * to a crash when the configurations are treated as the same. + * This is necessary to ensure that a configuration transition that sets cpu does not erase the + * difference between a pair of configurations created by --experimental_multi_cpu, leading to a + * crash when the configurations are treated as the same. * *

TODO(b/33780512): Remove once dynamic configurations are used. */ - @Option(name = "experimental multi cpu distinguisher", - defaultValue = "", - category = "internal") + @Option( + name = "experimental multi cpu distinguisher", + defaultValue = "", + optionUsageRestrictions = OptionUsageRestrictions.INTERNAL + ) public String experimentalMultiCpuDistinguisher; - @Option(name = "min_param_file_size", - defaultValue = "32768", - category = "undocumented", - help = "Minimum command line length before creating a parameter file.") + @Option( + name = "min_param_file_size", + defaultValue = "32768", + optionUsageRestrictions = OptionUsageRestrictions.UNDOCUMENTED, + help = "Minimum command line length before creating a parameter file." + ) public int minParamFileSize; - @Option(name = "experimental_extended_sanity_checks", - defaultValue = "false", - category = "undocumented", - help = "Enables internal validation checks to make sure that configured target " - + "implementations only access things they should. Causes a performance hit.") + @Option( + name = "experimental_extended_sanity_checks", + defaultValue = "false", + optionUsageRestrictions = OptionUsageRestrictions.UNDOCUMENTED, + help = + "Enables internal validation checks to make sure that configured target " + + "implementations only access things they should. Causes a performance hit." + ) public boolean extendedSanityChecks; - @Option(name = "experimental_allow_runtime_deps_on_neverlink", - defaultValue = "true", - category = "undocumented", - help = "Flag to help transition from allowing to disallowing runtime_deps on neverlink" - + " Java archives. The depot needs to be cleaned up to roll this out by default.") + @Option( + name = "experimental_allow_runtime_deps_on_neverlink", + defaultValue = "true", + optionUsageRestrictions = OptionUsageRestrictions.UNDOCUMENTED, + help = + "Flag to help transition from allowing to disallowing runtime_deps on neverlink" + + " Java archives. The depot needs to be cleaned up to roll this out by default." + ) public boolean allowRuntimeDepsOnNeverLink; - @Option(name = "strict_filesets", - defaultValue = "false", - category = "semantics", - help = "If this option is enabled, filesets crossing package boundaries are reported " - + "as errors. It does not work when check_fileset_dependencies_recursively is " - + "disabled.") + @Option( + name = "strict_filesets", + defaultValue = "false", + category = "semantics", + help = + "If this option is enabled, filesets crossing package boundaries are reported " + + "as errors. It does not work when check_fileset_dependencies_recursively is " + + "disabled." + ) public boolean strictFilesets; // Plugins are build using the host config. To avoid cycles we just don't propagate // this option to the host config. If one day we decide to use plugins when building // host tools, we can improve this by (for example) creating a compiler configuration that is // used only for building plugins. - @Option(name = "plugin", - converter = LabelConverter.class, - allowMultiple = true, - defaultValue = "", - category = "flags", - help = "Plugins to use in the build. Currently works with java_plugin.") + @Option( + name = "plugin", + converter = LabelConverter.class, + allowMultiple = true, + defaultValue = "", + category = "flags", + help = "Plugins to use in the build. Currently works with java_plugin." + ) public List

For example: "--default_override=build=--cpu=piii" */ - @Option(name = "default_override", - defaultValue = "", - allowMultiple = true, - category = "hidden", - converter = OptionOverrideConverter.class, - help = "") + @Option( + name = "default_override", + defaultValue = "", + allowMultiple = true, + optionUsageRestrictions = OptionUsageRestrictions.HIDDEN, + converter = OptionOverrideConverter.class, + help = "" + ) public List optionsOverrides; - /** - * This is the filename that the Blaze client parsed. - */ - @Option(name = "rc_source", - defaultValue = "", - allowMultiple = true, - category = "hidden", - help = "") + /** This is the filename that the Blaze client parsed. */ + @Option( + name = "rc_source", + defaultValue = "", + allowMultiple = true, + optionUsageRestrictions = OptionUsageRestrictions.HIDDEN, + help = "" + ) public List rcSource; - @Option(name = "always_profile_slow_operations", - defaultValue = "true", - category = "undocumented", - help = "Whether profiling slow operations is always turned on") + @Option( + name = "always_profile_slow_operations", + defaultValue = "true", + optionUsageRestrictions = OptionUsageRestrictions.UNDOCUMENTED, + help = "Whether profiling slow operations is always turned on" + ) public boolean alwaysProfileSlowOperations; - @Option(name = "profile", - defaultValue = "null", - category = "misc", - converter = OptionsUtils.PathFragmentConverter.class, - help = "If set, profile Blaze and write data to the specified " - + "file. Use blaze analyze-profile to analyze the profile.") + @Option( + name = "profile", + defaultValue = "null", + category = "misc", + converter = OptionsUtils.PathFragmentConverter.class, + help = + "If set, profile Blaze and write data to the specified " + + "file. Use blaze analyze-profile to analyze the profile." + ) public PathFragment profilePath; - @Option(name = "record_full_profiler_data", - defaultValue = "false", - category = "undocumented", - help = "By default, Blaze profiler will record only aggregated data for fast but numerous " - + "events (such as statting the file). If this option is enabled, profiler will record " - + "each event - resulting in more precise profiling data but LARGE performance " - + "hit. Option only has effect if --profile used as well.") + @Option( + name = "record_full_profiler_data", + defaultValue = "false", + optionUsageRestrictions = OptionUsageRestrictions.UNDOCUMENTED, + help = + "By default, Blaze profiler will record only aggregated data for fast but numerous " + + "events (such as statting the file). If this option is enabled, profiler will record " + + "each event - resulting in more precise profiling data but LARGE performance " + + "hit. Option only has effect if --profile used as well." + ) public boolean recordFullProfilerData; - @Option(name = "memory_profile", - defaultValue = "null", - category = "undocumented", - converter = OptionsUtils.PathFragmentConverter.class, - help = "If set, write memory usage data to the specified " - + "file at phase ends.") + @Option( + name = "memory_profile", + defaultValue = "null", + optionUsageRestrictions = OptionUsageRestrictions.UNDOCUMENTED, + converter = OptionsUtils.PathFragmentConverter.class, + help = "If set, write memory usage data to the specified " + "file at phase ends." + ) public PathFragment memoryProfilePath; - @Option(name = "gc_watchdog", - defaultValue = "false", - category = "undocumented", - deprecationWarning = "Ignoring: this option is no longer supported", - help = "Deprecated.") + @Option( + name = "gc_watchdog", + defaultValue = "false", + optionUsageRestrictions = OptionUsageRestrictions.UNDOCUMENTED, + deprecationWarning = "Ignoring: this option is no longer supported", + help = "Deprecated." + ) public boolean gcWatchdog; - @Option(name = "startup_time", - defaultValue = "0", - category = "hidden", - help = "The time in ms the launcher spends before sending the request to the blaze server.") + @Option( + name = "startup_time", + defaultValue = "0", + optionUsageRestrictions = OptionUsageRestrictions.HIDDEN, + help = "The time in ms the launcher spends before sending the request to the blaze server." + ) public long startupTime; @Option( name = "extract_data_time", defaultValue = "0", - category = "hidden", + optionUsageRestrictions = OptionUsageRestrictions.HIDDEN, help = "The time in ms spent on extracting the new blaze version." ) public long extractDataTime; - @Option(name = "command_wait_time", - defaultValue = "0", - category = "hidden", - help = "The time in ms a command had to wait on a busy Blaze server process.") + @Option( + name = "command_wait_time", + defaultValue = "0", + optionUsageRestrictions = OptionUsageRestrictions.HIDDEN, + help = "The time in ms a command had to wait on a busy Blaze server process." + ) public long waitTime; - @Option(name = "tool_tag", - defaultValue = "", - category = "misc", - help = "A tool name to attribute this Blaze invocation to.") + @Option( + name = "tool_tag", + defaultValue = "", + category = "misc", + help = "A tool name to attribute this Blaze invocation to." + ) public String toolTag; - @Option(name = "restart_reason", - defaultValue = "no_restart", - category = "hidden", - help = "The reason for the server restart.") + @Option( + name = "restart_reason", + defaultValue = "no_restart", + optionUsageRestrictions = OptionUsageRestrictions.HIDDEN, + help = "The reason for the server restart." + ) public String restartReason; - @Option(name = "binary_path", - defaultValue = "", - category = "hidden", - help = "The absolute path of the blaze binary.") + @Option( + name = "binary_path", + defaultValue = "", + optionUsageRestrictions = OptionUsageRestrictions.HIDDEN, + help = "The absolute path of the blaze binary." + ) public String binaryPath; - @Option(name = "experimental_allow_project_files", - defaultValue = "false", - category = "hidden", - help = "Enable processing of + parameters.") + @Option( + name = "experimental_allow_project_files", + defaultValue = "false", + optionUsageRestrictions = OptionUsageRestrictions.HIDDEN, + help = "Enable processing of + parameters." + ) public boolean allowProjectFiles; - @Option(name = "block_for_lock", - defaultValue = "true", - category = "hidden", - help = "If set (the default), a command will block if there is another one running. If " - + "unset, these commands will immediately return with an error.") + @Option( + name = "block_for_lock", + defaultValue = "true", + optionUsageRestrictions = OptionUsageRestrictions.HIDDEN, + help = + "If set (the default), a command will block if there is another one running. If " + + "unset, these commands will immediately return with an error." + ) public boolean blockForLock; } diff --git a/src/main/java/com/google/devtools/build/lib/runtime/commands/CanonicalizeCommand.java b/src/main/java/com/google/devtools/build/lib/runtime/commands/CanonicalizeCommand.java index 01519a54a1..2831e6babe 100644 --- a/src/main/java/com/google/devtools/build/lib/runtime/commands/CanonicalizeCommand.java +++ b/src/main/java/com/google/devtools/build/lib/runtime/commands/CanonicalizeCommand.java @@ -29,6 +29,7 @@ import com.google.devtools.build.lib.util.ExitCode; import com.google.devtools.common.options.Option; import com.google.devtools.common.options.OptionsBase; import com.google.devtools.common.options.OptionsParser; +import com.google.devtools.common.options.OptionsParser.OptionUsageRestrictions; import com.google.devtools.common.options.OptionsParsingException; import com.google.devtools.common.options.OptionsProvider; import java.util.Collection; @@ -87,13 +88,17 @@ public final class CanonicalizeCommand implements BlazeCommand { * are undocumented no-ops, and are not to be used by anything outside of that test. */ public static class FlagClashCanaryOptions extends OptionsBase { - @Option(name = "flag_clash_canary", defaultValue = "false", category = "undocumented") + @Option( + name = "flag_clash_canary", + defaultValue = "false", + optionUsageRestrictions = OptionUsageRestrictions.UNDOCUMENTED + ) public boolean flagClashCanary; @Option( name = "flag_clash_canary_expander1", defaultValue = "null", - category = "undocumented", + optionUsageRestrictions = OptionUsageRestrictions.UNDOCUMENTED, expansion = {"--flag_clash_canary=1"} ) public Void flagClashCanaryExpander1; @@ -101,7 +106,7 @@ public final class CanonicalizeCommand implements BlazeCommand { @Option( name = "flag_clash_canary_expander2", defaultValue = "null", - category = "undocumented", + optionUsageRestrictions = OptionUsageRestrictions.UNDOCUMENTED, expansion = {"--flag_clash_canary=0"} ) public Void flagClashCanaryExpander2; -- cgit v1.2.3