mirror of
https://github.com/MaskRay/ccls.git
synced 2024-11-22 07:35:08 +00:00
Build: simplify
parent
c02a58c799
commit
67a2932b92
15
Build.md
15
Build.md
@ -224,21 +224,14 @@ ninja -C Release
|
|||||||
|
|
||||||
## Notes on compiling Clang+LLVM from source
|
## 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/`):
|
MaskRay's config (building trunk LLVM at `~/llvm/Release/`):
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
git clone https://git.llvm.org/git/llvm.git
|
git clone https://git.llvm.org/git/llvm.git
|
||||||
git clone https://git.llvm.org/git/clang.git llvm/tools/clang
|
git clone https://git.llvm.org/git/clang.git llvm/tools/clang
|
||||||
cd llvm
|
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
|
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
|
* 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:
|
`-DCMAKE_PREFIX_PATH=` is a `;`-separated list where you can find:
|
||||||
|
|
||||||
* `llvm`: llvm source
|
* `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`: 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`
|
* `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/include/llvm/Config/config.h
|
||||||
~/llvm/Release/tools/clang/include/clang/Config/config.h
|
~/llvm/Release/tools/clang/include/clang/Config/config.h
|
||||||
# libclangIndex.so
|
# libclangIndex.so
|
||||||
~/llvm/Release/lib/libclangIndex.so
|
~/llvm/Release/lib/libclangIndex.so or libclangIndex.a
|
||||||
# -resource-dir
|
# -resource-dir
|
||||||
~/llvm/Release/lib/clang/7.0.0
|
~/llvm/Release/lib/clang/7.0.0
|
||||||
# clang+llvm libraries
|
# clang+llvm libraries
|
||||||
~/llvm/Release/lib/libclangDriver.so
|
~/llvm/Release/lib/libclangDriver.so
|
||||||
~/llvm/Release/lib/libLLVMSupport.so
|
~/llvm/Release/lib/libLLVMSupport.so or libLLVMSupport.a
|
||||||
...
|
...
|
||||||
```
|
```
|
||||||
|
@ -89,30 +89,23 @@ ln -s $(buck targets --show-output :helloworld#compilation-database | cut -d ' '
|
|||||||
|
|
||||||
### stdout of an external command
|
### 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
|
ccls shell script wrapper:
|
||||||
# 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:
|
|
||||||
```zsh
|
```zsh
|
||||||
#!/bin/zsh
|
#!/bin/zsh
|
||||||
# mycompdb /tmp/c
|
/path/to/Release/ccls --init='{"compilationDatabaseCommand":"/tmp/c/x"}' "$@"
|
||||||
cat >> /tmp/initialization-options
|
|
||||||
cat <<e
|
|
||||||
[ { "arguments": [ "c++", "a.o", "a.cc" ],
|
|
||||||
"directory": "/tmp/c", "file": "a.cc" } ]
|
|
||||||
e
|
|
||||||
```
|
```
|
||||||
|
|
||||||
|
`/tmp/c/x`:
|
||||||
|
```zsh
|
||||||
|
#!/bin/zsh
|
||||||
|
# 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)):
|
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
|
```zsh
|
||||||
#!/usr/bin/env python3
|
#!/usr/bin/env python3
|
||||||
|
Loading…
Reference in New Issue
Block a user