Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

lower drive letter on win32 #236

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion refresh.template.py
Original file line number Diff line number Diff line change
Expand Up @@ -1147,6 +1147,17 @@ def _convert_compile_commands(aquery_output):
) as threadpool:
outputs = threadpool.map(_get_cpp_command_for_files, aquery_output.actions)

# Workaround for: https://github.com/clangd/clangd/issues/108
# Fixes clangd's ambiguous path handling which cause a broken f2-editing
def lower_drive_if_win32(dir):
if sys.platform == 'win32':
drive, path = os.path.splitdrive(dir)
dir = os.path.join(str(drive).lower(), path)

return dir

dir = lower_drive_if_win32(os.environ["BUILD_WORKSPACE_DIRECTORY"])

# Yield as compile_commands.json entries
header_files_already_written = set()
for source_files, header_files, compile_command_args in outputs:
Expand All @@ -1167,7 +1178,7 @@ def _convert_compile_commands(aquery_output):
# Using `arguments' instead of 'command' because it's now preferred by clangd. Heads also that shlex.join doesn't work for windows cmd, so you'd need to use windows_list2cmdline if we ever switched back. For more, see https://github.com/hedronvision/bazel-compile-commands-extractor/issues/8#issuecomment-1090262263
'arguments': compile_command_args,
# Bazel gotcha warning: If you were tempted to use `bazel info execution_root` as the build working directory for compile_commands...search ImplementationReadme.md to learn why that breaks.
'directory': os.environ["BUILD_WORKSPACE_DIRECTORY"],
'directory': dir,
}


Expand Down