llvm/utils/bazel/llvm-project-overlay/clang-tools-extra/clangd/BUILD.bazel

# 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"],
    features = ["layering_check"],
)

licenses(["notice"])

# TODO: this is a shim to provide Features.inc as needed by Feature.h.
# Replace this with something that parses Features.inc.in.
genrule(
    name = "gen_features_inc",
    outs = ["Features.inc"],
    cmd = "\n".join([
        "echo '// IWYU pragma: private, include \"Feature.h\"' >> $@",
        "echo '#define CLANGD_BUILD_XPC 0' >> $@",
        "echo '#define CLANGD_ENABLE_REMOTE 1' >> $@",
        "echo '#define ENABLE_GRPC_REFLECTION 0' >> $@",
        "echo '#define CLANGD_MALLOC_TRIM 0' >> $@",
        "echo '#define CLANGD_TIDY_CHECKS 1' >> $@",
        "echo '#define CLANGD_DECISION_FOREST 1' >> $@",
    ]),
)

# TODO: Pick up other files for more complete functionality, to match
# clangd/CMakeLists.txt. This might look something like
# glob(["*.cpp", "dir/**/*.cpp", ...]).
cc_library(
    name = "ClangDaemon",
    srcs = [
        "Feature.cpp",
        "Features.inc",
        "JSONTransport.cpp",
        "Protocol.cpp",
        "URI.cpp",
        "index/SymbolID.cpp",
        "support/Cancellation.cpp",
        "support/Context.cpp",
        "support/Logger.cpp",
        "support/MemoryTree.cpp",
        "support/Shutdown.cpp",
        "support/ThreadCrashReporter.cpp",
        "support/Trace.cpp",
    ],
    hdrs = [
        "Feature.h",
        "LSPBinder.h",
        "Protocol.h",
        "Transport.h",
        "URI.h",
        "index/SymbolID.h",
        "support/Cancellation.h",
        "support/Context.h",
        "support/Function.h",
        "support/Logger.h",
        "support/MemoryTree.h",
        "support/Shutdown.h",
        "support/ThreadCrashReporter.h",
        "support/Trace.h",
    ],
    includes = ["."],
    deps = [
        "//clang:basic",
        "//clang:index",
        "//llvm:Support",
        "//llvm:TargetParser",
        "//llvm:config",
    ],
)