How to make Bazel print file paths to the console using backslashes on Windows

53 views
Skip to first unread message

Konstantin

unread,
Jun 13, 2022, 9:09:57 PM6/13/22
to bazel-discuss
When Bazel compiles C++ files it prints out file paths with the forward slashes, like this:
    Compiling src/cpp/test/ActivityContextProxyTest.cpp; 6s local
    Compiling src/cpp/main/MetricsMonitor.cpp; 6s local
Same when it displays compilation errors:
external/art-cpp/src/cpp/test/TStringAssertionTraits.cpp(18): error C2143: syntax error: missing ';' before 'CppUnit::assertion_traits<TString>::equal'
external/art-cpp/src/cpp/test/TStringAssertionTraits.cpp(18): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int

This creates a problem for Visual Studio on Windows - it does not understand forward slashes, so clicking on the error to navigate to source does not work.

Is there a way to make Bazel print backslashes in the paths on Windows? At least in the compiler error messages.

Thank you!
Konstantin

Alex Humesky

unread,
Jun 14, 2022, 5:52:28 PM6/14/22
to Konstantin, bazel-discuss
On Mon, Jun 13, 2022 at 9:10 PM Konstantin <kon...@ermank.com> wrote:
When Bazel compiles C++ files it prints out file paths with the forward slashes, like this:
    Compiling src/cpp/test/ActivityContextProxyTest.cpp; 6s local
    Compiling src/cpp/main/MetricsMonitor.cpp; 6s local

This part looks like it comes from bazel, so that part is potentially changeable so it prints platform-dependent plaths. Probably best to file a feature request

Same when it displays compilation errors:
external/art-cpp/src/cpp/test/TStringAssertionTraits.cpp(18): error C2143: syntax error: missing ';' before 'CppUnit::assertion_traits<TString>::equal'
external/art-cpp/src/cpp/test/TStringAssertionTraits.cpp(18): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int

Is this coming from bazel, or a compiler? Looks to me like it's from a compiler, so I'm not sure that bazel can do much about that unfortunately.


This creates a problem for Visual Studio on Windows - it does not understand forward slashes, so clicking on the error to navigate to source does not work.

Is there a way to make Bazel print backslashes in the paths on Windows? At least in the compiler error messages.

Thank you!
Konstantin

--
You received this message because you are subscribed to the Google Groups "bazel-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to bazel-discus...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/bazel-discuss/28ab7871-7eac-4131-9eae-18cbc39f1f1bn%40googlegroups.com.

Konstantin

unread,
Jun 21, 2022, 1:13:32 PM6/21/22
to bazel-discuss
One partial workaround I found is MSVC option "/FC" which makes it use canonicalized paths in all diagnostics.
Reply all
Reply to author
Forward
0 new messages