summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrea Grandi <agrandi@google.com>2022-10-07 14:49:53 -0700
committerChromeos LUCI <chromeos-scoped@luci-project-accounts.iam.gserviceaccount.com>2022-10-21 18:22:53 +0000
commitfae6145045a7bb060c00de1a1fafe506267159e5 (patch)
tree05312290a753b197be054f5f77d49819f2991ecc
parent012d263c875df4a5440777504732df829775979c (diff)
downloadchrome-ec-fae6145045a7bb060c00de1a1fafe506267159e5.tar.gz
util: Add ability to configure clangd for Zephyr
BRANCH=none BUG=b:236389226,b:176500425 TEST=./util/clangd_config.py --os zephyr herobrine TEST=./util/clangd_config.py herobrine TEST=./util/clangd_config.py --os zephyr herobrine ro TEST=./util/clangd_config.py herobrine ro Signed-off-by: Andrea Grandi <agrandi@google.com> Change-Id: I063652e8faf4f6e0443bb2abf2d654cb674d17ac Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3939615 Reviewed-by: Jeremy Bettis <jbettis@chromium.org> Reviewed-by: Craig Hesling <hesling@chromium.org> Reviewed-by: Aaron Massey <aaronmassey@google.com>
-rwxr-xr-xutil/clangd_config.py33
1 files changed, 32 insertions, 1 deletions
diff --git a/util/clangd_config.py b/util/clangd_config.py
index 96bcb7ebf1..2553707c43 100755
--- a/util/clangd_config.py
+++ b/util/clangd_config.py
@@ -65,7 +65,38 @@ def ec_build(ec_root: Path, board: str, image: str) -> Optional[Path]:
def zephyr_build(ec_root: Path, board: str, image: str) -> Optional[Path]:
"""Build the correct compile_commands.json for Zephyr board/image"""
- raise NotImplementedError("Zephyr is currently unsupported.")
+ target = Path(
+ f"build/zephyr/{board}/build-{image.lower()}/compile_commands.json"
+ )
+ cmd = ["zmake", "configure", board]
+
+ print(" ".join(cmd))
+ status = subprocess.run(cmd, check=False, cwd=ec_root)
+
+ if status.returncode != 0:
+ return None
+
+ # Replace /mnt/host/source with path of chromiumos outside chroot
+ default_chromiumos_path_outside_chroot = os.path.join(
+ Path.home(), "chromiumos"
+ )
+ chromiumos_path_outside_chroot = os.environ.get(
+ "EXTERNAL_TRUNK_PATH", default_chromiumos_path_outside_chroot
+ )
+ chromiumos_path_inside_chroot = "/mnt/host/source"
+
+ print(
+ f"Replacing '{chromiumos_path_inside_chroot}' with "
+ + f"'{chromiumos_path_outside_chroot}' in file {target}"
+ )
+
+ target.write_text(
+ target.read_text().replace(
+ chromiumos_path_inside_chroot, chromiumos_path_outside_chroot
+ )
+ )
+
+ return target
def copy(ec_root: Path, target: Path) -> None: