Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .gitsubmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
[submodule "kythe"]
path = third_party/kythe
url = https://github.com/kythe/kythe
[submodule "bazel"]
path = third_party/bazel
url = https://github.com/bazelbuild/bazel
6 changes: 6 additions & 0 deletions BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,12 @@ py_library(
],
)

py_binary(
name = "graphdef_from_bazel",
srcs = ["graphdef_from_bazel.py"],
deps = [":splitbrain"],
)

py_binary(
name = "main",
srcs = ["main.py"],
Expand Down
43 changes: 43 additions & 0 deletions graphdef_from_bazel.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
"""Extracts a GraphDef based on a Bazel workspace.

This tool launches the Bazel binary to extract some data from a workspace, and
processes the protocol buffer output to produce a GraphDef.

Usage:
./graphdef_from_bazel.py --input_dir=path/to/WORKSPACE \\
--output_dir=path/to/out
"""

from absl import app
from absl import flags
import graphdef_utils
from third_party.bazel.src.main.protobuf import build_pb2

FLAGS = flags.FLAGS
flags.DEFINE_string('input_path', None, 'Path to Bazel WORKSPACE file.')
flags.DEFINE_string('output_dir', None, 'Directory to write output to.')
flags.DEFINE_multi_string('modified_files', [],
'List of modified files to `bazel query` for.')
flags.DEFINE_bool('textproto', False,
'If true, writes output statistics as textproto format.')
flags.mark_flag_as_required('input_path')
flags.mark_flag_as_required('output_dir')


def main(argv):
del argv

with open(FLAGS.input_path) as f:
pass

# TODO(cameron): Load bazel proto using vendored dependency.
# TODO(cameron): Filter on predicates: Must be a working change in the CL? Maybe keep transitive.
# TODO(cameron): Find testdata based stuff and make changes bi-directional. Same with proto.
# TODO(cameron): Merge bi-directional dependencies.
# TODO(cameron): Import tests from internal.
# TODO(cameron): Assert the graph is a DAG. Find and merge cycles.
graphdef = program_graph_pb2.GraphDef()


if __name__ == '__main__':
app.run(main)
Binary file added testdata/bazel_query_on_repo.binarypb
Binary file not shown.
1 change: 1 addition & 0 deletions third_party/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# third_party