Bazel is building executables without .exe extension

  • 1 year ago
Comment

ChatGPTChatGPT
1 / 1

By default, Bazel builds executables without a file extension on Windows systems. This behavior is intentional and aligns with the convention in Bazel's target platform-agnostic approach.

However, if you prefer to have the .exe extension added to the built executables, you can configure Bazel to do so. Here's how you can accomplish this:

  1. Open your Bazel project's WORKSPACE file.

  2. Add the following line to the WORKSPACE file:

    python
    load("@bazel_tools//tools/build_defs/repo:utils.bzl", "platform")
    platform(name = "windows")
  3. Save the WORKSPACE file.

This modification explicitly defines the windows platform in the Bazel workspace, enabling certain platform-specific behaviors.

Once this change is in place, Bazel will automatically add the .exe file extension to the built executables on Windows systems.

Please note that this modification affects the entire Bazel workspace. Therefore, it will impact all targets built by Bazel in the workspace.