This file provides instructions on how to build and test SkCMS using Bazel.
Open a terminal and cd
into your SkCMS repository checkout, then run:
$ bazel build //... $ bazel test //...
Same as above, but add --config=linux-rbe
to your bazel
invocation, e.g.:
$ bazel build //... --config=linux-rbe $ bazel test //... --config=linux-rbe
Note that you need to obtain RBE credentials for this to work (instructions below).
TODO(lovisolo)
SkCMS can be compiled with either Microsoft Build Tools for Visual Studio 2019 or Clang.
Before continuing, install Bazel by following the instructions here. Make sure to include bazel
binary in your PATH
.
Note that Bazel requires symlink support to function properly. Enable symlink support by enabling Developer Mode, or by running Bazel as an administrator (reference).
The below instructions are based on the Build on Windows section of the Bazel documentation.
Download and install Build Tools for Visual Studio 2019 using this link. Select “Desktop development with C++” on the installation wizard, and leave all other items unchanged.
Open cmd.exe
and cd
into your SkCMS repository checkout. Set the BAZEL_VC
environment variable to point to your Build Tools for Visual Studio 2019 installation:
> set BAZEL_VC=C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\VC
Then run:
> bazel build //... > bazel test //... --enable_runfiles
Reference here.
TODO(lovisolo): Consider adding --enable_runfiles
to //.bazelrc
.
In order to build with Clang, you have to install both LLVM and Build Tools for Visual Studio 2019 (rationale here). Please install the latter by following the above instructions before proceeding.
Download and install LLVM from this link.
Open cmd.exe
and cd
into your SkCMS repository checkout, then run:
> bazel build //... --compiler=clang-cl > bazel test //... --compiler=clanmg-cl --enable_runfiles
If the above commands fail because Bazel cannot find your LLVM installation, set the BAZEL_LLVM
environment variable to point to your LLVM installation:
> set BAZEL_LLVM=C:\Program Files\LLVM
Reference here.
TODO(lovisolo): Investigate adding a platform target to the top-level BUILD.bazel
file as per the instructions here.
TODO(lovisolo)
Note that running remote builds requires a service account key with the correct permissions.
Instructions:
Step 1: Create service account under the skia-public GCP project, if you don't have one already:
$ gcloud iam service-accounts create somegoogler-rbe \ --description "somegoogler's RBE service account" \ --project skia-public
Step 2: Grant your service account the Remote Build Execution Artifact Creator role under the skia-rbe GCP project, which is where Skia's RBE instance lives:
$ gcloud projects add-iam-policy-binding skia-rbe \ --role roles/remotebuildexecution.artifactCreator \ --member serviceAccount:somegoogler-rbe@skia-public.iam.gserviceaccount.com
Step 3: Create a JSON service account key:
$ gcloud iam service-accounts keys create path/to/somegoogler-rbe.json \ --project skia-public \ --iam-account somegoogler-rbe@skia-public.iam.gserviceaccount.com
Step 4: Create a .bazelrc file in your home directory with the following contents:
build:remote --google_credentials=path/to/somegoogler-rbe.json
Note that service account keys expire after 3 months, so you might have to repeat this step if you run into permission issues.