Skip to content

Instantly share code, notes, and snippets.

@russelyang
Forked from pcj/README.md
Created August 10, 2017 16:44
Show Gist options
  • Save russelyang/6dd29c031efe245fb8557a41e7cce8ce to your computer and use it in GitHub Desktop.
Save russelyang/6dd29c031efe245fb8557a41e7cce8ce to your computer and use it in GitHub Desktop.
Installing bazel 0.4.5 on Windows

Installing bazel 0.4.5 on Windows 10

  1. Read the steps in https://bazel.build/versions/master/docs/windows.html.
  2. Read the github issues bazelbuild/bazel#2431 and related bazelbuild/bazel#2449.
  3. May be useful to consult https://github.com/bazelbuild/bazel/blob/master/tools/cpp/cc_configure.bzl.

Install Msys2

  1. 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.
  2. The install path must be c:\tools\msys64 (hardcoded into bazel).
  3. Open an msys2 shell.
  4. 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.
  5. In my case this did not include python within msys2, so I did pacman -S python2 also.

Install Bazel

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).

Install Visual Studio

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.

Setup environment

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

Finally

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment