Here are the examples of the java api com.google.devtools.build.lib.runtime.CommandEnvironment.getReporter() taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.
71 Examples
19
View Complete Implementation : BlazeRuntimeWrapper.java
Copyright Apache License 2.0
Author : bazelbuild
Copyright Apache License 2.0
Author : bazelbuild
public BuildRequest createRequest(String commandName, List<String> targets) {
return BuildRequest.create(commandName, optionsParser, null, targets, env.getReporter().getOutErr(), env.getCommandId(), runtime.getClock().currentTimeMillis());
}
19
View Complete Implementation : VersionCommand.java
Copyright Apache License 2.0
Author : bazelbuild
Copyright Apache License 2.0
Author : bazelbuild
@Override
public BlazeCommandResult exec(CommandEnvironment env, OptionsParsingResult options) {
env.getEventBus().post(new NoBuildEvent());
try {
env.getReporter().getOutErr().printOutLn(getInfo(env.getRuntime().getProductName(), BlazeVersionInfo.instance(), options.getOptions(VersionOptions.clreplaced).gnuFormat));
} catch (IOException e) {
env.getReporter().handle(Event.error(e.getMessage()));
return BlazeCommandResult.exitCode(ExitCode.COMMAND_LINE_ERROR);
}
return BlazeCommandResult.exitCode(ExitCode.SUCCESS);
}
19
View Complete Implementation : BuildTool.java
Copyright Apache License 2.0
Author : bazelbuild
Copyright Apache License 2.0
Author : bazelbuild
private Reporter getReporter() {
return env.getReporter();
}
19
View Complete Implementation : OutputFilteringModule.java
Copyright Apache License 2.0
Author : bazelbuild
Copyright Apache License 2.0
Author : bazelbuild
@Subscribe
@SuppressWarnings("unused")
public void targetParsingComplete(TargetParsingCompleteEvent event) {
if (autoOutputFilter != null) {
env.getReporter().setOutputFilter(autoOutputFilter.getFilter(event.getLabels()));
}
}
19
View Complete Implementation : QueryCommand.java
Copyright Apache License 2.0
Author : bazelbuild
Copyright Apache License 2.0
Author : bazelbuild
/**
* When Blaze is used with --color=no or not in a tty a ansi characters filter is set so that
* we don't print fancy colors in non-supporting terminal outputs. But query output, specifically
* the binary formatters, can print actual data that contain ansi bytes/chars. Because of that
* we need to remove the filtering before printing any query result.
*/
private static void disableAnsiCharactersFiltering(CommandEnvironment env) {
env.getReporter().switchToAnsiAllowingHandler();
}
18
View Complete Implementation : OutputFilterTest.java
Copyright Apache License 2.0
Author : bazelbuild
Copyright Apache License 2.0
Author : bazelbuild
@Test
public void testPackagesAOF_ABC() throws Exception {
enableDeprecationWarnings();
addOptions("--auto_output_filter=packages");
CommandEnvironment env = runtimeWrapper.newCommand();
env.getReporter().addHandler(stderr);
buildTarget("//java/a", "//java/b", "//java/c");
replacedertEvent(deprecationMessages("b", "B", "b"));
replacedertEvent(deprecationMessages("c", "C", "c"));
}
18
View Complete Implementation : LicenseCommand.java
Copyright Apache License 2.0
Author : bazelbuild
Copyright Apache License 2.0
Author : bazelbuild
@Override
public BlazeCommandResult exec(CommandEnvironment env, OptionsParsingResult options) {
env.getEventBus().post(new NoBuildEvent());
OutErr outErr = env.getReporter().getOutErr();
outErr.printOutLn("Licenses of all components included in this binary:\n");
try {
outErr.printOutLn(ResourceFileLoader.loadResource(this.getClreplaced(), "LICENSE"));
} catch (IOException e) {
throw new IllegalStateException("I/O error while trying to print 'LICENSE' resource: " + e.getMessage(), e);
}
Path bundledJdk = env.getDirectories().getEmbeddedBinariesRoot().getRelative("embedded_tools/jdk").getPathFile().toPath();
if (Files.exists(bundledJdk)) {
outErr.printOutLn("This binary comes with a bundled JDK, which contains the following license files:\n");
printJavaLicenseFiles(outErr, bundledJdk);
}
Path bundledJre = env.getDirectories().getEmbeddedBinariesRoot().getRelative("embedded_tools/jre").getPathFile().toPath();
if (Files.exists(bundledJre)) {
outErr.printOutLn("This binary comes with a bundled JRE, which contains the following license files:\n");
printJavaLicenseFiles(outErr, bundledJre);
}
return BlazeCommandResult.exitCode(ExitCode.SUCCESS);
}
18
View Complete Implementation : OutputFilterTest.java
Copyright Apache License 2.0
Author : bazelbuild
Copyright Apache License 2.0
Author : bazelbuild
@Test
public void testPackagesAOF_AB() throws Exception {
enableDeprecationWarnings();
addOptions("--auto_output_filter=packages");
CommandEnvironment env = runtimeWrapper.newCommand();
env.getReporter().addHandler(stderr);
buildTarget("//java/a", "//java/b");
replacedertEvent(deprecationMessages("b", "B", "b"));
replacedertEvent(deprecationMessages("c", "C", "c"));
}
18
View Complete Implementation : OutputFilterTest.java
Copyright Apache License 2.0
Author : bazelbuild
Copyright Apache License 2.0
Author : bazelbuild
@Test
public void testPackagesAOF_JavaTestsA() throws Exception {
enableDeprecationWarnings();
addOptions("--auto_output_filter=packages");
CommandEnvironment env = runtimeWrapper.newCommand();
env.getReporter().addHandler(stderr);
buildTarget("//javatests/a");
replacedertEvent(deprecationMessages("b", "B", "b"));
replacedertNoEvent(deprecationMessages("c", "C", "c"));
replacedertNoEvent(deprecationMessages("c", "CTest", "c"));
}
18
View Complete Implementation : OutputFilterTest.java
Copyright Apache License 2.0
Author : bazelbuild
Copyright Apache License 2.0
Author : bazelbuild
@Test
public void testPackagesAOF_B() throws Exception {
enableDeprecationWarnings();
addOptions("--auto_output_filter=packages");
CommandEnvironment env = runtimeWrapper.newCommand();
env.getReporter().addHandler(stderr);
buildTarget("//java/b");
replacedertNoEvent(deprecationMessages("b", "B", "b"));
replacedertEvent(deprecationMessages("c", "C", "c"));
}
18
View Complete Implementation : SandboxModule.java
Copyright Apache License 2.0
Author : bazelbuild
Copyright Apache License 2.0
Author : bazelbuild
/**
* Unmounts an existing sandboxfs instance unless the user asked not to by providing the {@code
* --sandbox_debug} flag.
*/
private void unmountSandboxfs() {
if (sandboxfsProcess != null) {
if (shouldCleanupSandboxBase) {
sandboxfsProcess.destroy();
sandboxfsProcess = null;
} else {
checkNotNull(env, "env not initialized; was beforeCommand called?");
env.getReporter().handle(Event.info("Leaving sandboxfs mounted because of --sandbox_debug"));
}
}
}
18
View Complete Implementation : OutputFilterTest.java
Copyright Apache License 2.0
Author : bazelbuild
Copyright Apache License 2.0
Author : bazelbuild
@Test
public void testPackagesAOF_JavaTestsAB() throws Exception {
enableDeprecationWarnings();
addOptions("--auto_output_filter=packages");
CommandEnvironment env = runtimeWrapper.newCommand();
env.getReporter().addHandler(stderr);
buildTarget("//javatests/a", "//java/b");
replacedertEvent(deprecationMessages("b", "B", "b"));
replacedertEvent(deprecationMessages("c", "C", "c"));
replacedertEvent(deprecationMessages("c", "CTest", "c"));
}
18
View Complete Implementation : OutputFilterTest.java
Copyright Apache License 2.0
Author : bazelbuild
Copyright Apache License 2.0
Author : bazelbuild
@Test
public void testPackagesAOF_JavaTestsD() throws Exception {
addOptions("--auto_output_filter=packages");
CommandEnvironment env = runtimeWrapper.newCommand();
env.getReporter().addHandler(stderr);
buildTarget("//javatests/d");
replacedertEvent("D.java:6: warning: [cast] redundant cast to int");
replacedertNoEvent("E.java:6: warning: [cast] redundant cast to int");
replacedertNoEvent("ETest.java:6: warning: [cast] redundant cast to int");
}
18
View Complete Implementation : BuildCommand.java
Copyright Apache License 2.0
Author : bazelbuild
Copyright Apache License 2.0
Author : bazelbuild
@Override
public BlazeCommandResult exec(CommandEnvironment env, OptionsParsingResult options) {
BlazeRuntime runtime = env.getRuntime();
List<String> targets;
try (SilentCloseable closeable = Profiler.instance().profile("ProjectFileSupport.getTargets")) {
// only takes {@code options} to get options.getResidue()
targets = ProjectFileSupport.getTargets(runtime.getProjectFileProvider(), options);
}
if (targets.isEmpty()) {
env.getReporter().handle(Event.warn("Usage: " + runtime.getProductName() + " build <options> <targets>." + "\nInvoke `" + runtime.getProductName() + " help build` for full description of usage and options." + "\nYour request is correct, but requested an empty set of targets." + " Nothing will be built."));
}
BuildRequest request;
try (SilentCloseable closeable = Profiler.instance().profile("BuildRequest.create")) {
request = BuildRequest.create(getClreplaced().getAnnotation(Command.clreplaced).name(), options, runtime.getStartupOptionsProvider(), targets, env.getReporter().getOutErr(), env.getCommandId(), env.getCommandStartTime());
}
ExitCode exitCode = new BuildTool(env).processRequest(request, null).getExitCondition();
return BlazeCommandResult.exitCode(exitCode);
}
18
View Complete Implementation : OutputFilterTest.java
Copyright Apache License 2.0
Author : bazelbuild
Copyright Apache License 2.0
Author : bazelbuild
@Test
public void testExplicitFilter() throws Exception {
enableDeprecationWarnings();
addOptions("--output_filter=^//java/a");
CommandEnvironment env = runtimeWrapper.newCommand();
env.getReporter().addHandler(stderr);
buildTarget("//java/a");
replacedertEvent(deprecationMessages("b", "B", "b"));
replacedertNoEvent(deprecationMessages("c", "C", "c"));
}
18
View Complete Implementation : OutputFilterTest.java
Copyright Apache License 2.0
Author : bazelbuild
Copyright Apache License 2.0
Author : bazelbuild
@Test
public void testNoMatchFilter() throws Exception {
enableDeprecationWarnings();
addOptions("--output_filter=DONT_MATCH");
CommandEnvironment env = runtimeWrapper.newCommand();
env.getReporter().addHandler(stderr);
buildTarget("//java/a");
replacedertNoEvent(deprecationMessages("b", "B", "b"));
replacedertNoEvent(deprecationMessages("c", "C", "c"));
}
18
View Complete Implementation : MobileInstallCommand.java
Copyright Apache License 2.0
Author : bazelbuild
Copyright Apache License 2.0
Author : bazelbuild
private boolean isRuleSupported(CommandEnvironment env, List<String> mobileInstallSupportedRules, String ruleType) {
if (!mobileInstallSupportedRules.contains(ruleType)) {
env.getReporter().handle(Event.error(String.format("mobile-install can only be run on %s targets. Got: %s", mobileInstallSupportedRules, ruleType)));
return false;
} else {
return true;
}
}
18
View Complete Implementation : OutputFilterTest.java
Copyright Apache License 2.0
Author : bazelbuild
Copyright Apache License 2.0
Author : bazelbuild
@Test
public void testPackagesAOF_C() throws Exception {
enableDeprecationWarnings();
addOptions("--auto_output_filter=packages");
CommandEnvironment env = runtimeWrapper.newCommand();
env.getReporter().addHandler(stderr);
buildTarget("//java/c");
replacedertNoEvent(deprecationMessages("b", "B", "b"));
replacedertNoEvent(deprecationMessages("c", "C", "c"));
}
18
View Complete Implementation : WorkerModule.java
Copyright Apache License 2.0
Author : bazelbuild
Copyright Apache License 2.0
Author : bazelbuild
@Subscribe
public void cleanStarting(CleanStartingEvent event) {
if (workerPool != null) {
this.options = event.getOptionsProvider().getOptions(WorkerOptions.clreplaced);
workerFactory.setReporter(env.getReporter());
workerFactory.setOptions(options);
shutdownPool("Clean command is running, shutting down worker pool...");
}
}
18
View Complete Implementation : OutputFilterTest.java
Copyright Apache License 2.0
Author : bazelbuild
Copyright Apache License 2.0
Author : bazelbuild
@Test
public void testPackagesAOF_AC() throws Exception {
enableDeprecationWarnings();
addOptions("--auto_output_filter=packages");
CommandEnvironment env = runtimeWrapper.newCommand();
env.getReporter().addHandler(stderr);
buildTarget("//java/a", "//java/c");
replacedertEvent(deprecationMessages("b", "B", "b"));
replacedertNoEvent(deprecationMessages("c", "C", "c"));
}
18
View Complete Implementation : OutputFilterTest.java
Copyright Apache License 2.0
Author : bazelbuild
Copyright Apache License 2.0
Author : bazelbuild
@Test
public void testEmptyFilter() throws Exception {
enableDeprecationWarnings();
addOptions("--output_filter=");
CommandEnvironment env = runtimeWrapper.newCommand();
env.getReporter().addHandler(stderr);
buildTarget("//java/a");
replacedertEvent(deprecationMessages("b", "B", "b"));
replacedertEvent(deprecationMessages("c", "C", "c"));
}
18
View Complete Implementation : SkylarkDebuggerModule.java
Copyright Apache License 2.0
Author : bazelbuild
Copyright Apache License 2.0
Author : bazelbuild
@Override
public void beforeCommand(CommandEnvironment env) {
// Conditionally enable debugging
SkylarkDebuggerOptions buildOptions = env.getOptions().getOptions(SkylarkDebuggerOptions.clreplaced);
boolean enabled = buildOptions != null && buildOptions.debugSkylark;
if (enabled) {
initializeDebugging(env.getReporter(), buildOptions.debugServerPort, buildOptions.verboseLogs);
} else {
disableDebugging();
}
}
18
View Complete Implementation : OutputFilterTest.java
Copyright Apache License 2.0
Author : bazelbuild
Copyright Apache License 2.0
Author : bazelbuild
@Test
public void testStatusCmdPrinted() throws Exception {
addOptions("--auto_output_filter=packages", "--workspace_status_command=" + workspaceScript.getPathString());
CommandEnvironment env = runtimeWrapper.newCommand();
env.getReporter().addHandler(stderr);
buildTarget("//javatests/a", "//java/b");
replacedertEvent("STATUS_CMD_HAS_RUN");
addOptions("--auto_output_filter=subpackages", "--workspace_status_command=" + workspaceScript.getPathString());
env = runtimeWrapper.newCommand();
env.getReporter().addHandler(stderr);
buildTarget("//javatests/a", "//java/b");
replacedertEvent("STATUS_CMD_HAS_RUN");
}
18
View Complete Implementation : OutputFilterTest.java
Copyright Apache License 2.0
Author : bazelbuild
Copyright Apache License 2.0
Author : bazelbuild
@Test
public void testPackagesAOF_A() throws Exception {
enableDeprecationWarnings();
addOptions("--auto_output_filter=packages");
CommandEnvironment env = runtimeWrapper.newCommand();
env.getReporter().addHandler(stderr);
buildTarget("//java/a");
replacedertEvent(deprecationMessages("b", "B", "b"));
replacedertNoEvent(deprecationMessages("c", "C", "c"));
}
18
View Complete Implementation : OutputFilterTest.java
Copyright Apache License 2.0
Author : bazelbuild
Copyright Apache License 2.0
Author : bazelbuild
@Test
public void testPackagesAOF_BC() throws Exception {
enableDeprecationWarnings();
addOptions("--auto_output_filter=packages");
CommandEnvironment env = runtimeWrapper.newCommand();
env.getReporter().addHandler(stderr);
buildTarget("//java/b", "//java/c");
replacedertNoEvent(deprecationMessages("b", "B", "b"));
replacedertEvent(deprecationMessages("c", "C", "c"));
}
18
View Complete Implementation : OutputFilterTest.java
Copyright Apache License 2.0
Author : bazelbuild
Copyright Apache License 2.0
Author : bazelbuild
@Test
public void testExplicitFilterNoJavacoptOverride() throws Exception {
addOptions("--output_filter=^//java/d");
CommandEnvironment env = runtimeWrapper.newCommand();
env.getReporter().addHandler(stderr);
buildTarget("//java/d");
replacedertEvent("D.java:6: warning: [cast] redundant cast to int");
replacedertNoEvent("E.java:6: warning: [cast] redundant cast to int");
}
18
View Complete Implementation : WorkspaceRuleModule.java
Copyright Apache License 2.0
Author : bazelbuild
Copyright Apache License 2.0
Author : bazelbuild
@Override
public void beforeCommand(CommandEnvironment env) {
reporter = env.getReporter();
eventBus = env.getEventBus();
if (env.getOptions() == null || env.getOptions().getOptions(DebuggingOptions.clreplaced) == null) {
reporter.handle(Event.error("Installation is corrupt: could not retrieve debugging options"));
return;
}
PathFragment logFile = env.getOptions().getOptions(DebuggingOptions.clreplaced).workspaceRulesLogFile;
if (logFile != null) {
try {
outFileStream = new AsynchronousFileOutputStream(env.getWorkingDirectory().getRelative(logFile));
} catch (IOException e) {
env.getReporter().handle(Event.error(e.getMessage()));
env.getBlazeModuleEnvironment().exit(new AbruptExitException("Error initializing workspace rule log file.", ExitCode.COMMAND_LINE_ERROR));
}
eventBus.register(this);
}
}
18
View Complete Implementation : OutputFilteringModule.java
Copyright Apache License 2.0
Author : bazelbuild
Copyright Apache License 2.0
Author : bazelbuild
@Subscribe
@SuppressWarnings("unused")
public void buildStarting(BuildStartingEvent event) {
BuildRequestOptions requestOptions = env.getOptions().getOptions(BuildRequestOptions.clreplaced);
Pattern outputFilter = (requestOptions != null) && (requestOptions.outputFilter != null) ? requestOptions.outputFilter.regexPattern() : null;
if (outputFilter != null) {
// Coarse-grained initialization of the output filter. This only has an
// effect if the --output_filter option is given. The auto output filter is
// only initialized later, when we know all targets. For now this is good
// enough, as the target parsing only loads packages that are mentioned on
// the command line (which are included by all auto output filters).
env.getReporter().setOutputFilter(RegexOutputFilter.forPattern(outputFilter));
} else {
this.autoOutputFilter = env.getOptions().getOptions(Options.clreplaced).autoOutputFilter;
}
}
18
View Complete Implementation : OutputFilterTest.java
Copyright Apache License 2.0
Author : bazelbuild
Copyright Apache License 2.0
Author : bazelbuild
@Test
public void testPackagesAOF_D() throws Exception {
addOptions("--auto_output_filter=packages");
CommandEnvironment env = runtimeWrapper.newCommand();
env.getReporter().addHandler(stderr);
buildTarget("//java/d");
replacedertEvent("D.java:6: warning: [cast] redundant cast to int");
replacedertNoEvent("E.java:6: warning: [cast] redundant cast to int");
}
17
View Complete Implementation : SyncCommand.java
Copyright Apache License 2.0
Author : bazelbuild
Copyright Apache License 2.0
Author : bazelbuild
private static void reportError(CommandEnvironment env, EvaluationResult<SkyValue> value) {
if (value.getError().getException() != null) {
env.getReporter().handle(Event.error(value.getError().getException().getMessage()));
} else {
env.getReporter().handle(Event.error(value.getError().toString()));
}
}
17
View Complete Implementation : WorkerModule.java
Copyright Apache License 2.0
Author : bazelbuild
Copyright Apache License 2.0
Author : bazelbuild
/**
* Shuts down the worker pool and sets {#code workerPool} to null.
*/
private void shutdownPool(String reason, boolean alwaysLog) {
Preconditions.checkArgument(!reason.isEmpty());
if (workerPool != null) {
if ((options != null && options.workerVerbose) || alwaysLog) {
env.getReporter().handle(Event.info(reason));
}
workerPool.close();
workerPool = null;
}
}
16
View Complete Implementation : AnalysisPhaseRunner.java
Copyright Apache License 2.0
Author : bazelbuild
Copyright Apache License 2.0
Author : bazelbuild
private static TargetPatternPhaseValue evaluateTargetPatterns(CommandEnvironment env, final BuildRequest request, final TargetValidator validator) throws LoadingFailedException, TargetParsingException, InterruptedException {
boolean keepGoing = request.getKeepGoing();
TargetPatternPhaseValue result = env.getSkyframeExecutor().loadTargetPatternsWithFilters(env.getReporter(), request.getTargets(), env.getRelativeWorkingDirectory(), request.getLoadingOptions(), request.getLoadingPhaseThreadCount(), keepGoing, request.shouldRunTests());
if (validator != null) {
Collection<Target> targets = result.getTargets(env.getReporter(), env.getSkyframeExecutor().getPackageManager());
validator.validateTargets(targets, keepGoing);
}
return result;
}
16
View Complete Implementation : AnalysisPhaseRunner.java
Copyright Apache License 2.0
Author : bazelbuild
Copyright Apache License 2.0
Author : bazelbuild
private static void reportTargets(CommandEnvironment env, replacedysisResult replacedysisResult) {
Collection<ConfiguredTarget> targetsToBuild = replacedysisResult.getTargetsToBuild();
Collection<ConfiguredTarget> targetsToTest = replacedysisResult.getTargetsToTest();
if (targetsToTest != null) {
int testCount = targetsToTest.size();
int targetCount = targetsToBuild.size() - testCount;
if (targetCount == 0) {
env.getReporter().handle(Event.info("Found " + testCount + (testCount == 1 ? " test target..." : " test targets...")));
} else {
env.getReporter().handle(Event.info("Found " + targetCount + (targetCount == 1 ? " target and " : " targets and ") + testCount + (testCount == 1 ? " test target..." : " test targets...")));
}
} else {
int targetCount = targetsToBuild.size();
env.getReporter().handle(Event.info("Found " + targetCount + (targetCount == 1 ? " target..." : " targets...")));
}
}
16
View Complete Implementation : BuildTool.java
Copyright Apache License 2.0
Author : bazelbuild
Copyright Apache License 2.0
Author : bazelbuild
/**
* The crux of the build system. Builds the targets specified in the request using the specified
* Executor.
*
* <p>Performs loading, replacedysis and execution for the specified set of targets, honoring the
* configuration options in the BuildRequest. Returns normally iff successful, throws an exception
* otherwise.
*
* <p>The caller is responsible for setting up and syncing the package cache.
*
* <p>During this function's execution, the actualTargets and successfulTargets
* fields of the request object are set.
*
* @param request the build request that this build tool is servicing, which specifies various
* options; during this method's execution, the actualTargets and successfulTargets fields
* of the request object are populated
* @param validator target validator
* @return the result as a {@link BuildResult} object
*/
public BuildResult processRequest(BuildRequest request, TargetValidator validator) {
BuildResult result = new BuildResult(request.getStartTime());
maybeSetStopOnFirstFailure(request, result);
int startSuspendCount = suspendCount();
Throwable catastrophe = null;
ExitCode exitCode = ExitCode.BLAZE_INTERNAL_ERROR;
try {
buildTargets(request, result, validator);
exitCode = ExitCode.SUCCESS;
} catch (BuildFailedException e) {
if (e.isErrorAlreadyShown()) {
// The actual error has already been reported by the Builder.
} else {
reportExceptionError(e);
}
if (e.isCatastrophic()) {
result.setCatastrophe();
}
exitCode = e.getExitCode() != null ? e.getExitCode() : ExitCode.BUILD_FAILURE;
} catch (InterruptedException e) {
// We may have been interrupted by an error, or the user's interruption may have raced with
// an error, so check to see if we should report that error code instead.
exitCode = env.getPendingExitCode();
if (exitCode == null) {
exitCode = ExitCode.INTERRUPTED;
env.getReporter().handle(Event.error("build interrupted"));
env.getEventBus().post(new BuildInterruptedEvent());
} else {
// Report the exception from the environment - the exception we're handling here is just an
// interruption.
reportExceptionError(env.getPendingException());
result.setCatastrophe();
}
} catch (TargetParsingException | LoadingFailedException | ViewCreationFailedException e) {
exitCode = ExitCode.PARSING_FAILURE;
reportExceptionError(e);
} catch (PostreplacedysisQueryCommandLineException e) {
exitCode = ExitCode.COMMAND_LINE_ERROR;
reportExceptionError(e);
} catch (TestExecException e) {
// ExitCode.SUCCESS means that build was successful. Real return code of program
// is going to be calculated in TestCommand.doTest().
exitCode = ExitCode.SUCCESS;
reportExceptionError(e);
} catch (InvalidConfigurationException e) {
exitCode = ExitCode.COMMAND_LINE_ERROR;
reportExceptionError(e);
// TODO(gregce): With "global configurations" we cannot tie a configuration creation failure
// to a single target and have to halt the entire build. Once configurations are genuinely
// created as part of the replacedysis phase they should report their error on the level of the
// target(s) that triggered them.
result.setCatastrophe();
} catch (AbruptExitException e) {
exitCode = e.getExitCode();
reportExceptionError(e);
result.setCatastrophe();
} catch (Throwable throwable) {
catastrophe = throwable;
Throwables.propagate(throwable);
} finally {
stopRequest(result, catastrophe, exitCode, startSuspendCount);
}
return result;
}
16
View Complete Implementation : BuildTool.java
Copyright Apache License 2.0
Author : bazelbuild
Copyright Apache License 2.0
Author : bazelbuild
/**
* Stops processing the specified request.
*
* <p>This logs the build result, cleans up and stops the clock.
*
* @param result result to update
* @param crash any unexpected {@link RuntimeException} or {@link Error}. May be null
* @param exitCondition a suggested exit condition from either the build logic or a thrown
* exception somewhere along the way
* @param startSuspendCount number of suspensions before the build started
*/
public void stopRequest(BuildResult result, Throwable crash, ExitCode exitCondition, int startSuspendCount) {
Preconditions.checkState((crash == null) || !exitCondition.equals(ExitCode.SUCCESS));
int stopSuspendCount = suspendCount();
Preconditions.checkState(startSuspendCount <= stopSuspendCount);
result.setUnhandledThrowable(crash);
result.setExitCondition(exitCondition);
InterruptedException ie = null;
try {
env.getSkyframeExecutor().notifyCommandComplete(env.getReporter());
} catch (InterruptedException e) {
env.getReporter().handle(Event.error("Build interrupted during command completion"));
ie = e;
}
// The stop time has to be captured before we send the BuildCompleteEvent.
result.setStopTime(runtime.getClock().currentTimeMillis());
result.setWreplaceduspended(stopSuspendCount > startSuspendCount);
env.getEventBus().post(new BuildPrecompleteEvent());
env.getEventBus().post(new BuildCompleteEvent(result, ImmutableList.of(BuildEventId.buildToolLogs(), BuildEventId.buildMetrics())));
// Post the build tool logs event; the corresponding local files may be contributed from
// modules, and this has to happen after posting the BuildCompleteEvent because that's when
// modules add their data to the collection.
env.getEventBus().post(result.getBuildToolLogCollection().freeze().toEvent());
if (ie != null) {
if (exitCondition.equals(ExitCode.SUCCESS)) {
result.setExitCondition(ExitCode.INTERRUPTED);
} else if (!exitCondition.equals(ExitCode.INTERRUPTED)) {
logger.log(Level.WARNING, "Suppressed interrupted exception during stop request because already failing with exit" + " code " + exitCondition, ie);
}
}
}
16
View Complete Implementation : CleanCommand.java
Copyright Apache License 2.0
Author : bazelbuild
Copyright Apache License 2.0
Author : bazelbuild
private static void asyncClean(CommandEnvironment env, Path path, String pathItemName) throws IOException, CommandException {
String tempBaseName = path.getBaseName() + "_tmp_" + ProcessUtils.getpid();
// Keeping tempOutputBase in the same directory ensures it remains in the
// same file system, and therefore the mv will be atomic and fast.
Path tempPath = path.getParentDirectory().getChild(tempBaseName);
path.renameTo(tempPath);
env.getReporter().handle(Event.info(null, pathItemName + " moved to " + tempPath + " for deletion"));
// Daemonize the shell and use the double-fork idiom to ensure that the shell
// exits even while the "rm -rf" command continues.
String command = String.format("exec >&- 2>&- <&- && (/usr/bin/setsid /bin/rm -rf %s &)&", ShellEscaper.escapeString(tempPath.getPathString()));
logger.info("Executing shell command " + ShellEscaper.escapeString(command));
// Doesn't throw iff command exited and was successful.
new CommandBuilder().addArg(command).useShell(true).setWorkingDir(tempPath.getParentDirectory()).build().execute();
}
16
View Complete Implementation : DumpCommand.java
Copyright Apache License 2.0
Author : bazelbuild
Copyright Apache License 2.0
Author : bazelbuild
private boolean dumpActionCache(CommandEnvironment env, PrintStream out) {
try {
env.getPersistentActionCache().dump(out);
} catch (IOException e) {
env.getReporter().handle(Event.error("Cannot dump action cache: " + e.getMessage()));
return false;
}
return true;
}
15
View Complete Implementation : SpawnLogModule.java
Copyright Apache License 2.0
Author : bazelbuild
Copyright Apache License 2.0
Author : bazelbuild
@Override
public void afterCommand() throws AbruptExitException {
boolean done = false;
if (spawnLogContext != null) {
try {
spawnLogContext.close();
if (!outputStreams.isEmpty()) {
InputStream in = rawOutput.getInputStream();
StableSort.stableSort(in, outputStreams);
outputStreams.close();
}
done = true;
} catch (IOException e) {
throw new AbruptExitException(ExitCode.LOCAL_ENVIRONMENTAL_ERROR, e);
} finally {
if (!done && !outputStreams.isEmpty()) {
env.getReporter().handle(Event.warn("Execution log might not have been populated. Raw execution log is at " + rawOutput));
}
clear();
}
}
}
15
View Complete Implementation : RunCommand.java
Copyright Apache License 2.0
Author : bazelbuild
Copyright Apache License 2.0
Author : bazelbuild
private boolean prepareTestEnvironment(CommandEnvironment env, TestRunnerAction action) {
try {
action.prepare(env.getExecRoot());
return true;
} catch (IOException e) {
env.getReporter().handle(Event.error("Error while setting up test: " + e.getMessage()));
return false;
}
}
14
View Complete Implementation : SpawnLogModule.java
Copyright Apache License 2.0
Author : bazelbuild
Copyright Apache License 2.0
Author : bazelbuild
@Override
public void executorInit(CommandEnvironment env, BuildRequest request, ExecutorBuilder builder) {
env.getEventBus().register(this);
try {
initOutputs(env);
} catch (IOException e) {
env.getReporter().handle(Event.error(e.getMessage()));
env.getBlazeModuleEnvironment().exit(new AbruptExitException("Error initializing execution log", ExitCode.COMMAND_LINE_ERROR, e));
}
if (spawnLogContext != null) {
// TODO(schmitt): Pretty sure the "spawn-log" commandline identifier is never used as there is
// no other SpawnLogContext to distinguish from.
builder.addActionContext(SpawnLogContext.clreplaced, spawnLogContext, "spawn-log");
builder.addStrategyByContext(SpawnLogContext.clreplaced, "");
}
}
14
View Complete Implementation : RunCommand.java
Copyright Apache License 2.0
Author : bazelbuild
Copyright Apache License 2.0
Author : bazelbuild
// productionVisibility = Visibility.PRIVATE
@VisibleForTesting
protected BuildResult processRequest(final CommandEnvironment env, BuildRequest request) {
List<String> targetPatternStrings = request.getTargets();
return new BuildTool(env).processRequest(request, (Collection<Target> targets, boolean keepGoing) -> RunCommand.this.validateTargets(env.getReporter(), targetPatternStrings, targets, keepGoing));
}
14
View Complete Implementation : SandboxModule.java
Copyright Apache License 2.0
Author : bazelbuild
Copyright Apache License 2.0
Author : bazelbuild
@Override
public void afterCommand() {
checkNotNull(env, "env not initialized; was beforeCommand called?");
SandboxOptions options = env.getOptions().getOptions(SandboxOptions.clreplaced);
int asyncTreeDeleteThreads = options != null ? options.asyncTreeDeleteIdleThreads : 0;
if (treeDeleter != null && asyncTreeDeleteThreads > 0) {
// If asynchronous deletions were requested, they may still be ongoing so let them be: trying
// to delete the base tree synchronously could fail as we can race with those other deletions,
// and scheduling an asynchronous deletion could race with future builds.
AsynchronousTreeDeleter treeDeleter = (AsynchronousTreeDeleter) checkNotNull(this.treeDeleter);
treeDeleter.setThreads(asyncTreeDeleteThreads);
}
if (shouldCleanupSandboxBase) {
try {
checkNotNull(sandboxBase, "shouldCleanupSandboxBase implies sandboxBase has been set");
for (SpawnRunner spawnRunner : spawnRunners) {
spawnRunner.cleanupSandboxBase(sandboxBase, treeDeleter);
}
} catch (IOException e) {
env.getReporter().handle(Event.warn("Failed to delete contents of sandbox " + sandboxBase + ": " + e));
}
shouldCleanupSandboxBase = false;
checkState(sandboxfsProcess == null, "sandboxfs instance should have been shut down at this " + "point; were the buildComplete/buildInterrupted events sent?");
sandboxBase = null;
}
env.getEventBus().unregister(this);
env = null;
}
13
View Complete Implementation : QueryEnvironmentBasedCommand.java
Copyright Apache License 2.0
Author : bazelbuild
Copyright Apache License 2.0
Author : bazelbuild
public static AbstractBlazeQueryEnvironment<Target> newQueryEnvironment(CommandEnvironment env, boolean keepGoing, boolean orderedResults, List<String> universeScope, int loadingPhaseThreads, Set<Setting> settings, boolean useGraphlessQuery) {
WalkableGraph walkableGraph = SkyframeExecutorWrappingWalkableGraph.of(env.getSkyframeExecutor());
TargetProviderForQueryEnvironment targetProviderForQueryEnvironment = new TargetProviderForQueryEnvironment(walkableGraph, env.getPackageManager());
PackageProgressReceiver progressReceiver = env.getSkyframeExecutor().getPackageProgressReceiver();
if (progressReceiver != null) {
progressReceiver.reset();
env.getReporter().post(new LoadingPhaseStartedEvent(progressReceiver));
}
return env.getRuntime().getQueryEnvironmentFactory().create(env.getPackageManager().newTransitiveLoader(), env.getSkyframeExecutor(), targetProviderForQueryEnvironment, env.getPackageManager(), env.getPackageManager().newTargetPatternPreloader(), env.getRelativeWorkingDirectory(), keepGoing, /*strictScope=*/
true, orderedResults, universeScope, loadingPhaseThreads, /*labelFilter=*/
ALL_LABELS, env.getReporter(), settings, env.getRuntime().getQueryFunctions(), env.getPackageManager().getPackagePath(), /*blockUniverseEvaluationErrors=*/
false, useGraphlessQuery);
}
13
View Complete Implementation : RunCommand.java
Copyright Apache License 2.0
Author : bazelbuild
Copyright Apache License 2.0
Author : bazelbuild
private boolean writeScript(CommandEnvironment env, PathFragment shellExecutable, PathFragment scriptPathFrag, String cmd) {
Path scriptPath = env.getWorkingDirectory().getRelative(scriptPathFrag);
try {
if (OS.getCurrent() == OS.WINDOWS) {
FileSystemUtils.writeContent(scriptPath, StandardCharsets.ISO_8859_1, "@echo off\n" + cmd + " %*");
scriptPath.setExecutable(true);
} else {
FileSystemUtils.writeContent(scriptPath, StandardCharsets.ISO_8859_1, "#!" + shellExecutable.getPathString() + "\n" + cmd + " \"$@\"");
scriptPath.setExecutable(true);
}
} catch (IOException e) {
env.getReporter().handle(Event.error("Error writing run script:" + e.getMessage()));
return false;
}
return true;
}
13
View Complete Implementation : TestCommand.java
Copyright Apache License 2.0
Author : bazelbuild
Copyright Apache License 2.0
Author : bazelbuild
@Override
public BlazeCommandResult exec(CommandEnvironment env, OptionsParsingResult options) {
TestOutputFormat testOutput = options.getOptions(ExecutionOptions.clreplaced).testOutput;
if (testOutput == TestStrategy.TestOutputFormat.STREAMED) {
env.getReporter().handle(Event.warn("Streamed test output requested. All tests will be run locally, without sharding, " + "one at a time"));
}
AnsiTerminalPrinter printer = new AnsiTerminalPrinter(env.getReporter().getOutErr().getOutputStream(), options.getOptions(UiOptions.clreplaced).useColor());
// Initialize test handler.
AggregatingTestListener testListener = new AggregatingTestListener(options.getOptions(TestSummaryOptions.clreplaced), options.getOptions(ExecutionOptions.clreplaced), env.getEventBus());
env.getEventBus().register(testListener);
return doTest(env, options, testListener, printer);
}
13
View Complete Implementation : DockerSandboxedSpawnRunner.java
Copyright Apache License 2.0
Author : bazelbuild
Copyright Apache License 2.0
Author : bazelbuild
/**
* Returns whether the darwin sandbox is supported on the local machine by running docker info.
* This is expensive, and we have also reports of docker hanging for a long time!
*/
public static boolean isSupported(CommandEnvironment cmdEnv, Path dockerClient) {
boolean verbose = cmdEnv.getOptions().getOptions(SandboxOptions.clreplaced).dockerVerbose;
if (!ProcessWrapperUtil.isSupported(cmdEnv)) {
if (verbose) {
cmdEnv.getReporter().handle(Event.error("Docker sandboxing is disabled, because ProcessWrapperUtil.isSupported " + "returned false. This should never happen - is your Bazel binary " + "corrupted?"));
}
return false;
}
// On Linux we need to know the UID and GID that we're running as, because otherwise Docker will
// create files as 'root' and we can't move them to the execRoot.
if (OS.getCurrent() == OS.LINUX) {
try {
ProcessUtils.getuid();
ProcessUtils.getgid();
} catch (UnsatisfiedLinkError e) {
if (verbose) {
cmdEnv.getReporter().handle(Event.error("Docker sandboxing is disabled, because ProcessUtils.getuid/getgid threw an " + "UnsatisfiedLinkError. This means that you're running a Bazel version " + "that doesn't have JNI libraries - did you build it correctly?\n" + Throwables.getStackTracereplacedtring(e)));
}
return false;
}
}
Command cmd = new Command(new String[] { dockerClient.getPathString(), "info" }, cmdEnv.getClientEnv(), cmdEnv.getExecRoot().getPathFile());
try {
cmd.execute(ByteStreams.nullOutputStream(), ByteStreams.nullOutputStream());
} catch (CommandException e) {
if (verbose) {
cmdEnv.getReporter().handle(Event.error("Docker sandboxing is disabled, because running 'docker info' failed: " + Throwables.getStackTracereplacedtring(e)));
}
return false;
}
if (verbose) {
cmdEnv.getReporter().handle(Event.info("Docker sandboxing is supported"));
}
return true;
}
12
View Complete Implementation : CleanCommand.java
Copyright Apache License 2.0
Author : bazelbuild
Copyright Apache License 2.0
Author : bazelbuild
@Override
public BlazeCommandResult exec(CommandEnvironment env, OptionsParsingResult options) {
Options cleanOptions = options.getOptions(Options.clreplaced);
boolean async = cleanOptions.async;
env.getEventBus().post(new NoBuildEvent());
// TODO(dmarting): Deactivate expunge_async on non-Linux platform until we completely fix it
// for non-Linux platforms (https://github.com/bazelbuild/bazel/issues/1906).
// MacOS and FreeBSD support setsid(2) but don't have /usr/bin/setsid, so if we wanted to
// support --expunge_async on these platforms, we'd have to write a wrapper that calls setsid(2)
// and exec(2).
boolean asyncSupport = os == OS.LINUX;
if (async && !asyncSupport) {
String fallbackName = cleanOptions.expunge ? "--expunge" : "synchronous clean";
env.getReporter().handle(Event.info(null, /*location*/
"--async cannot be used on non-Linux platforms, falling back to " + fallbackName));
async = false;
}
String cleanBanner = (async || !asyncSupport) ? "Starting clean." : "Starting clean (this may take a while). " + "Consider using --async if the clean takes more than several minutes.";
env.getEventBus().post(new CleanStartingEvent(options));
env.getReporter().handle(Event.info(null, /*location*/
cleanBanner));
try {
String symlinkPrefix = options.getOptions(BuildRequestOptions.clreplaced).getSymlinkPrefix(env.getRuntime().getProductName());
return actuallyClean(env, env.getOutputBase(), cleanOptions.expunge, async, symlinkPrefix);
} catch (IOException e) {
env.getReporter().handle(Event.error(e.getMessage()));
return BlazeCommandResult.exitCode(ExitCode.LOCAL_ENVIRONMENTAL_ERROR);
} catch (CommandException | ExecException e) {
env.getReporter().handle(Event.error(e.getMessage()));
return BlazeCommandResult.exitCode(ExitCode.RUN_FAILURE);
} catch (InterruptedException e) {
env.getReporter().handle(Event.error("clean interrupted"));
return BlazeCommandResult.exitCode(ExitCode.INTERRUPTED);
}
}
12
View Complete Implementation : WorkerModule.java
Copyright Apache License 2.0
Author : bazelbuild
Copyright Apache License 2.0
Author : bazelbuild
@Subscribe
public void buildStarting(BuildStartingEvent event) {
options = event.getRequest().getOptions(WorkerOptions.clreplaced);
if (workerFactory == null) {
Path workerDir = env.getOutputBase().getRelative(env.getRuntime().getProductName() + "-workers");
try {
if (!workerDir.createDirectory()) {
// Clean out old log files.
for (Path logFile : workerDir.getDirectoryEntries()) {
if (logFile.getBaseName().endsWith(".log")) {
try {
logFile.delete();
} catch (IOException e) {
env.getReporter().handle(Event.error("Could not delete old worker log: " + logFile));
}
}
}
}
} catch (IOException e) {
env.getReporter().handle(Event.error("Could not create base directory for workers: " + workerDir));
}
workerFactory = new WorkerFactory(options, workerDir);
}
workerFactory.setReporter(env.getReporter());
workerFactory.setOptions(options);
// Use a LinkedHashMap instead of an ImmutableMap.Builder to allow duplicates; the last value
// preplaceded wins.
LinkedHashMap<String, Integer> newConfigBuilder = new LinkedHashMap<>();
for (Map.Entry<String, Integer> entry : options.workerMaxInstances) {
newConfigBuilder.put(entry.getKey(), entry.getValue());
}
if (!newConfigBuilder.containsKey("")) {
// Empty string gives the number of workers for any type of worker not explicitly specified.
// If no value is given, use the default, 4.
// TODO(steinman): Calculate a reasonable default value instead of arbitrarily defaulting to
// 4.
newConfigBuilder.put("", MultiResourceConverter.DEFAULT_VALUE);
}
ImmutableMap<String, Integer> newConfig = ImmutableMap.copyOf(newConfigBuilder);
// If the config changed compared to the last run, we have to create a new pool.
if (workerPoolConfig != null && !workerPoolConfig.equals(newConfig)) {
shutdownPool("Worker configuration has changed, restarting worker pool...", /* alwaysLog= */
true);
}
if (workerPool == null) {
workerPoolConfig = newConfig;
workerPool = new WorkerPool(workerFactory, workerPoolConfig, options.highPriorityWorkers);
}
}
10
View Complete Implementation : BuildTool.java
Copyright Apache License 2.0
Author : bazelbuild
Copyright Apache License 2.0
Author : bazelbuild
/**
* The crux of the build system: builds the targets specified in the request.
*
* <p>Performs loading, replacedysis and execution for the specified set of targets, honoring the
* configuration options in the BuildRequest. Returns normally iff successful, throws an exception
* otherwise.
*
* <p>Callers must ensure that {@link #stopRequest} is called after this method, even if it
* throws.
*
* <p>The caller is responsible for setting up and syncing the package cache.
*
* <p>During this function's execution, the actualTargets and successfulTargets fields of the
* request object are set.
*
* @param request the build request that this build tool is servicing, which specifies various
* options; during this method's execution, the actualTargets and successfulTargets fields of
* the request object are populated
* @param result the build result that is the mutable result of this build
* @param validator target validator
*/
public void buildTargets(BuildRequest request, BuildResult result, TargetValidator validator) throws BuildFailedException, InterruptedException, ViewCreationFailedException, TargetParsingException, LoadingFailedException, AbruptExitException, InvalidConfigurationException, TestExecException, PostreplacedysisQueryCommandLineException {
try (SilentCloseable c = Profiler.instance().profile("validateOptions")) {
validateOptions(request);
}
BuildOptions buildOptions;
try (SilentCloseable c = Profiler.instance().profile("createBuildOptions")) {
buildOptions = runtime.createBuildOptions(request);
}
ExecutionTool executionTool = null;
boolean catastrophe = false;
try {
try (SilentCloseable c = Profiler.instance().profile("BuildStartingEvent")) {
env.getEventBus().post(new BuildStartingEvent(env, request));
}
logger.info("Build identifier: " + request.getId());
// Error out early if multi_cpus is set, but we're not in build or test command.
if (!request.getMultiCpus().isEmpty()) {
getReporter().handle(Event.warn("The --experimental_multi_cpu option is _very_ experimental and only intended for " + "internal testing at this time. If you do not work on the build tool, then you " + "should stop now!"));
if (!"build".equals(request.getCommandName()) && !"test".equals(request.getCommandName())) {
throw new InvalidConfigurationException("The experimental setting to select multiple CPUs is only supported for 'build' and " + "'test' right now!");
}
}
// Exit if there are any pending exceptions from modules.
env.throwPendingException();
initializeOutputFilter(request);
replacedysisResult replacedysisResult = replacedysisPhaseRunner.execute(env, request, buildOptions, validator);
// We cannot move the executionTool down to the execution phase part since it does set up the
// symlinks for tools.
// TODO(twerth): Extract embedded tool setup from execution tool and move object creation to
// execution phase.
executionTool = new ExecutionTool(env, request);
if (request.getBuildOptions().performreplacedysisPhase) {
result.setBuildConfigurationCollection(replacedysisResult.getConfigurationCollection());
result.setActualTargets(replacedysisResult.getTargetsToBuild());
result.setTestTargets(replacedysisResult.getTargetsToTest());
try (SilentCloseable c = Profiler.instance().profile("postProcessreplacedysisResult")) {
postProcessreplacedysisResult(request, replacedysisResult);
}
// Execution phase.
if (needsExecutionPhase(request.getBuildOptions())) {
try (SilentCloseable closeable = Profiler.instance().profile("ExecutionTool.init")) {
executionTool.init();
}
executionTool.executeBuild(request.getId(), replacedysisResult, result, replacedysisResult.getPackageRoots(), request.getTopLevelArtifactContext());
} else {
env.getReporter().post(new NoExecutionEvent());
}
String delayedErrorMsg = replacedysisResult.getError();
if (delayedErrorMsg != null) {
throw new BuildFailedException(delayedErrorMsg);
}
}
Profiler.instance().markPhase(ProfilePhase.FINISH);
} catch (Error | RuntimeException e) {
request.getOutErr().printErrLn("Internal error thrown during build. Printing stack trace: " + Throwables.getStackTracereplacedtring(e));
catastrophe = true;
throw e;
} finally {
if (executionTool != null) {
executionTool.shutdown();
}
if (!catastrophe) {
// Delete dirty nodes to ensure that they do not acreplacedulate indefinitely.
long versionWindow = request.getViewOptions().versionWindowForDirtyNodeGc;
if (versionWindow != -1) {
env.getSkyframeExecutor().deleteOldNodes(versionWindow);
}
// The workspace status actions will not run with certain flags, or if an error
// occurs early in the build. Tell a lie so that the event is not missing.
// If multiple build_info events are sent, only the first is kept, so this does not harm
// successful runs (which use the workspace status action).
env.getEventBus().post(new BuildInfoEvent(env.getBlazeWorkspace().getWorkspaceStatusActionFactory().createDummyWorkspaceStatus(new DummyEnvironment() {
@Override
public Path getWorkspace() {
return env.getWorkspace();
}
@Override
public String getBuildRequestId() {
return env.getBuildRequestId();
}
@Override
public OptionsProvider getOptions() {
return env.getOptions();
}
})));
}
}
}
10
View Complete Implementation : ExecutionTool.java
Copyright Apache License 2.0
Author : bazelbuild
Copyright Apache License 2.0
Author : bazelbuild
/**
* Creates convenience symlinks based on the target configurations.
*
* <p>Exactly what target configurations we consider depends on the value of {@code
* --use_top_level_targets_for_symlinks}. If this flag is false, we use the top-level target
* configuration as represented by the command line prior to processing any target. If the flag is
* true, we instead use the configurations OF the top-level targets -- meaning that we account for
* the effects of any rule transitions these targets may have.
*
* <p>For each type of convenience symlink, if all the considered configurations agree on what
* path the symlink should point to, it gets created; otherwise, the symlink is not created, and
* in fact gets removed if it was already present from a previous invocation.
*/
private ImmutableList<ConvenienceSymlink> createConvenienceSymlinks(BuildRequestOptions buildRequestOptions, replacedysisResult replacedysisResult) {
SkyframeExecutor executor = env.getSkyframeExecutor();
Reporter reporter = env.getReporter();
// Gather configurations to consider.
Set<BuildConfiguration> targetConfigurations = buildRequestOptions.useTopLevelTargetsForSymlinks() ? replacedysisResult.getTargetsToBuild().stream().map(ConfiguredTarget::getConfigurationKey).filter(configuration -> configuration != null).distinct().map((key) -> executor.getConfiguration(reporter, key)).collect(toImmutableSet()) : ImmutableSet.copyOf(replacedysisResult.getConfigurationCollection().getTargetConfigurations());
String productName = runtime.getProductName();
try (SilentCloseable c = Profiler.instance().profile("OutputDirectoryLinksUtils.createOutputDirectoryLinks")) {
return OutputDirectoryLinksUtils.createOutputDirectoryLinks(runtime.getRuleClreplacedProvider().getSymlinkDefinitions(), buildRequestOptions, env.getWorkspaceName(), env.getWorkspace(), env.getDirectories(), getReporter(), targetConfigurations, options -> getConfiguration(executor, reporter, options), productName);
}
}