aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/tools
diff options
context:
space:
mode:
authorGravatar olaola <olaola@google.com>2018-06-15 08:16:44 -0700
committerGravatar Copybara-Service <copybara-piper@google.com>2018-06-15 08:18:10 -0700
commita5e36eeb6d97cb7530317d565062b39de7392c55 (patch)
treeb163c1c741ba3a2a407b6da26e33225648810036 /src/tools
parentef5b63ddb4b00a573d3f1c016e508bf3d412b57a (diff)
Adding a tool to parse the execution logs.
For now, the tool simply displays the log as text. TESTED=ran it RELNOTES: A tool to parse the Bazel execution log. PiperOrigin-RevId: 200718299
Diffstat (limited to 'src/tools')
-rw-r--r--src/tools/execlog/BUILD12
-rw-r--r--src/tools/execlog/README.md14
-rw-r--r--src/tools/execlog/src/main/java/com/google/devtools/build/execlog/BUILD15
-rw-r--r--src/tools/execlog/src/main/java/com/google/devtools/build/execlog/ExecLogParser.java40
-rw-r--r--src/tools/execlog/src/main/java/com/google/devtools/build/execlog/ParserOptions.java33
5 files changed, 114 insertions, 0 deletions
diff --git a/src/tools/execlog/BUILD b/src/tools/execlog/BUILD
new file mode 100644
index 0000000000..d6ba1a2ac8
--- /dev/null
+++ b/src/tools/execlog/BUILD
@@ -0,0 +1,12 @@
+filegroup(
+ name = "srcs",
+ srcs = glob(["**"]) + ["//src/tools/execlog/src/main/java/com/google/devtools/build/execlog:srcs"],
+ visibility = ["//src:__pkg__"],
+)
+
+java_binary(
+ name = "parser",
+ main_class = "com.google.devtools.build.execlog.ExecLogParser",
+ visibility = ["//visibility:public"],
+ runtime_deps = ["//src/tools/execlog/src/main/java/com/google/devtools/build/execlog:parser"],
+)
diff --git a/src/tools/execlog/README.md b/src/tools/execlog/README.md
new file mode 100644
index 0000000000..a65c9ee1c8
--- /dev/null
+++ b/src/tools/execlog/README.md
@@ -0,0 +1,14 @@
+# Execution Log Parser
+
+This tool is used to inspect and parse the Bazel execution logs.
+To generate the execution log, run e.g.:
+
+ bazel build \
+ --experimental_execution_log_file=/tmp/exec.log :hello_world
+
+Then build the parser and run it.
+
+ bazel build src/tools/execlog:all
+ bazel-bin/src/tools/execlog/parser --log_path=/tmp/exec.log
+
+This will simply print the log contents to stdout in text form.
diff --git a/src/tools/execlog/src/main/java/com/google/devtools/build/execlog/BUILD b/src/tools/execlog/src/main/java/com/google/devtools/build/execlog/BUILD
new file mode 100644
index 0000000000..8aa327ad42
--- /dev/null
+++ b/src/tools/execlog/src/main/java/com/google/devtools/build/execlog/BUILD
@@ -0,0 +1,15 @@
+filegroup(
+ name = "srcs",
+ srcs = glob(["**"]),
+ visibility = ["//src/tools/execlog:__pkg__"],
+)
+
+java_library(
+ name = "parser",
+ srcs = glob(["*.java"]),
+ visibility = ["//src/tools/execlog:__subpackages__"],
+ deps = [
+ "//src/main/java/com/google/devtools/common/options",
+ "//src/main/protobuf:spawn_java_proto",
+ ],
+)
diff --git a/src/tools/execlog/src/main/java/com/google/devtools/build/execlog/ExecLogParser.java b/src/tools/execlog/src/main/java/com/google/devtools/build/execlog/ExecLogParser.java
new file mode 100644
index 0000000000..238a30be49
--- /dev/null
+++ b/src/tools/execlog/src/main/java/com/google/devtools/build/execlog/ExecLogParser.java
@@ -0,0 +1,40 @@
+// Copyright 2018 The Bazel Authors. All rights reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+package com.google.devtools.build.execlog;
+
+import com.google.devtools.build.lib.exec.Protos.SpawnExec;
+import com.google.devtools.common.options.OptionsParser;
+
+import java.io.FileInputStream;
+import java.io.InputStream;
+
+/**
+ * A tool to inspect and parse the Bazel execution log.
+ */
+final class ExecLogParser {
+
+ static final String DELIMITER = "\n---------------------------------------------------------\n";
+
+ public static void main(String[] args) throws Exception {
+ OptionsParser op = OptionsParser.newOptionsParser(ParserOptions.class);
+ op.parseAndExitUponError(args);
+ ParserOptions options = op.getOptions(ParserOptions.class);
+ InputStream in = new FileInputStream(options.logPath);
+ while (in.available() > 0) {
+ SpawnExec ex = SpawnExec.parseDelimitedFrom(in);
+ System.out.println(ex);
+ System.out.println(DELIMITER);
+ }
+ }
+}
diff --git a/src/tools/execlog/src/main/java/com/google/devtools/build/execlog/ParserOptions.java b/src/tools/execlog/src/main/java/com/google/devtools/build/execlog/ParserOptions.java
new file mode 100644
index 0000000000..326cb43624
--- /dev/null
+++ b/src/tools/execlog/src/main/java/com/google/devtools/build/execlog/ParserOptions.java
@@ -0,0 +1,33 @@
+// Copyright 2018 The Bazel Authors. All rights reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+package com.google.devtools.build.execlog;
+
+import com.google.devtools.common.options.Option;
+import com.google.devtools.common.options.OptionDocumentationCategory;
+import com.google.devtools.common.options.OptionEffectTag;
+import com.google.devtools.common.options.OptionsBase;
+
+/** Options for execution log parser. */
+public class ParserOptions extends OptionsBase {
+ @Option(
+ name = "log_path",
+ defaultValue = "null",
+ category = "logging",
+ documentationCategory = OptionDocumentationCategory.UNCATEGORIZED,
+ effectTags = {OptionEffectTag.UNKNOWN},
+ help = "Location of the log file to parse."
+ )
+ public String logPath;
+}