From 418f4ca6b4991ec51fae7a36b7d13fde5f0d96db Mon Sep 17 00:00:00 2001 From: Lukacs Berki Date: Fri, 27 Feb 2015 13:08:48 +0000 Subject: Remove --compile_only and --compilation_prerequisites_only; --output_groups can be used in their stead. -- MOS_MIGRATED_REVID=87334648 --- .../devtools/build/lib/buildtool/BuildRequest.java | 57 +++------------------- .../build/lib/runtime/commands/RunCommand.java | 6 --- .../build/lib/runtime/commands/TestCommand.java | 32 ++++++------ 3 files changed, 23 insertions(+), 72 deletions(-) (limited to 'src/main/java/com/google/devtools/build/lib') 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 0b56fa06d8..c9133d0fb3 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 @@ -24,7 +24,6 @@ import com.google.devtools.build.lib.Constants; import com.google.devtools.build.lib.analysis.BuildView; import com.google.devtools.build.lib.analysis.TopLevelArtifactContext; import com.google.devtools.build.lib.analysis.TopLevelArtifactProvider; -import com.google.devtools.build.lib.analysis.config.BuildConfiguration.Options; 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; @@ -214,21 +213,6 @@ public class BuildRequest implements OptionsClassProvider { + "those phases.") public boolean performExecutionPhase; - @Option(name = "compile_only", - defaultValue = "false", - category = "what", - help = "If specified, Blaze will only build files that are generated by lightweight " - + "compilation actions, skipping more expensive build steps (such as linking).") - public boolean compileOnly; - - @Option(name = "compilation_prerequisites_only", - defaultValue = "false", - category = "what", - help = "If specified, Blaze will only build files that are prerequisites to compilation " - + "of the given target (for example, generated source files and headers) without " - + "building the target itself. This flag is ignored if --compile_only is enabled.") - public boolean compilationPrerequisitesOnly; - @Option(name = "output_groups", converter = Converters.CommaSeparatedOptionListConverter.class, allowMultiple = true, @@ -237,14 +221,6 @@ public class BuildRequest implements OptionsClassProvider { help = "Specifies, which output groups of the top-level target to build.") public List outputGroups; - @Option(name = "build_default_artifacts", - defaultValue = "true", - category = "undocumented", - help = "Whether to build the files to build of the configured targets on the command line. " - + "If false, only the artifacts specified by --output_groups is built. The default " - + "is true.") - public boolean buildDefaultArtifacts; - @Option(name = "show_result", defaultValue = "1", category = "verbosity", @@ -520,10 +496,6 @@ public class BuildRequest implements OptionsClassProvider { if (getBuildOptions().verboseExplanations && getBuildOptions().explanationPath == null) { warnings.add("--verbose_explanations has no effect when --explain= is not enabled"); } - if (getBuildOptions().compileOnly && getBuildOptions().compilationPrerequisitesOnly) { - throw new InvalidConfigurationException( - "--compile_only and --compilation_prerequisites_only are not compatible"); - } return warnings; } @@ -540,30 +512,13 @@ public class BuildRequest implements OptionsClassProvider { current.add(TopLevelArtifactProvider.TEMP_FILES); current.add(TopLevelArtifactProvider.HIDDEN_TOP_LEVEL); current.add(TopLevelArtifactProvider.DEFAULT); - current.addAll(getBuildOptions().outputGroups); - - if (getOptions(Options.class).collectCodeCoverage && runTests) { - current.add(TopLevelArtifactProvider.BASELINE_COVERAGE); - } - - BuildRequestOptions options = getOptions(BuildRequestOptions.class); - if (!options.buildDefaultArtifacts) { - current.remove(TopLevelArtifactProvider.DEFAULT); - current.remove(TopLevelArtifactProvider.HIDDEN_TOP_LEVEL); - } - - if (options.compileOnly) { - current.add(TopLevelArtifactProvider.FILES_TO_COMPILE); - current.remove(TopLevelArtifactProvider.BASELINE_COVERAGE); - current.remove(TopLevelArtifactProvider.DEFAULT); - current.remove(TopLevelArtifactProvider.HIDDEN_TOP_LEVEL); - } - if (options.compilationPrerequisitesOnly) { - current.add(TopLevelArtifactProvider.COMPILATION_PREREQUISITES); - current.remove(TopLevelArtifactProvider.BASELINE_COVERAGE); - current.remove(TopLevelArtifactProvider.DEFAULT); - current.remove(TopLevelArtifactProvider.HIDDEN_TOP_LEVEL); + for (String outputGroup : getBuildOptions().outputGroups) { + if (outputGroup.startsWith("-")) { + current.remove(outputGroup.substring(1)); + } else { + current.add(outputGroup); + } } return ImmutableSortedSet.copyOf(current); diff --git a/src/main/java/com/google/devtools/build/lib/runtime/commands/RunCommand.java b/src/main/java/com/google/devtools/build/lib/runtime/commands/RunCommand.java index b128d372ab..472b8d6741 100644 --- a/src/main/java/com/google/devtools/build/lib/runtime/commands/RunCommand.java +++ b/src/main/java/com/google/devtools/build/lib/runtime/commands/RunCommand.java @@ -144,12 +144,6 @@ public class RunCommand implements BlazeCommand { this.getClass().getAnnotation(Command.class).name(), options, runtime.getStartupOptionsProvider(), targets, outErr, runtime.getCommandId(), runtime.getCommandStartTime()); - if (request.getBuildOptions().compileOnly) { - String message = "The '" + getClass().getAnnotation(Command.class).name() + - "' command is incompatible with the --compile_only option"; - runtime.getReporter().handle(Event.error(message)); - return ExitCode.COMMAND_LINE_ERROR; - } currentRunUnder = runUnder; BuildResult result; diff --git a/src/main/java/com/google/devtools/build/lib/runtime/commands/TestCommand.java b/src/main/java/com/google/devtools/build/lib/runtime/commands/TestCommand.java index 561c54a5b2..094add61a3 100644 --- a/src/main/java/com/google/devtools/build/lib/runtime/commands/TestCommand.java +++ b/src/main/java/com/google/devtools/build/lib/runtime/commands/TestCommand.java @@ -16,6 +16,8 @@ package com.google.devtools.build.lib.runtime.commands; import com.google.common.collect.ImmutableList; import com.google.devtools.build.lib.analysis.ConfiguredTarget; +import com.google.devtools.build.lib.analysis.TopLevelArtifactProvider; +import com.google.devtools.build.lib.analysis.config.BuildConfiguration; import com.google.devtools.build.lib.buildtool.BuildRequest; import com.google.devtools.build.lib.buildtool.BuildResult; import com.google.devtools.build.lib.events.Event; @@ -62,17 +64,23 @@ public class TestCommand implements BlazeCommand { TestOutputFormat testOutput = optionsParser.getOptions(ExecutionOptions.class).testOutput; - if (testOutput == TestStrategy.TestOutputFormat.STREAMED) { - runtime.getReporter().handle(Event.warn( - "Streamed test output requested so all tests will be run locally, without sharding, " + - "one at a time")); - try { + try { + if (testOutput == TestStrategy.TestOutputFormat.STREAMED) { + runtime.getReporter().handle(Event.warn( + "Streamed test output requested so all tests will be run locally, without sharding, " + + "one at a time")); + optionsParser.parse(OptionPriority.SOFTWARE_REQUIREMENT, + "streamed output requires locally run tests, without sharding", + ImmutableList.of("--test_sharding_strategy=disabled", "--test_strategy=exclusive")); + } + + if (optionsParser.getOptions(BuildConfiguration.Options.class).collectCodeCoverage) { optionsParser.parse(OptionPriority.SOFTWARE_REQUIREMENT, - "streamed output requires locally run tests, without sharding", - ImmutableList.of("--test_sharding_strategy=disabled", "--test_strategy=exclusive")); - } catch (OptionsParsingException e) { - throw new IllegalStateException("Known options failed to parse", e); + "baseline coverage artifacts are built with running tests with coverage collection", + ImmutableList.of("--output_groups=" + TopLevelArtifactProvider.BASELINE_COVERAGE)); } + } catch (OptionsParsingException e) { + throw new IllegalStateException("Known options failed to parse", e); } } @@ -104,12 +112,6 @@ public class TestCommand implements BlazeCommand { getClass().getAnnotation(Command.class).name(), options, runtime.getStartupOptionsProvider(), targets, runtime.getReporter().getOutErr(), runtime.getCommandId(), runtime.getCommandStartTime()); - if (request.getBuildOptions().compileOnly) { - String message = "The '" + getClass().getAnnotation(Command.class).name() + - "' command is incompatible with the --compile_only option"; - runtime.getReporter().handle(Event.error(message)); - return ExitCode.COMMAND_LINE_ERROR; - } request.setRunTests(); BuildResult buildResult = runtime.getBuildTool().processRequest(request, null); -- cgit v1.2.3