From 67a2932b922403ce98b5c319a4abb4ba687d66f2 Mon Sep 17 00:00:00 2001 From: Fangrui Song Date: Wed, 23 Jan 2019 22:26:12 +0800 Subject: [PATCH] Build: simplify --- Build.md | 15 ++++----------- Project-Setup.md | 31 ++++++++++++------------------- 2 files changed, 16 insertions(+), 30 deletions(-) diff --git a/Build.md b/Build.md index 8c6e4da..829ee15 100644 --- a/Build.md +++ b/Build.md @@ -224,21 +224,14 @@ ninja -C Release ## Notes on compiling Clang+LLVM from source -* `include/llvm/Config/config.h` -* `include/clang/Config/config.h` -* `lib/libclangIndex.so` -* `lib/libLLVM{Support,...}.so` or `lib/libLLVM{Support,...}.a` or - `lib/libLLVM.so` - MaskRay's config (building trunk LLVM at `~/llvm/Release/`): ```sh git clone https://git.llvm.org/git/llvm.git git clone https://git.llvm.org/git/clang.git llvm/tools/clang cd llvm -# create a build directory named `Release/` cmake -H. -BRelease -G Ninja -DCMAKE_BUILD_TYPE=Release -DBUILD_SHARED_LIBS=ON -DLLVM_ENABLE_LLD=ON -DLLVM_TARGETS_TO_BUILD=X86 -ninja -C Release clangFormat clangFrontendTool clangIndex clangTooling +ninja -C Release clang clangFormat clangFrontendTool clangIndex clangTooling cxx ``` * Remove `LLVM_ENABLE_LLD` if you don't have lld (a much faster linker than bfd/gold) installed @@ -255,7 +248,7 @@ ninja -C Release `-DCMAKE_PREFIX_PATH=` is a `;`-separated list where you can find: * `llvm`: llvm source -* `llvm/tools/clang`: clang source (`git clone https://git.llvm.org/git/clang.git`) +* `llvm/tools/clang`: clang source * `llvm/Release`: build directory. `include/` contains generated llvm header files, e.g. `include/llvm/Config/config.h` * `llvm/Release/tools/clang`: build directory. `include/` contains generated clang header files, e.g. `include/clang/Config/config.h` @@ -266,11 +259,11 @@ The cmake build system is expected to find these files: ~/llvm/Release/include/llvm/Config/config.h ~/llvm/Release/tools/clang/include/clang/Config/config.h # libclangIndex.so -~/llvm/Release/lib/libclangIndex.so +~/llvm/Release/lib/libclangIndex.so or libclangIndex.a # -resource-dir ~/llvm/Release/lib/clang/7.0.0 # clang+llvm libraries ~/llvm/Release/lib/libclangDriver.so -~/llvm/Release/lib/libLLVMSupport.so +~/llvm/Release/lib/libLLVMSupport.so or libLLVMSupport.a ... ``` diff --git a/Project-Setup.md b/Project-Setup.md index 893dab2..94579db 100644 --- a/Project-Setup.md +++ b/Project-Setup.md @@ -89,30 +89,23 @@ ln -s $(buck targets --show-output :helloworld#compilation-database | cut -d ' ' ### stdout of an external command -You may use the initialization option `"compilationDatabaseCommand"` to provide the JSON compilation database. ccls will read its stdout rather than read `compile_commands.json`. This may be useful when ccls cannot parse the `compile_commands.json` correctly (e.g. MSVC cl.exe, Intel C++ Compiler options) +If the initialization option `"compilationDatabaseCommand"` is set, the command will be executed by ccls to provide the JSON compilation database. ccls will read its stdout rather than read `compile_commands.json`. This may be useful when ccls cannot parse the `compile_commands.json` correctly (e.g. MSVC cl.exe, Intel C++ Compiler options) -```sh -# extra command line option -'--init={"compilationDatabaseCommand":"mycompdb"}' -``` - -```elisp -(setq ccls-initialization-options '(:compilationDatabaseCommand "mycompdb")) -``` - -Suppose the project is at `/tmp/c`, `mycompdb /tmp/c` will be executed with stdin=initializationOptions and the stdout should be a JSON compilation database. - -You may use this shell script as a starting point: +ccls shell script wrapper: ```zsh #!/bin/zsh -# mycompdb /tmp/c -cat >> /tmp/initialization-options -cat <> /tmp/initialization-options # stdin is initialization options +print '[{"arguments":["c++","-c","a.cc"],"directory":"/tmp/c","file":"a.cc"}]' +``` + +Suppose the project is at `/tmp/c`, `/tmp/c/x /tmp/c` will be executed with stdin=initializationOptions and the stdout should be a JSON compilation database. + An example to scrub Intel C++ Compiler options (or, even easier, check out `clang.excludeArgs` in the [Initialization options](https://github.com/MaskRay/ccls/wiki/Initialization-options)): ```zsh #!/usr/bin/env python3