Kythe uses Bazel to build itself and has implemented Bazel
that use Kythe’s Java and C++ extractors. This effectively allows Bazel to
extract each compilation as it is run during the build.
Extracting the Kythe repository
Add the flag
to make Bazel extract Java compilations and
--experimental_action_listener=@io_kythe//kythe/extractors:extract_kzip_cxx to do the
same for C++.
You can use the Kythe release to extract compilations from other Bazel based
Extracting CMake based repositories
These instructions assume your environment is already set up to successfully
run cmake for your repository.
Set the following three environment variables:
KYTHE_ROOT_DIRECTORY: The absolute path for file input to be extracted.
This is generally the root of the repository. All files extracted will be
stored relative to this path.
KYTHE_OUTPUT_DIRECTORY: The absolute path for storing output.
KYTHE_CORPUS: The corpus label for extracted files.
$ export KYTHE_ROOT_DIRECTORY="/absolute/path/to/repo/root"$ export KYTHE_OUTPUT_DIRECTORY="/tmp/kythe-output"$ export KYTHE_CORPUS="github.com/myproject/myrepo"# $CMAKE_ROOT_DIRECTORY is passed into the -sourcedir flag. This value should be# the directory that contains the top-level CMakeLists.txt file. In many# repositories this path is the same as $KYTHE_ROOT_DIRECTORY.$ export CMAKE_ROOT_DIRECTORY="/absolute/path/to/cmake/root"$ /opt/kythe/tools/runextractor cmake \-extractor=/opt/kythe/extractors/cxx_extractor \-sourcedir=$CMAKE_ROOT_DIRECTORY
// Get all file nodes
cayley> g.V().Has("/kythe/node/kind", "file").All()
// Get definition anchors for all record nodes
cayley> g.V().Has("/kythe/node/kind", "record").Tag("record").In("/kythe/edge/defines").All()
// Get the file(s) defining a particular node
cayley> g.V("node_ticket").In("/kythe/edge/defines").Out("/kythe/edge/childof").Has("/kythe/node/kind", "file").All()
As part of Kythe’s first release, a sample UI has been made to show Kythe’s
basic cross-reference capabilities. The following command can be run over the
serving table created with the write_tables binary (see above).