You can build Bazel from source following these steps:
Ensure that JDK 8, Python, bash, zip, and the usual C build toolchain are installed on your system.
On systems based on Debian packages (Debian, Ubuntu): you can install OpenJDK 8 and Python by running the following command in a terminal:
sudo apt-get install build-essential openjdk-8-jdk python zip
On Windows: you need additional software. See the requirements page.
Download and unpack Bazel's distribution archive.
Download bazel-<version>-dist.zip
from the release page. We recommend to also verify the signature made by our release key 48457EE0.
The distribution archive contains generated files in addition to the versioned sources, so this step cannot be short cut by checking out the source tree.
Build Bazel using ./compile.sh
.
cd
into the directory where you unpacked the distribution archivebash ./compile.sh
cd
into the directory where you unpacked the distribution archive./compile.sh
The output will be output/bazel
on Unix-like systems (e.g. Ubuntu, macOS) and output/bazel.exe
on Windows. This is a self-contained Bazel binary. You can copy it to a directory on the PATH
(such as /usr/local/bin
on Linux) or use it in-place.
Make sure your machine meets the requirements.
Depending on the Bazel version you compile:
bazel-0.5.4-dist.zip
and newer:
The compilation script uses Visual C++ to compile Bazel‘s C++ code. The resulting Bazel binary is a native Windows binary and it’s not linked to msys-2.0.dll
.
bazel-0.5.0-dist.zip
through bazel-0.5.3-dist.zip
:
The compilation script uses GCC to build Bazel's C++ code. The resulting Bazel binary is an msys binary so it is linked to msys-2.0.dll
.
You can patch the compilation script to build Bazel using Visual C++ instead of GCC, and avoid linking it to msys-2.0.dll
. The patch is to replace these lines in ./compile.sh
:
if [[ $PLATFORM == "windows" ]]; then EXTRA_BAZEL_ARGS="${EXTRA_BAZEL_ARGS-} --cpu=x64_windows_msys --host_cpu=x64_windows_msys" fi
with these lines:
if [[ $PLATFORM == "windows" ]]; then EXTRA_BAZEL_ARGS="${EXTRA_BAZEL_ARGS-} --cpu=x64_windows_msvc --host_cpu=x64_windows_msvc" fi
bazel-0.4.5-dist.zip
and earlier:
The compilation script uses GCC to compile Bazel's C++ code. The resulting Bazel binary is an msys binary so it is linked to msys-2.0.dll
. Bazel cannot be built using Visual C++.