diff options
author | Michajlo Matijkiw <michajlo@google.com> | 2016-09-16 15:44:35 +0000 |
---|---|---|
committer | Laszlo Csomor <laszlocsomor@google.com> | 2016-09-19 07:34:41 +0000 |
commit | af79a3255157076962d127a6e61f1bebc7b85939 (patch) | |
tree | c463a7596b7fad97236529eac51cc8b0f268bb47 /src | |
parent | 5deab1e63b5d526d9851b15ac9f7484c751496ea (diff) |
Allow configuring writing of command.log
Sometimes, especially in the case of a lot of output, one may not want to write
everything twice.
--
MOS_MIGRATED_REVID=133388416
Diffstat (limited to 'src')
6 files changed, 35 insertions, 10 deletions
diff --git a/src/main/cpp/blaze.cc b/src/main/cpp/blaze.cc index e57efe8ea9..493d367ee4 100644 --- a/src/main/cpp/blaze.cc +++ b/src/main/cpp/blaze.cc @@ -517,6 +517,10 @@ static vector<string> GetArgumentArray() { result.push_back("--experimental_oom_more_eagerly_threshold=" + ToString(globals->options->oom_more_eagerly_threshold)); + if (!globals->options->write_command_log) { + result.push_back("--nowrite_command_log"); + } + if (globals->options->watchfs) { result.push_back("--watchfs"); } diff --git a/src/main/cpp/startup_options.cc b/src/main/cpp/startup_options.cc index 5d3e9f4118..09b8eab33e 100644 --- a/src/main/cpp/startup_options.cc +++ b/src/main/cpp/startup_options.cc @@ -73,6 +73,7 @@ void StartupOptions::Init() { oom_more_eagerly_threshold = 100; command_port = 0; oom_more_eagerly = false; + write_command_log = true; watchfs = false; invocation_policy = NULL; } @@ -215,6 +216,12 @@ blaze_exit_code::ExitCode StartupOptions::ProcessArg( return blaze_exit_code::BAD_ARGV; } option_sources["experimental_oom_more_eagerly_threshold"] = rcfile; + } else if (GetNullaryOption(arg, "--write_command_log")) { + write_command_log = true; + option_sources["write_command_log"] = rcfile; + } else if (GetNullaryOption(arg, "--nowrite_command_log")) { + write_command_log = false; + option_sources["write_command_log"] = rcfile; } else if (GetNullaryOption(arg, "--watchfs")) { watchfs = true; option_sources["watchfs"] = rcfile; diff --git a/src/main/cpp/startup_options.h b/src/main/cpp/startup_options.h index cc77f2e376..523523a32c 100644 --- a/src/main/cpp/startup_options.h +++ b/src/main/cpp/startup_options.h @@ -166,6 +166,8 @@ class StartupOptions { int oom_more_eagerly_threshold; + bool write_command_log; + // If true, Blaze will listen to OS-level file change notifications. bool watchfs; diff --git a/src/main/java/com/google/devtools/build/lib/runtime/BlazeCommandDispatcher.java b/src/main/java/com/google/devtools/build/lib/runtime/BlazeCommandDispatcher.java index 3ab483ad84..2e363c382a 100644 --- a/src/main/java/com/google/devtools/build/lib/runtime/BlazeCommandDispatcher.java +++ b/src/main/java/com/google/devtools/build/lib/runtime/BlazeCommandDispatcher.java @@ -368,18 +368,20 @@ public class BlazeCommandDispatcher { return exitCausingException.getExitCode().getNumericExitCode(); } - try { - Path commandLog = getCommandLogPath(env.getOutputBase()); + if (env.getRuntime().writeCommandLog()) { + try { + Path commandLog = getCommandLogPath(env.getOutputBase()); - // Unlink old command log from previous build, if present, so scripts - // reading it don't conflate it with the command log we're about to write. - commandLog.delete(); + // Unlink old command log from previous build, if present, so scripts + // reading it don't conflate it with the command log we're about to write. + commandLog.delete(); - logOutputStream = commandLog.getOutputStream(); - outErr = tee(outErr, OutErr.create(logOutputStream, logOutputStream)); - } catch (IOException ioException) { - LoggingUtil.logToRemote( - Level.WARNING, "Unable to delete or open command.log", ioException); + logOutputStream = commandLog.getOutputStream(); + outErr = tee(outErr, OutErr.create(logOutputStream, logOutputStream)); + } catch (IOException ioException) { + LoggingUtil.logToRemote( + Level.WARNING, "Unable to delete or open command.log", ioException); + } } ExitCode result = checkCwdInWorkspace(env, commandAnnotation, commandName, outErr); diff --git a/src/main/java/com/google/devtools/build/lib/runtime/BlazeRuntime.java b/src/main/java/com/google/devtools/build/lib/runtime/BlazeRuntime.java index 597d4d064a..2b64b6ed80 100644 --- a/src/main/java/com/google/devtools/build/lib/runtime/BlazeRuntime.java +++ b/src/main/java/com/google/devtools/build/lib/runtime/BlazeRuntime.java @@ -290,6 +290,10 @@ public final class BlazeRuntime { return getWorkspace().getDirectories().getOutputBase().getChild("server"); } + public boolean writeCommandLog() { + return startupOptionsProvider.getOptions(BlazeServerStartupOptions.class).writeCommandLog; + } + /** * Returns the {@link QueryEnvironmentFactory} that should be used to create a * {@link AbstractBlazeQueryEnvironment}, whenever one is needed. diff --git a/src/main/java/com/google/devtools/build/lib/runtime/BlazeServerStartupOptions.java b/src/main/java/com/google/devtools/build/lib/runtime/BlazeServerStartupOptions.java index ee5d58aff6..75c4dee166 100644 --- a/src/main/java/com/google/devtools/build/lib/runtime/BlazeServerStartupOptions.java +++ b/src/main/java/com/google/devtools/build/lib/runtime/BlazeServerStartupOptions.java @@ -269,4 +269,10 @@ public class BlazeServerStartupOptions extends OptionsBase { category = "server startup", help = "If true, Blaze runs as Exoblaze") public boolean exoblaze; + + @Option(name = "write_command_log", + defaultValue = "true", + category = "undocumented", + help = "Whether or not to write the command.log file") + public boolean writeCommandLog; } |