Index: clangd/CMakeLists.txt =================================================================== --- clangd/CMakeLists.txt +++ clangd/CMakeLists.txt @@ -1,6 +1,5 @@ -add_clang_executable(clangd +add_clang_library(clangDaemon ClangdLSPServer.cpp - ClangdMain.cpp ClangdServer.cpp ClangdUnit.cpp ClangdUnitStore.cpp @@ -11,9 +10,7 @@ ProtocolHandlers.cpp ) -install(TARGETS clangd RUNTIME DESTINATION bin) - -target_link_libraries(clangd +target_link_libraries(clangDaemon clangBasic clangFormat clangFrontend @@ -22,3 +19,5 @@ clangToolingCore LLVMSupport ) + +add_subdirectory(tool) Index: clangd/ClangdMain.cpp =================================================================== --- /dev/null +++ clangd/ClangdMain.cpp @@ -1,40 +0,0 @@ -//===--- ClangdMain.cpp - clangd server loop ------------------------------===// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -#include "ClangdLSPServer.h" -#include "JSONRPCDispatcher.h" -#include "llvm/Support/CommandLine.h" -#include "llvm/Support/FileSystem.h" -#include "llvm/Support/Program.h" - -#include -#include -#include - -using namespace clang; -using namespace clang::clangd; - -static llvm::cl::opt - RunSynchronously("run-synchronously", - llvm::cl::desc("parse on main thread"), - llvm::cl::init(false), llvm::cl::Hidden); - -int main(int argc, char *argv[]) { - llvm::cl::ParseCommandLineOptions(argc, argv, "clangd"); - - llvm::raw_ostream &Outs = llvm::outs(); - llvm::raw_ostream &Logs = llvm::errs(); - JSONOutput Out(Outs, Logs); - - // Change stdin to binary to not lose \r\n on windows. - llvm::sys::ChangeStdinToBinary(); - - ClangdLSPServer LSPServer(Out, RunSynchronously); - LSPServer.run(std::cin); -} Index: clangd/tool/CMakeLists.txt =================================================================== --- clangd/tool/CMakeLists.txt +++ clangd/tool/CMakeLists.txt @@ -1,20 +1,14 @@ +include_directories(${CMAKE_CURRENT_SOURCE_DIR}/..) + add_clang_executable(clangd - ClangdLSPServer.cpp ClangdMain.cpp - ClangdServer.cpp - ClangdUnit.cpp - ClangdUnitStore.cpp - DraftStore.cpp - GlobalCompilationDatabase.cpp - JSONRPCDispatcher.cpp - Protocol.cpp - ProtocolHandlers.cpp ) install(TARGETS clangd RUNTIME DESTINATION bin) target_link_libraries(clangd clangBasic + clangDaemon clangFormat clangFrontend clangSema