mirror of
https://github.com/MaskRay/ccls.git
synced 2024-11-22 07:35:08 +00:00
Add Example-Projects.md
parent
4e4477347f
commit
105f9fc648
64
Example-Projects.md
Normal file
64
Example-Projects.md
Normal file
@ -0,0 +1,64 @@
|
||||
## Linux kernel
|
||||
|
||||
defconfig
|
||||
|
||||
```sh
|
||||
# Use clang 9 or newer.
|
||||
make O=out.x86_64 CC=/path/to/clang defconfig
|
||||
make O=out.x86_64 CC=/path/to/clang # generate .<target>.cmd files
|
||||
scripts/gen_compile_commands.py -d out.x86_64
|
||||
ln -s out.x86_64/compile_commands.json
|
||||
```
|
||||
|
||||
<small>2019-11-09: ARCH=x86_64 defconfig => 1.4G .ccls-cache</small>
|
||||
|
||||
Arch Linux:
|
||||
|
||||
```sh
|
||||
mkdir out
|
||||
wget 'https://git.archlinux.org/svntogit/packages.git/plain/trunk/config?h=packages/linux' -O out/.config
|
||||
yes '' | make O=out config
|
||||
```
|
||||
|
||||
If CC=gcc, there may be some options that need filtering out:
|
||||
|
||||
```zsh
|
||||
ccls -index ~/Dev/Linux -init='{"clang":{"excludeArgs":[
|
||||
"-falign-jumps=1","-falign-loops=1","-fconserve-stack","-fmerge-constants","-fno-code-hoisting","-fno-schedule-insns","-fno-sched-pressure","-fno-var-tracking-assignments","-fsched-pressure",
|
||||
"-mhard-float","-mindirect-branch-register","-mindirect-branch=thunk-inline","-mpreferred-stack-boundary=2","-mpreferred-stack-boundary=3","-mpreferred-stack-boundary=4","-mrecord-mcount","-mindirect-branch=thunk-extern","-mno-fp-ret-in-387","-mskip-rax-setup",
|
||||
"--param=allow-store-data-races=0","-Wa,arch/x86/kernel/macros.s","-Wa,-"
|
||||
], "extraArgs":["--gcc-toolchain=/usr"]}}'
|
||||
```
|
||||
|
||||
### LLVM
|
||||
|
||||
```sh
|
||||
git clone https://github.com/llvm/llvm-project.git
|
||||
cd llvm-project
|
||||
cmake -Hllvm -BDebug -GNinja -DCMAKE_BUILD_TYPE=Debug -DCMAKE_EXPORT_COMPILE_COMMANDS=On -DLLVM_ENABLE_PROJECTS='clang;clang-tools-extra;lld' <other options>
|
||||
ln -s Debug/compile_commands.json
|
||||
```
|
||||
|
||||
You can filter out some files to speed up indexing. Example initialization options:
|
||||
```javascript
|
||||
{"index":{"initialBlacklist":["/(clang|lld|llvm)/(test|unittests)/", "/llvm/(bindings|examples|utils)/", "/StaticAnalyzer/"]}}
|
||||
```
|
||||
|
||||
### musl
|
||||
|
||||
```zsh
|
||||
mkdir Debug; cd Debug
|
||||
../configure --enable-optimize=no --enable-debug --prefix=~/.local/stow/musl
|
||||
bear make -j
|
||||
cd ..; ln -s Debug/compile_commands.json
|
||||
```
|
||||
|
||||
### ruby
|
||||
|
||||
```zsh
|
||||
autoreconf
|
||||
mkdir Debug; cd Debug
|
||||
../configure --prefix=/tmp/opt
|
||||
bear make -j main
|
||||
cd ..; ln -s Debug/compile_commands.json
|
||||
```
|
@ -246,74 +246,3 @@ armv7-linux-gnueabi
|
||||
-U__clang__
|
||||
-isystem../Config/exec/arm/inc/c
|
||||
```
|
||||
|
||||
## `compile_commands.json` examples
|
||||
|
||||
### Linux kernel
|
||||
|
||||
```zsh
|
||||
wget 'https://git.archlinux.org/svntogit/packages.git/plain/trunk/config?h=packages/linux' -O .config
|
||||
yes '' | make config
|
||||
bear make -j bzImage modules
|
||||
```
|
||||
|
||||
```zsh
|
||||
ccls -index ~/Dev/Linux -init='{"clang":{"excludeArgs":[
|
||||
"-falign-jumps=1","-falign-loops=1","-fconserve-stack","-fmerge-constants","-fno-code-hoisting","-fno-schedule-insns","-fno-sched-pressure","-fno-var-tracking-assignments","-fsched-pressure",
|
||||
"-mhard-float","-mindirect-branch-register","-mindirect-branch=thunk-inline","-mpreferred-stack-boundary=2","-mpreferred-stack-boundary=3","-mpreferred-stack-boundary=4","-mrecord-mcount","-mindirect-branch=thunk-extern","-mno-fp-ret-in-387","-mskip-rax-setup",
|
||||
"--param=allow-store-data-races=0","-Wa,arch/x86/kernel/macros.s","-Wa,-"
|
||||
], "extraArgs":["--gcc-toolchain=/usr"]}}'
|
||||
```
|
||||
|
||||
### LLVM multirepo
|
||||
|
||||
```zsh
|
||||
git clone https://git.llvm.org/git/llvm.git
|
||||
cd llvm
|
||||
git clone https://git.llvm.org/git/clang.git tools/clang
|
||||
git clone https://git.llvm.org/git/lldb.git tools/lldb
|
||||
git clone https://git.llvm.org/git/lld.git projects/lld
|
||||
git clone https://git.llvm.org/git/compiler-rt.git projects/compiler-rt
|
||||
git clone https://git.llvm.org/git/libcxx.git projects/libcxx
|
||||
git clone https://git.llvm.org/git/libcxxabi.git projects/libcxxabi
|
||||
|
||||
# cmake -H. -BDebug -GNinja -DCMAKE_BUILD_TYPE=Debug -DCMAKE_EXPORT_COMPILE_COMMANDS=On <other options>
|
||||
ln -s Debug/compile_commands.json
|
||||
|
||||
# Let clients know llvm/ is the project root, llvm/tools/clang etc are not.
|
||||
# emacs-ccls knows this file but other clients may require manual configuration.
|
||||
touch .ccls-root
|
||||
```
|
||||
|
||||
You can filter out some files to speed up indexing. Example initialization options:
|
||||
```javascript
|
||||
{"index":{"initialBlacklist":["/(clang|lld|llvm)/(test|unittests)/", "/llvm/(bindings|examples|utils)/", "/StaticAnalyzer/"]}}
|
||||
```
|
||||
|
||||
### LLVM monorepo
|
||||
|
||||
```zsh
|
||||
git clone git@github.com:llvm/llvm-project.git
|
||||
|
||||
# cmake -Hllvm -BDebug -GNinja -DCMAKE_BUILD_TYPE=Debug -DCMAKE_EXPORT_COMPILE_COMMANDS=On -DLLVM_ENABLE_PROJECTS='llvm;clang' <other options>
|
||||
ln -s llvm/compile_commands.json
|
||||
```
|
||||
|
||||
### musl
|
||||
|
||||
```zsh
|
||||
mkdir Debug; cd Debug
|
||||
../configure --enable-optimize=no --enable-debug --prefix=~/.local/stow/musl
|
||||
bear make -j
|
||||
cd ..; ln -s Debug/compile_commands.json
|
||||
```
|
||||
|
||||
### ruby
|
||||
|
||||
```zsh
|
||||
autoreconf
|
||||
mkdir Debug; cd Debug
|
||||
../configure --prefix=/tmp/opt
|
||||
bear make -j main
|
||||
cd ..; ln -s Debug/compile_commands.json
|
||||
```
|
||||
|
@ -17,6 +17,7 @@
|
||||
- [[Visual Studio Code]]
|
||||
- [[Monaco Editor | https://github.com/MaskRay/ccls/wiki/Monaco-Editor]]
|
||||
* [[Project Setup]]
|
||||
- [[Example Projects]]
|
||||
* [[Customization]]
|
||||
* [[Debugging]]
|
||||
* [[FAQ]]
|
||||
|
Loading…
Reference in New Issue
Block a user