diff options
author | 2017-09-11 14:07:15 +0200 | |
---|---|---|
committer | 2017-09-12 14:03:26 +0200 | |
commit | 91e32895ae19f7f87cdde0e1e84e3d6032ee9e85 (patch) | |
tree | 6344a27d97d9686e08a7ba419e93464dc978a61b /src/main/java/com | |
parent | c2762023ee171cb49b89557d0ab29e0b3950fadb (diff) |
Automated rollback of commit 70f84252a0f1669564ef3c92c4adeda9b5a22f50.
*** Reason for rollback ***
Introduced a UI regression.
See #3534.
*** Original change description ***
Avoid relying on System.out/err going to the terminal
Use an appropriate EventHandler instead.
PiperOrigin-RevId: 168218216
Diffstat (limited to 'src/main/java/com')
3 files changed, 34 insertions, 37 deletions
diff --git a/src/main/java/com/google/devtools/build/lib/bazel/repository/skylark/SkylarkExecutionResult.java b/src/main/java/com/google/devtools/build/lib/bazel/repository/skylark/SkylarkExecutionResult.java index d7aff9d625..fba2c1ec9f 100644 --- a/src/main/java/com/google/devtools/build/lib/bazel/repository/skylark/SkylarkExecutionResult.java +++ b/src/main/java/com/google/devtools/build/lib/bazel/repository/skylark/SkylarkExecutionResult.java @@ -107,7 +107,7 @@ final class SkylarkExecutionResult { private final Map<String, String> envBuilder = Maps.newLinkedHashMap(); private long timeout = -1; private boolean executed = false; - private OutErr outErr; + private boolean quiet; private Builder(Map<String, String> environment) { envBuilder.putAll(environment); @@ -162,8 +162,8 @@ final class SkylarkExecutionResult { return this; } - Builder setOutErr(OutErr outErr) { - this.outErr = outErr; + Builder setQuiet(boolean quiet) { + this.quiet = quiet; return this; } @@ -183,8 +183,8 @@ final class SkylarkExecutionResult { // Bazel will crash. Maybe we should use custom output streams that throw an appropriate // exception when reaching a specific size. delegator.addSink(recorder); - if (outErr != null) { - delegator.addSink(outErr); + if (!quiet) { + delegator.addSink(OutErr.create(System.out, System.err)); } try { String[] argsArray = new String[args.size()]; diff --git a/src/main/java/com/google/devtools/build/lib/bazel/repository/skylark/SkylarkRepositoryContext.java b/src/main/java/com/google/devtools/build/lib/bazel/repository/skylark/SkylarkRepositoryContext.java index de78271c3a..df777f20ae 100644 --- a/src/main/java/com/google/devtools/build/lib/bazel/repository/skylark/SkylarkRepositoryContext.java +++ b/src/main/java/com/google/devtools/build/lib/bazel/repository/skylark/SkylarkRepositoryContext.java @@ -25,7 +25,6 @@ import com.google.devtools.build.lib.bazel.repository.downloader.HttpDownloader; import com.google.devtools.build.lib.bazel.repository.downloader.HttpUtils; import com.google.devtools.build.lib.cmdline.Label; import com.google.devtools.build.lib.events.Location; -import com.google.devtools.build.lib.events.Reporter; import com.google.devtools.build.lib.packages.Attribute; import com.google.devtools.build.lib.packages.Info; import com.google.devtools.build.lib.packages.NativeProvider; @@ -407,7 +406,7 @@ public class SkylarkRepositoryContext { .setDirectory(outputDirectory.getPathFile()) .addEnvironmentVariables(environment) .setTimeout(timeout.longValue() * 1000) - .setOutErr(quiet ? null : Reporter.outErrForReporter(env.getListener())) + .setQuiet(quiet) .execute(); } diff --git a/src/main/java/com/google/devtools/build/lib/rules/cpp/CppCompileAction.java b/src/main/java/com/google/devtools/build/lib/rules/cpp/CppCompileAction.java index a8d3a38bbb..5a084f284a 100644 --- a/src/main/java/com/google/devtools/build/lib/rules/cpp/CppCompileAction.java +++ b/src/main/java/com/google/devtools/build/lib/rules/cpp/CppCompileAction.java @@ -65,8 +65,6 @@ import com.google.devtools.build.skyframe.SkyFunction; import com.google.devtools.build.skyframe.SkyKey; import com.google.devtools.build.skyframe.SkyValue; import java.io.IOException; -import java.io.PrintWriter; -import java.io.StringWriter; import java.util.ArrayList; import java.util.Collection; import java.util.Collections; @@ -876,40 +874,40 @@ public class CppCompileAction extends AbstractAction } } if (VALIDATION_DEBUG_WARN) { - if (VALIDATION_DEBUG >= 2 || errors.hasProblems() || warnings.hasProblems()) { - StringWriter buffer = new StringWriter(); - PrintWriter out = new PrintWriter(buffer); - if (errors.hasProblems()) { - out.println("ERROR: Include(s) were not in declared srcs:"); - } else if (warnings.hasProblems()) { - out.println("WARN: Include(s) were not in declared srcs:"); - } else { - out.println("INFO: Include(s) were OK for '" + getSourceFile() - + "', declared srcs:"); - } - for (Artifact a : context.getDeclaredIncludeSrcs()) { - out.println(" '" + a.toDetailString() + "'"); - } - out.println(" or under declared dirs:"); - for (PathFragment f : Sets.newTreeSet(context.getDeclaredIncludeDirs())) { - out.println(" '" + f + "'"); - } - out.println(" or under declared warn dirs:"); - for (PathFragment f : Sets.newTreeSet(context.getDeclaredIncludeWarnDirs())) { - out.println(" '" + f + "'"); - } - out.println(" with prefixes:"); - for (PathFragment dirpath : context.getQuoteIncludeDirs()) { - out.println(" '" + dirpath + "'"); + synchronized (System.err) { + if (VALIDATION_DEBUG >= 2 || errors.hasProblems() || warnings.hasProblems()) { + if (errors.hasProblems()) { + System.err.println("ERROR: Include(s) were not in declared srcs:"); + } else if (warnings.hasProblems()) { + System.err.println("WARN: Include(s) were not in declared srcs:"); + } else { + System.err.println("INFO: Include(s) were OK for '" + getSourceFile() + + "', declared srcs:"); + } + for (Artifact a : context.getDeclaredIncludeSrcs()) { + System.err.println(" '" + a.toDetailString() + "'"); + } + System.err.println(" or under declared dirs:"); + for (PathFragment f : Sets.newTreeSet(context.getDeclaredIncludeDirs())) { + System.err.println(" '" + f + "'"); + } + System.err.println(" or under declared warn dirs:"); + for (PathFragment f : Sets.newTreeSet(context.getDeclaredIncludeWarnDirs())) { + System.err.println(" '" + f + "'"); + } + System.err.println(" with prefixes:"); + for (PathFragment dirpath : context.getQuoteIncludeDirs()) { + System.err.println(" '" + dirpath + "'"); + } } - eventHandler.handle( - Event.warn(buffer.toString()).withTag(Label.print(getOwner().getLabel()))); } } if (warnings.hasProblems()) { eventHandler.handle( - Event.warn(getOwner().getLocation(), warnings.getMessage(this, getSourceFile())) + Event.warn( + getOwner().getLocation(), + warnings.getMessage(this, getSourceFile())) .withTag(Label.print(getOwner().getLabel()))); } errors.assertProblemFree(this, getSourceFile()); |