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

via cfe-commits cfe-commits at lists.llvm.org
Thu Mar 14 14:05:19 PDT 2024


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

>From e2b83f086e51d7144d8e6ac1d1850300de55f01f Mon Sep 17 00:00:00 2001
From: Josh L <github-llvm at technomagi.com>
Date: Mon, 12 Feb 2024 22:59:21 +0000
Subject: [PATCH 1/2] 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",
+    ],
+)

>From 9dc8c8e9196fa51a9f687fd6542dc8ca0de70173 Mon Sep 17 00:00:00 2001
From: Josh L <github-llvm at technomagi.com>
Date: Thu, 14 Mar 2024 21:02:52 +0000
Subject: [PATCH 2/2] Implement suggestions from review

---
 .../clang-tools-extra/clangd/BUILD.bazel                     | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

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
index 0e25dd1c166560..c1d24058e21a1d 100644
--- a/utils/bazel/llvm-project-overlay/clang-tools-extra/clangd/BUILD.bazel
+++ b/utils/bazel/llvm-project-overlay/clang-tools-extra/clangd/BUILD.bazel
@@ -2,12 +2,13 @@
 # See https://llvm.org/LICENSE.txt for license information.
 # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
 
-package(default_visibility = ["//visibility:public"])
+package(features = ["layering_check"],
+        default_visibility = ["//visibility:public"])
 
 licenses(["notice"])
 
 cc_library(
-    name = "clangd_library",
+    name = "clangDaemon",
     srcs = [
         "JSONTransport.cpp",
         "Protocol.cpp",



More information about the cfe-commits mailing list