Home > Enterprise >  Change bazel output symlink location
Change bazel output symlink location

Time:02-02

I am using Bazel as my C build system and whenever I build my project my root directory is cluttered up with the bazel symlinks: bazel-bin, bazel-out, bazel-pipeline, and bazel-testlogs. Is it possible for me to have bazel place these in a directory such as ./out? I have tried using --output_base=./out and --output_user_root=./out however the symlinks are still placed in the root directory.

Here is what I want my project structure to be after a bazel [options] build:

ProjectRoot
├── bin
│   ├── App.cpp
│   └── BUILD.bazel
├── lib
│   ├── Lib1
│   │   ├── Lib1.cpp
│   │   ├── Lib1.hpp
│   │   └── BUILD.bazel
│   ├── Lib2
│   │   ├── Lib2.cpp
│   │   ├── Lib2.hpp
│   │   └── BUILD.bazel
│   └── BUILD.bazel
├── out
│   ├── bazel-bin
│   │   ├── stuff
│   │   └── ...
│   ├── bazel-out
│   │   ├── stuff
│   │   └── ...
│   ├── bazel-pipeline
│   │   ├── stuff
│   │   └── ...
│   └── bazel-testlogs
│       ├── stuff
│       └── ...
├── test
│   ├── test.cpp
│   └── BUILD.bazel
└── WORKSPACE.bazel

Here is what it currently is:

ProjectRoot
├── bazel-bin
│   ├── stuff
│   └── ...
├── bazel-out
│   ├── stuff
│   └── ...
├── bazel-pipeline
│   ├── stuff
│   └── ...
├── bazel-testlogs
│   ├── stuff
│   └── ...
├── bin
│   ├── App.cpp
│   └── BUILD.bazel
├── lib
│   ├── Lib1
│   │   ├── Lib1.cpp
│   │   ├── Lib1.hpp
│   │   ├── BUILD.bazel
│   ├── Lib2
│   │   ├── Lib2.cpp
│   │   ├── Lib2.hpp
│   │   ├── BUILD.bazel
│   └── BUILD.bazel
├── out
├── test
│   ├── test.cpp
│   └── BUILD.bazel
└── WORKSPACE.bazel

CodePudding user response:

You're looking for --symlink_prefix. E.g., --symlink_prefix=/tmp/anywhere/you/want/bazel-.

  • Related