Skip to content

Commit

Permalink
pw_ide: Allow disabling clangd query drivers arg
Browse files Browse the repository at this point in the history
Change-Id: I9b6075217561f3556f27e5dc45ee7b373235bd15
Reviewed-on: https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/233491
Reviewed-by: Anthony DiGirolamo <[email protected]>
Pigweed-Auto-Submit: Chad Norvell <[email protected]>
Commit-Queue: Auto-Submit <[email protected]>
Lint: Lint 🤖 <[email protected]>
  • Loading branch information
chadnorvell authored and CQ Bot Account committed Sep 3, 2024
1 parent 7456907 commit f2c1020
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 5 deletions.
7 changes: 6 additions & 1 deletion pw_ide/py/pw_ide/cpp.py
Original file line number Diff line number Diff line change
Expand Up @@ -1202,13 +1202,18 @@ def __init__(self, settings: PigweedIdeSettings):
compile_commands_dir = str(state.stable_target_link)

host_cc_path = find_cipd_installed_exe_path("clang++")

self.arguments: list[str] = [
f'--compile-commands-dir={compile_commands_dir}',
f'--query-driver={settings.clangd_query_driver_str(host_cc_path)}',
'--background-index',
'--clang-tidy',
]

query_driver = settings.clangd_query_driver_str(host_cc_path)

if query_driver is not None:
self.arguments.append(f'--query-driver={query_driver}')

def command(self, system: str = platform.system()) -> str:
"""Return the command that runs clangd with Pigweed paths."""

Expand Down
21 changes: 17 additions & 4 deletions pw_ide/py/pw_ide/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -332,17 +332,25 @@ def clangd_alternate_path(self) -> Path | None:
return self._config.get('clangd_alternate_path', None)

@property
def clangd_additional_query_drivers(self) -> list[str]:
def clangd_additional_query_drivers(self) -> list[str] | None:
"""Additional query driver paths that clangd should use.
By default, ``pw_ide`` supplies driver paths for the toolchains included
in Pigweed. If you are using toolchains that are not supplied by
Pigweed, you should include path globs to your toolchains here. These
paths will be given higher priority than the Pigweed toolchain paths.
If you want to omit the query drivers argument altogether, set this to
``null``.
"""
return self._config.get('clangd_additional_query_drivers', list())

def clangd_query_drivers(self, host_clang_cc_path: Path) -> list[str]:
def clangd_query_drivers(
self, host_clang_cc_path: Path
) -> list[str] | None:
if self.clangd_additional_query_drivers is None:
return None

drivers = [
*[
_expand_any_vars_str(p)
Expand All @@ -357,8 +365,13 @@ def clangd_query_drivers(self, host_clang_cc_path: Path) -> list[str]:

return drivers

def clangd_query_driver_str(self, host_clang_cc_path: Path) -> str:
return ','.join(self.clangd_query_drivers(host_clang_cc_path))
def clangd_query_driver_str(self, host_clang_cc_path: Path) -> str | None:
clangd_query_drivers = self.clangd_query_drivers(host_clang_cc_path)

if clangd_query_drivers is None:
return None

return ','.join(clangd_query_drivers)

@property
def workspace_root(self) -> Path:
Expand Down

0 comments on commit f2c1020

Please sign in to comment.