If you are looking for a searchable/indexed interface into Verible's source code, this is already deployed at https://cs.opensource.google/verible/verible.
If you would like to learn how manually index the source code yourself, perhaps for offline work, then read on. The steps mentioned here can be generalized for indexing Bazel-based projects.
More information about indexing Bazel-based projects using Kythe here.
Download the latest Kythe release from https://github.com/kythe/kythe/releases and then unpack it for a snapshot of Kythe’s toolset.
tar xzf kythe-v*.tar.gz
rm -rf /opt/kythe
mv kythe-v*/ /opt/kythe
More information can be found here.
Clone Kythe from here. Then from within the Kythe clone, build the web frontend and copy its files into /opt/kythe/
bazel build //kythe/web/ui
mkdir -p /opt/kythe/web/ui
cp -r bazel-bin/kythe/web/ui/resources/public/* /opt/kythe/web/ui
cp -r kythe/web/ui/resources/public/* /opt/kythe/web/ui
chmod -R 755 /opt/kythe/web/ui
More information can be found here.
vnames.json
file is used for renaming certain filepaths during extraction, but
renaming isn’t needed here but you can add the renaming you find suitable.
# run on all targets
bazel test --experimental_action_listener=:extract_cxx //...
# run on specific target (e.g. some cc_binary or cc_library)
bazel test --experimental_action_listener=:extract_cxx //verilog/analysis:default_rules
Extracted kzip files will be in bazel-out/local-fastbuild/extra_actions/extractor folder. One kzip file per target.
find -L bazel-out -name '*cxx.kzip'
More information can be found here.
For extracting the indexing facts from extracted kzip
files, run the following
command to apply the indexing for each kzip
file and generate the result into
kythe graphstore
.
for i in $(find -L bazel-out -name '*cxx.kzip'); do
# Indexing C++ compilations
/opt/kythe/indexers/cxx_indexer --ignore_unimplemented "$i" > entries
# Write entry stream into a GraphStore
/opt/kythe/tools/write_entries --graphstore leveldb:.kythe_graphstore < entries
done
# Generate corresponding serving tables
/opt/kythe/tools/write_tables --graphstore .kythe_graphstore --out .kythe_serving
Run Kythe's UI
to visualize cross-reference and code navigation.
# --listen localhost:8080 allows access from only this machine; change to
# --listen 0.0.0.0:8080 to allow access from any machine
/opt/kythe/tools/http_server \
--public_resources /opt/kythe/web/ui \
--listen localhost:8080 \
--serving_table .kythe_serving