I Bazel the right tool for me? (Migrating existing CPP VS win projects to linux)

64 views
Skip to first unread message

Misha Golub

unread,
Jun 2, 2021, 1:09:14 PM6/2/21
to bazel-discuss
Hello. I have a codebase that was a set of Windows Visual Studio solutions for long time. It is split between multiple git projects, one of them contains supposedly cross platform code.

When tasked with compiling it for linux I immediately recalled that I heard a lot of good stuff about Bazel from senior devops.

I want to hear your opinion on whether Bazel is the right tool and if so want to hear best practices for issues that I have.

In the past when people tried to compile it for linux it involved a lot of shell scripts with gcc calls and horrible hacks.

I heard that Bazel makes it harder to shoot yourself in the foot and break incremental build, for example.

The original plan was to keep using Visual Studio/Incredibuild for WIndows and write separate BUILD files for linux part.

I tried to just write some build files and I am having a problem because over the year the codebase accumulated a lot of junk in include and link paths. The VSproject did not always follow best practices, a lot of includes in the code are "just add more include paths from environment variables until it compiles" and "when including just use path relative to some known preexisting path even though it is kinda unrelated"

When I try to use --copt=-I/path/to/workspace Bazel does not let me do it, kinda good sign as it does not let me shoot in the foot.

Most include statements in solution are relative to workspace directory. For example:

"$WORKSPACEDIR/code/bar/bar.cpp"  has 
    #include "code/stuff.h"
"$WORKSPACEDIR/code/stuff.h" includes like this
   #include "code/util/temporary_hacks.h"
"$WORKSPACEDIR/code/util/temporary_hacks.h" also includes with path relative to workspace dir.

Is it possible to "Bazelify" the project without rewriting the includes everywhere? What are the best practices for doing it?
Reply all
Reply to author
Forward
0 new messages