diff options
author | 2015-11-02 14:15:20 +0000 | |
---|---|---|
committer | 2015-11-02 16:56:54 +0000 | |
commit | 4758969f0cfb2aea4cdf892b8afc367dfe739614 (patch) | |
tree | 34ec345605061d0057b3f8f3e2ce79e943d1f0dc /src/main/java/com/google/devtools | |
parent | f96edf7bc9346c7e7bd2260f032d8c89d074c650 (diff) |
Move LoadingPhaseRunner.Options to top-level class LoadingOptions.
--
MOS_MIGRATED_REVID=106836859
Diffstat (limited to 'src/main/java/com/google/devtools')
6 files changed, 117 insertions, 101 deletions
diff --git a/src/main/java/com/google/devtools/build/lib/buildtool/BuildRequest.java b/src/main/java/com/google/devtools/build/lib/buildtool/BuildRequest.java index c4f3aa35e8..bc9269b4b8 100644 --- a/src/main/java/com/google/devtools/build/lib/buildtool/BuildRequest.java +++ b/src/main/java/com/google/devtools/build/lib/buildtool/BuildRequest.java @@ -26,7 +26,7 @@ import com.google.devtools.build.lib.analysis.OutputGroupProvider; import com.google.devtools.build.lib.analysis.TopLevelArtifactContext; import com.google.devtools.build.lib.analysis.config.InvalidConfigurationException; import com.google.devtools.build.lib.exec.ExecutionOptions; -import com.google.devtools.build.lib.pkgcache.LoadingPhaseRunner; +import com.google.devtools.build.lib.pkgcache.LoadingOptions; import com.google.devtools.build.lib.pkgcache.PackageCacheOptions; import com.google.devtools.build.lib.runtime.BlazeCommandEventHandler; import com.google.devtools.build.lib.util.OptionsUtils; @@ -313,7 +313,7 @@ public class BuildRequest implements OptionsClassProvider { private static final List<Class<? extends OptionsBase>> MANDATORY_OPTIONS = ImmutableList.of( BuildRequestOptions.class, PackageCacheOptions.class, - LoadingPhaseRunner.Options.class, + LoadingOptions.class, BuildView.Options.class, ExecutionOptions.class); @@ -431,8 +431,8 @@ public class BuildRequest implements OptionsClassProvider { /** * Returns the set of options related to the loading phase. */ - public LoadingPhaseRunner.Options getLoadingOptions() { - return getOptions(LoadingPhaseRunner.Options.class); + public LoadingOptions getLoadingOptions() { + return getOptions(LoadingOptions.class); } /** diff --git a/src/main/java/com/google/devtools/build/lib/pkgcache/LoadingOptions.java b/src/main/java/com/google/devtools/build/lib/pkgcache/LoadingOptions.java new file mode 100644 index 0000000000..6739388cad --- /dev/null +++ b/src/main/java/com/google/devtools/build/lib/pkgcache/LoadingOptions.java @@ -0,0 +1,103 @@ +// Copyright 2015 The Bazel Authors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +package com.google.devtools.build.lib.pkgcache; + +import com.google.devtools.build.lib.packages.TestSize; +import com.google.devtools.build.lib.packages.TestTimeout; +import com.google.devtools.common.options.Option; +import com.google.devtools.common.options.OptionsBase; +import com.google.devtools.common.options.Converters.CommaSeparatedOptionListConverter; + +import java.util.List; +import java.util.Set; + +/** + * Options that affect how command-line target patterns are resolved to individual targets. + */ +public class LoadingOptions extends OptionsBase { + + @Option(name = "loading_phase_threads", + defaultValue = "200", + category = "undocumented", + help = "Number of parallel threads to use for the loading phase.") + public int loadingPhaseThreads; + + @Option(name = "build_tests_only", + defaultValue = "false", + category = "what", + help = "If specified, only *_test and test_suite rules will be built " + + "and other targets specified on the command line will be ignored. " + + "By default everything that was requested will be built.") + public boolean buildTestsOnly; + + @Option(name = "compile_one_dependency", + defaultValue = "false", + category = "what", + help = "Compile a single dependency of the argument files. " + + "This is useful for syntax checking source files in IDEs, " + + "for example, by rebuilding a single target that depends on " + + "the source file to detect errors as early as possible in the " + + "edit/build/test cycle. This argument affects the way all " + + "non-flag arguments are interpreted; instead of being targets " + + "to build they are source filenames. For each source filename " + + "an arbitrary target that depends on it will be built.") + public boolean compileOneDependency; + + @Option(name = "test_tag_filters", + converter = CommaSeparatedOptionListConverter.class, + defaultValue = "", + category = "what", + help = "Specifies a comma-separated list of test tags. Each tag can be optionally " + + "preceded with '-' to specify excluded tags. Only those test targets will be " + + "found that contain at least one included tag and do not contain any excluded " + + "tags. This option affects --build_tests_only behavior and the test command." + ) + public List<String> testTagFilterList; + + @Option(name = "test_size_filters", + converter = TestSize.TestSizeFilterConverter.class, + defaultValue = "", + category = "what", + help = "Specifies a comma-separated list of test sizes. Each size can be optionally " + + "preceded with '-' to specify excluded sizes. Only those test targets will be " + + "found that contain at least one included size and do not contain any excluded " + + "sizes. This option affects --build_tests_only behavior and the test command." + ) + public Set<TestSize> testSizeFilterSet; + + @Option(name = "test_timeout_filters", + converter = TestTimeout.TestTimeoutFilterConverter.class, + defaultValue = "", + category = "what", + help = "Specifies a comma-separated list of test timeouts. Each timeout can be " + + "optionally preceded with '-' to specify excluded timeouts. Only those test " + + "targets will be found that contain at least one included timeout and do not " + + "contain any excluded timeouts. This option affects --build_tests_only behavior " + + "and the test command." + ) + public Set<TestTimeout> testTimeoutFilterSet; + + @Option(name = "test_lang_filters", + converter = CommaSeparatedOptionListConverter.class, + defaultValue = "", + category = "what", + help = "Specifies a comma-separated list of test languages. Each language can be " + + "optionally preceded with '-' to specify excluded languages. Only those " + + "test targets will be found that are written in the specified languages. " + + "The name used for each language should be the same as the language prefix in the " + + "*_test rule, e.g. one of 'cc', 'java', 'py', etc." + + "This option affects --build_tests_only behavior and the test command." + ) + public List<String> testLangFilterList; +}
\ No newline at end of file diff --git a/src/main/java/com/google/devtools/build/lib/pkgcache/LoadingPhaseRunner.java b/src/main/java/com/google/devtools/build/lib/pkgcache/LoadingPhaseRunner.java index f0b76dcfb2..c667b7d944 100644 --- a/src/main/java/com/google/devtools/build/lib/pkgcache/LoadingPhaseRunner.java +++ b/src/main/java/com/google/devtools/build/lib/pkgcache/LoadingPhaseRunner.java @@ -34,17 +34,11 @@ import com.google.devtools.build.lib.packages.NonconfigurableAttributeMapper; import com.google.devtools.build.lib.packages.Package; import com.google.devtools.build.lib.packages.Rule; import com.google.devtools.build.lib.packages.Target; -import com.google.devtools.build.lib.packages.TestSize; import com.google.devtools.build.lib.packages.TestTargetUtils; -import com.google.devtools.build.lib.packages.TestTimeout; import com.google.devtools.build.lib.syntax.Type; import com.google.devtools.build.lib.vfs.Path; import com.google.devtools.build.lib.vfs.PathFragment; -import com.google.devtools.common.options.Converters.CommaSeparatedOptionListConverter; -import com.google.devtools.common.options.Option; -import com.google.devtools.common.options.OptionsBase; -import java.util.ArrayList; import java.util.Collection; import java.util.HashSet; import java.util.List; @@ -73,87 +67,7 @@ import javax.annotation.Nullable; * <p>For full caching, this class tracks the exact values of all inputs to the loading phase. To * maximize caching, it is vital that these change as rarely as possible. */ -public class LoadingPhaseRunner { - - /** - * Loading phase options. - */ - public static class Options extends OptionsBase { - - @Option(name = "loading_phase_threads", - defaultValue = "200", - category = "undocumented", - help = "Number of parallel threads to use for the loading phase.") - public int loadingPhaseThreads; - - @Option(name = "build_tests_only", - defaultValue = "false", - category = "what", - help = "If specified, only *_test and test_suite rules will be built " - + "and other targets specified on the command line will be ignored. " - + "By default everything that was requested will be built.") - public boolean buildTestsOnly; - - @Option(name = "compile_one_dependency", - defaultValue = "false", - category = "what", - help = "Compile a single dependency of the argument files. " - + "This is useful for syntax checking source files in IDEs, " - + "for example, by rebuilding a single target that depends on " - + "the source file to detect errors as early as possible in the " - + "edit/build/test cycle. This argument affects the way all " - + "non-flag arguments are interpreted; instead of being targets " - + "to build they are source filenames. For each source filename " - + "an arbitrary target that depends on it will be built.") - public boolean compileOneDependency; - - @Option(name = "test_tag_filters", - converter = CommaSeparatedOptionListConverter.class, - defaultValue = "", - category = "what", - help = "Specifies a comma-separated list of test tags. Each tag can be optionally " + - "preceded with '-' to specify excluded tags. Only those test targets will be " + - "found that contain at least one included tag and do not contain any excluded " + - "tags. This option affects --build_tests_only behavior and the test command." - ) - public List<String> testTagFilterList; - - @Option(name = "test_size_filters", - converter = TestSize.TestSizeFilterConverter.class, - defaultValue = "", - category = "what", - help = "Specifies a comma-separated list of test sizes. Each size can be optionally " + - "preceded with '-' to specify excluded sizes. Only those test targets will be " + - "found that contain at least one included size and do not contain any excluded " + - "sizes. This option affects --build_tests_only behavior and the test command." - ) - public Set<TestSize> testSizeFilterSet; - - @Option(name = "test_timeout_filters", - converter = TestTimeout.TestTimeoutFilterConverter.class, - defaultValue = "", - category = "what", - help = "Specifies a comma-separated list of test timeouts. Each timeout can be " + - "optionally preceded with '-' to specify excluded timeouts. Only those test " + - "targets will be found that contain at least one included timeout and do not " + - "contain any excluded timeouts. This option affects --build_tests_only behavior " + - "and the test command." - ) - public Set<TestTimeout> testTimeoutFilterSet; - - @Option(name = "test_lang_filters", - converter = CommaSeparatedOptionListConverter.class, - defaultValue = "", - category = "what", - help = "Specifies a comma-separated list of test languages. Each language can be " + - "optionally preceded with '-' to specify excluded languages. Only those " + - "test targets will be found that are written in the specified languages. " + - "The name used for each language should be the same as the language prefix in the " + - "*_test rule, e.g. one of 'cc', 'java', 'py', etc." + - "This option affects --build_tests_only behavior and the test command." - ) - public List<String> testLangFilterList; - } +public final class LoadingPhaseRunner { /** * A callback interface to notify the caller about specific events. @@ -286,7 +200,7 @@ public class LoadingPhaseRunner { * given build configuration provider. */ public LoadingResult execute(EventHandler eventHandler, EventBus eventBus, - List<String> targetPatterns, Options options, + List<String> targetPatterns, LoadingOptions options, ListMultimap<String, Label> labelsToLoadUnconditionally, boolean keepGoing, boolean enableLoading, boolean determineTests, @Nullable Callback callback) throws TargetParsingException, LoadingFailedException, InterruptedException { @@ -587,7 +501,7 @@ public class LoadingPhaseRunner { * * @param targetPatterns the list of command-line target patterns specified by the user * @param compileOneDependency if true, enables alternative interpretation of targetPatterns; see - * {@link Options#compileOneDependency} + * {@link LoadingOptions#compileOneDependency} * @throws TargetParsingException if parsing failed and !keepGoing */ private ResolvedTargets<Target> getTargetsToBuild(EventHandler eventHandler, @@ -613,7 +527,7 @@ public class LoadingPhaseRunner { * @param keepGoing value of the --keep_going flag */ private ResolvedTargets<Target> determineTests(EventHandler eventHandler, - List<String> targetPatterns, Options options, boolean keepGoing) + List<String> targetPatterns, LoadingOptions options, boolean keepGoing) throws TargetParsingException, InterruptedException { // Parse the targets to get the tests. ResolvedTargets<Target> testTargetsBuilder = targetPatternEvaluator.parseTargetPatternList( diff --git a/src/main/java/com/google/devtools/build/lib/pkgcache/TestFilter.java b/src/main/java/com/google/devtools/build/lib/pkgcache/TestFilter.java index b034e0d52d..84df151698 100644 --- a/src/main/java/com/google/devtools/build/lib/pkgcache/TestFilter.java +++ b/src/main/java/com/google/devtools/build/lib/pkgcache/TestFilter.java @@ -20,7 +20,6 @@ import com.google.devtools.build.lib.packages.Target; import com.google.devtools.build.lib.packages.TestSize; import com.google.devtools.build.lib.packages.TestTargetUtils; import com.google.devtools.build.lib.packages.TestTimeout; -import com.google.devtools.build.lib.pkgcache.LoadingPhaseRunner.Options; import java.util.List; import java.util.Objects; @@ -29,14 +28,14 @@ import java.util.Set; import javax.annotation.Nullable; /** - * Predicate that implements test filtering using the command-line options in {@link Options}. + * Predicate that implements test filtering using the command-line options in {@link LoadingOptions}. * Implements {@link #hashCode} and {@link #equals} so it can be used as a Skyframe key. */ public final class TestFilter implements Predicate<Target> { /** * Convert the options into a test filter. */ - public static TestFilter forOptions(Options options, EventHandler eventHandler, + public static TestFilter forOptions(LoadingOptions options, EventHandler eventHandler, Set<String> ruleNames) { Predicate<Target> testFilter = Predicates.alwaysTrue(); if (!options.testSizeFilterSet.isEmpty()) { diff --git a/src/main/java/com/google/devtools/build/lib/runtime/commands/BuildCommand.java b/src/main/java/com/google/devtools/build/lib/runtime/commands/BuildCommand.java index 5c68fc2c87..f6bc840ce3 100644 --- a/src/main/java/com/google/devtools/build/lib/runtime/commands/BuildCommand.java +++ b/src/main/java/com/google/devtools/build/lib/runtime/commands/BuildCommand.java @@ -19,7 +19,7 @@ import com.google.devtools.build.lib.buildtool.BuildRequest; import com.google.devtools.build.lib.buildtool.BuildRequest.BuildRequestOptions; import com.google.devtools.build.lib.buildtool.BuildTool; import com.google.devtools.build.lib.exec.ExecutionOptions; -import com.google.devtools.build.lib.pkgcache.LoadingPhaseRunner; +import com.google.devtools.build.lib.pkgcache.LoadingOptions; import com.google.devtools.build.lib.pkgcache.PackageCacheOptions; import com.google.devtools.build.lib.runtime.BlazeCommand; import com.google.devtools.build.lib.runtime.BlazeRuntime; @@ -42,7 +42,7 @@ import java.util.List; ExecutionOptions.class, PackageCacheOptions.class, BuildView.Options.class, - LoadingPhaseRunner.Options.class, + LoadingOptions.class, BuildConfiguration.Options.class, }, usesConfigurationOptions = true, diff --git a/src/main/java/com/google/devtools/build/lib/skyframe/TargetPatternPhaseFunction.java b/src/main/java/com/google/devtools/build/lib/skyframe/TargetPatternPhaseFunction.java index 07903d9a64..1dd3af31cb 100644 --- a/src/main/java/com/google/devtools/build/lib/skyframe/TargetPatternPhaseFunction.java +++ b/src/main/java/com/google/devtools/build/lib/skyframe/TargetPatternPhaseFunction.java @@ -25,7 +25,7 @@ import com.google.devtools.build.lib.packages.Target; import com.google.devtools.build.lib.packages.TargetUtils; import com.google.devtools.build.lib.pkgcache.FilteringPolicies; import com.google.devtools.build.lib.pkgcache.LoadingPhaseRunner; -import com.google.devtools.build.lib.pkgcache.LoadingPhaseRunner.Options; +import com.google.devtools.build.lib.pkgcache.LoadingOptions; import com.google.devtools.build.lib.pkgcache.TestFilter; import com.google.devtools.build.lib.skyframe.TargetPatternPhaseValue.TargetPatternList; import com.google.devtools.build.lib.skyframe.TargetPatternValue.TargetPatternKey; @@ -165,7 +165,7 @@ final class TargetPatternPhaseFunction implements SkyFunction { * * @param targetPatterns the list of command-line target patterns specified by the user * @param compileOneDependency if true, enables alternative interpretation of targetPatterns; see - * {@link Options#compileOneDependency} + * {@link LoadingOptions#compileOneDependency} */ private static ResolvedTargets<Target> getTargetsToBuild(Environment env, List<String> targetPatterns, boolean compileOneDependency) { |