[clang-tools-extra] [llvm] Add bazel support for clangd as a library. (PR #81556)

via cfe-commits cfe-commits at lists.llvm.org
Mon Feb 12 16:09:25 PST 2024


https://github.com/josh11b created https://github.com/llvm/llvm-project/pull/81556

Both creates a `BUILD.bazel` file for the `clangd` directory in the project overlay, and removes an unnecessary `#include "Feature.h"` to reduce the dependencies from `Transport.h`.

This upstreams the patch that allows https://github.com/carbon-language/carbon-lang/tree/trunk/language_server to use `clangd` as a library. This was created as part of a Summer of Code project building a prototype Carbon language server. If this is not an appropriate architecture, I'm very open to alternative paths forward.

Thanks!

>From 25c2f4f22adda315205f12c5d62dbc839395c9c3 Mon Sep 17 00:00:00 2001
From: Josh L <josh11b at users.noreply.github.com>
Date: Mon, 12 Feb 2024 22:59:21 +0000
Subject: [PATCH] Add bazel support for clangd as a library.

---
 clang-tools-extra/clangd/Transport.h          |  1 -
 .../clang-tools-extra/clangd/BUILD.bazel      | 45 +++++++++++++++++++
 2 files changed, 45 insertions(+), 1 deletion(-)
 create mode 100644 utils/bazel/llvm-project-overlay/clang-tools-extra/clangd/BUILD.bazel

diff --git a/clang-tools-extra/clangd/Transport.h b/clang-tools-extra/clangd/Transport.h
index 4e80ea95b8537d..f17441cfc1ef22 100644
--- a/clang-tools-extra/clangd/Transport.h
+++ b/clang-tools-extra/clangd/Transport.h
@@ -18,7 +18,6 @@
 #ifndef LLVM_CLANG_TOOLS_EXTRA_CLANGD_TRANSPORT_H
 #define LLVM_CLANG_TOOLS_EXTRA_CLANGD_TRANSPORT_H
 
-#include "Feature.h"
 #include "llvm/ADT/StringRef.h"
 #include "llvm/Support/JSON.h"
 #include "llvm/Support/raw_ostream.h"
diff --git a/utils/bazel/llvm-project-overlay/clang-tools-extra/clangd/BUILD.bazel b/utils/bazel/llvm-project-overlay/clang-tools-extra/clangd/BUILD.bazel
new file mode 100644
index 00000000000000..0e25dd1c166560
--- /dev/null
+++ b/utils/bazel/llvm-project-overlay/clang-tools-extra/clangd/BUILD.bazel
@@ -0,0 +1,45 @@
+# This file is licensed under the Apache License v2.0 with LLVM Exceptions.
+# See https://llvm.org/LICENSE.txt for license information.
+# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+
+package(default_visibility = ["//visibility:public"])
+
+licenses(["notice"])
+
+cc_library(
+    name = "clangd_library",
+    srcs = [
+        "JSONTransport.cpp",
+        "Protocol.cpp",
+        "URI.cpp",
+        "index/SymbolID.cpp",
+        "support/Logger.cpp",
+        "support/Trace.cpp",
+        "support/MemoryTree.cpp",
+        "support/Context.cpp",
+        "support/Cancellation.cpp",
+        "support/ThreadCrashReporter.cpp",
+        "support/Shutdown.cpp",
+    ],
+    hdrs = [
+        "Transport.h",
+        "Protocol.h",
+        "URI.h",
+        "LSPBinder.h",
+        "index/SymbolID.h",
+        "support/Function.h",
+        "support/Cancellation.h",
+        "support/ThreadCrashReporter.h",
+        "support/Logger.h",
+        "support/Trace.h",
+        "support/MemoryTree.h",
+        "support/Context.h",
+        "support/Shutdown.h",
+    ],
+    includes = ["."],
+    deps = [
+        "//llvm:Support",
+        "//clang:basic",
+        "//clang:index",
+    ],
+)



More information about the cfe-commits mailing list