Decide where you want to store kythe code, e.g. ~/my/code/dir
(note that after we clone from git, it will append ‘kythe’ as the last directory).
{% highlight bash %} cd ~/my/code/dir git clone https://github.com/kythe/kythe.git {% endhighlight %}
Also set the env var KYTHE_DIR=~/my/code/dir/kythe
in your .bashrc
while you're at it.
If you use ssh to authenticate to github: {% highlight bash %} git clone git@github.com:kythe/kythe.git {% endhighlight %}
Kythe relies on the following external dependencies:
//kythe/release/...
and //buildtools/docker
)//kythe/web/ui
)You will need to ensure these packages are installed on the system where you intend to build Kythe. There are instructions for using apt-get
below. If you are using macOS, see Instructions for macOS.
{% highlight bash %} echo deb http://http.debian.net/debian jessie-backports main >> /etc/apt/sources.list apt-get update
apt-get install
asciidoc asciidoctor source-highlight graphviz
gcc uuid-dev libncurses-dev flex clang-3.8 bison
openjdk-8-jdk
parallel
wget
{% endhighlight %}
You must either have /usr/bin/clang
aliased properly, or the CC
env var set for Bazel:
{% highlight bash %} echo ‘build --client_env=CC=/usr/bin/clang-3.8’ >>~/.bazelrc {% endhighlight %}
OR:
{% highlight bash %} sudo ln -s /usr/bin/clang-3.8 /usr/bin/clang sudo ln -s /usr/bin/clang++-3.8 /usr/bin/clang++ {% endhighlight %}
OR:
{% highlight bash %} echo ‘export CC=/usr/bin/clang’ >> ~/.bashrc source ~/.bashrc {% endhighlight %}
If you ran bazel and get errors like this:
{% highlight bash %} /home/username/kythe/third_party/zlib/BUILD:10:1: undeclared inclusion(s) in rule ‘//third_party/zlib:zlib’: this rule is missing dependency declarations for the following files included by ‘third_party/zlib/uncompr.c’: ‘/usr/lib/llvm-3.6/lib/clang/3.6.0/include/limits.h’ ‘/usr/lib/llvm-3.6/lib/clang/3.6.0/include/stddef.h’ ‘/usr/lib/llvm-3.6/lib/clang/3.6.0/include/stdarg.h’. {% endhighlight %}
then you need to clean and rebuild your TOOLCHAIN:
{% highlight bash %} bazel clean --expunge && bazel build @local_config_cc//:toolchain {% endhighlight %}
Kythe uses Bazel to build its source code. After installing Bazel and all external dependencies, building Kythe should be as simple as:
{% highlight bash %} bazel build //... # Build all Kythe sources bazel test //... # Run all Kythe tests {% endhighlight %}
Please note that you must use a non-jdk7 version of Bazel. Some package managers may provide the jdk7 version by default. To determine if you are using an incompatible version of Bazel, look for jdk7
in the build label that is printed by bazel version
.
Also note that not all targets build with //...
- some targets are purposefully omitted. This includes //kythe/web/ui
, //kythe/release
, and many of the docker images we push.
Many examples on the site assume you have installed kythe in /opt/kythe.
{% highlight bash %}
bazel build //kythe/release
export KYTHE_RELEASE=“x.y.z”
tar -zxf bazel-genfiles/kythe/release/kythe-v${KYTHE_RELEASE}.tar.gz --directory /opt/
rm -f /opt/kythe
ln -s /opt/kythe-v${KYTHE_RELEASE} /opt/kythe {% endhighlight %}
Kythe's Go sources can be directly built with the go
tool as well as with Bazel.
{% highlight bash %}
sudo apt-get install libleveldb-dev libsnappy-dev
go get kythe.io/kythe/...
git clone https://github.com/kythe/kythe.git GOPATH=$GOPATH:$PWD/kythe/third_party/go go get kythe.io/kythe/... {% endhighlight %}
The additional benefits of using Bazel are the built-in support for generating the Go protobuf code in kythe/proto/
and the automatic usage of the checked-in third_party/go
libraries (instead of adding to your GOPATH
). However, for quick access to Kythe‘s Go sources (which implement most of Kythe’s platform and language-agnostic services), using the Go tool is very convenient.
Prerequisites: {% highlight bash %} apt-get install ruby ruby-dev build-essential gem install bundler {% endhighlight %}
Build and serve: {% highlight bash %} cd ./kythe/web/site ./build.sh
bundle exec jekyll serve {% endhighlight %}