- Read the steps in https://bazel.build/versions/master/docs/windows.html.
- Read the github issues bazelbuild/bazel#2431 and related bazelbuild/bazel#2449.
- May be useful to consult https://github.com/bazelbuild/bazel/blob/master/tools/cpp/cc_configure.bzl.
- Make sure you install the Feb 5 2016 Msys2 version from https://sourceforge.net/projects/msys2/files/Base/x86_64/msys2-x86_64-20160205.exe/download.
- The install path must be
c:\tools\msys64
(hardcoded into bazel). - Open an msys2 shell.
- Upgrade the installation with
pacman -Syuu gcc git curl zip unzip zlib-devel
as per instructions. This triggered a bunch of cygwin errors but the command completed. Close the msys2 shell and re-open it. - In my case this did not include python within msys2, so I did
pacman -S python2
also.
I downloaded bazel within msys2 shell using the link from the bazel releases page as $ curl -O -J -L https://github.com/bazelbuild/bazel/releases/download/0.4.5/bazel-0.4.5-windows-x86_64.exe
(which I then renamed to bazel.exe
).
Although the bazel windows instructions suggested that VS was only a compile dependency, bazel.exe would not run without it.
Specifically, the cc_configure.bzl
script needed the vsvarsall.bat
script, which is part of Visual Studio.
I already had VS2015 installed, but the C++ build tools were not installed, so I had to get this installed via Control Panel > Programs > Programs and Features
, right click Microsoft Visual Studio Enterprise 2015 with Updates
"Change", choose the [Modify]
button, and then select the Programming Languages / Visual C++
checkbox. This added 5G of stuff.
A few environment variables needed to be set:
$ env | grep BAZEL
BAZEL_PYTHON=/usr/bin/python2.exe
BAZEL_VS=C:/Program Files (x86)/Microsoft Visual Studio 14.0
BAZEL_SH=c:/tools/msys64/usr/bin/bash.exe
After all that I was able to build a simple java project:
$ ~/bazel.exe run :app
INFO: Found 1 target...
Target //src/main/java:app up-to-date:
C:/tools/msys64/tmp/_bazel_paulj/rklkin_f/execroot/atweb/bazel-out/local-fastbuild/bin/src/main/java/app.jar
C:/tools/msys64/tmp/_bazel_paulj/rklkin_f/execroot/atweb/bazel-out/local-fastbuild/bin/src/main/java/app
C:/tools/msys64/tmp/_bazel_paulj/rklkin_f/execroot/atweb/bazel-out/local-fastbuild/bin/src/main/java/app.cmd
INFO: Elapsed time: 0.540s, Critical Path: 0.01s
INFO: Running command line: C:/tools/msys64/tmp/_bazel_paulj/rklkin_f/execroot/atweb/bazel-out/local-fastbuild/bin/src/main/java/app.cmd
Hello World!
Yay! Good luck.
Hi; that's a great guide. I maintain the Bazel chocolatey package for Windows. Out of interest, does that work for you too? If there are any problems with it, please let me know.