Skip to content

Commit

Permalink
correct overeager slash conversion on windows
Browse files Browse the repository at this point in the history
Bazel's File().path method will return forward-slashed paths; this means
if you pass a flag like `"/FI" + f.path` it'll end up looking like
`/FIpath/to/thing`; however, _convert_flags was converting all / to -,
which ended up breaking the path. This makes sure to only replace the
_first_ /.
  • Loading branch information
novas0x2a committed Sep 11, 2024
1 parent b25485b commit 93d73c1
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion foreign_cc/private/cc_toolchain_util.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -330,7 +330,7 @@ def _convert_flags(compiler, flags):
list: The converted flags
"""
if compiler == "msvc-cl":
return [flag.replace("/", "-") if flag.startswith("/") else flag for flag in flags]
return [("-" + flag.removeprefix("/")) if flag.startswith("/") else flag for flag in flags]
return flags

def _add_if_needed(arr, add_arr):
Expand Down

0 comments on commit 93d73c1

Please sign in to comment.