Index: clang-tools-extra/trunk/clangd/CMakeLists.txt =================================================================== --- clang-tools-extra/trunk/clangd/CMakeLists.txt +++ clang-tools-extra/trunk/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: clang-tools-extra/trunk/clangd/ClangdMain.cpp =================================================================== --- clang-tools-extra/trunk/clangd/ClangdMain.cpp +++ clang-tools-extra/trunk/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: clang-tools-extra/trunk/clangd/tool/CMakeLists.txt =================================================================== --- clang-tools-extra/trunk/clangd/tool/CMakeLists.txt +++ clang-tools-extra/trunk/clangd/tool/CMakeLists.txt @@ -0,0 +1,18 @@ +include_directories(${CMAKE_CURRENT_SOURCE_DIR}/..) + +add_clang_executable(clangd + ClangdMain.cpp + ) + +install(TARGETS clangd RUNTIME DESTINATION bin) + +target_link_libraries(clangd + clangBasic + clangDaemon + clangFormat + clangFrontend + clangSema + clangTooling + clangToolingCore + LLVMSupport + ) Index: clang-tools-extra/trunk/clangd/tool/ClangdMain.cpp =================================================================== --- clang-tools-extra/trunk/clangd/tool/ClangdMain.cpp +++ clang-tools-extra/trunk/clangd/tool/ClangdMain.cpp @@ -0,0 +1,40 @@ +//===--- 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); +}