Sam DEv
Sam DEv

Reputation: 23

Bazel out-of-source build

I was recently introduced to 'Bazel' build system while learning gtest. Apparently I am a beginner in this thing. So far it is going well, I really appreciate bazel's simplicity. My question is:

How to build a bazel project outside the source directory? (Where my WORKSPACE file resides).

In the build process bazel generates directories like "bazel-bin" and other directories in "bazel-*" form. I want these directories to be in a specific folder and not just cluttered around in the main root source directory, My WORKSPACE file resided in the main source directory. I would like all these files to be in a directory like "build" which itself resides in the root source directory.

Upvotes: 2

Views: 710

Answers (1)

Vertexwahn
Vertexwahn

Reputation: 8142

Create a .bazelrc file with the following content:

build --symlink_prefix=/ # Out of source build

This avoids that Bazel specific symlinks are created in our source dir. If you have already such symlink dirs do a bazel clean to get rid of them and then create the .bazelrc file.

Consider also the Bazel Documentation about the --symlink-prefix flag.

Upvotes: 0

Related Questions