Skip to content

Commit

Permalink
Remove --compile_only and --compilation_prerequisites_only; --output_…
Browse files Browse the repository at this point in the history
…groups can be used in their stead.

--
MOS_MIGRATED_REVID=87334648
  • Loading branch information
lberki authored and hanwen committed Mar 4, 2015
1 parent ca3cf53 commit 418f4ca
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 72 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
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;
Expand Down Expand Up @@ -214,21 +213,6 @@ public static class BuildRequestOptions extends OptionsBase {
+ "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,
Expand All @@ -237,14 +221,6 @@ public static class BuildRequestOptions extends OptionsBase {
help = "Specifies, which output groups of the top-level target to build.")
public List<String> 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",
Expand Down Expand Up @@ -520,10 +496,6 @@ public List<String> validateOptions() throws InvalidConfigurationException {
if (getBuildOptions().verboseExplanations && getBuildOptions().explanationPath == null) {
warnings.add("--verbose_explanations has no effect when --explain=<file> is not enabled");
}
if (getBuildOptions().compileOnly && getBuildOptions().compilationPrerequisitesOnly) {
throw new InvalidConfigurationException(
"--compile_only and --compilation_prerequisites_only are not compatible");
}

return warnings;
}
Expand All @@ -540,30 +512,13 @@ private ImmutableSortedSet<String> determineOutputGroups() {
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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -144,12 +144,6 @@ public ExitCode exec(BlazeRuntime runtime, OptionsProvider options) {
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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@

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;
Expand Down Expand Up @@ -62,17 +64,23 @@ public void editOptions(BlazeRuntime runtime, OptionsParser optionsParser)

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);
}
}

Expand Down Expand Up @@ -104,12 +112,6 @@ private ExitCode doTest(BlazeRuntime runtime,
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);
Expand Down

0 comments on commit 418f4ca

Please sign in to comment.