From f2c1020e83c2b4623810e532dd7ca6ddbcc9c3a6 Mon Sep 17 00:00:00 2001 From: Chad Norvell Date: Tue, 3 Sep 2024 23:16:26 +0000 Subject: [PATCH] pw_ide: Allow disabling clangd query drivers arg MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change-Id: I9b6075217561f3556f27e5dc45ee7b373235bd15 Reviewed-on: https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/233491 Reviewed-by: Anthony DiGirolamo Pigweed-Auto-Submit: Chad Norvell Commit-Queue: Auto-Submit Lint: Lint 🤖 --- pw_ide/py/pw_ide/cpp.py | 7 ++++++- pw_ide/py/pw_ide/settings.py | 21 +++++++++++++++++---- 2 files changed, 23 insertions(+), 5 deletions(-) diff --git a/pw_ide/py/pw_ide/cpp.py b/pw_ide/py/pw_ide/cpp.py index a01dac2a82..71ac269d93 100644 --- a/pw_ide/py/pw_ide/cpp.py +++ b/pw_ide/py/pw_ide/cpp.py @@ -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.""" diff --git a/pw_ide/py/pw_ide/settings.py b/pw_ide/py/pw_ide/settings.py index b173c65f71..b319ab6abf 100644 --- a/pw_ide/py/pw_ide/settings.py +++ b/pw_ide/py/pw_ide/settings.py @@ -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) @@ -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: