Last active
March 22, 2019 17:35
-
-
Save MartyLake/9e83687a7c3507eddbd1839044401447 to your computer and use it in GitHub Desktop.
bootstrap script to generate compile_commands.json and clang complete on project that uses cmake and vim
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
" only use linters that uses compile_commands.json | |
let g:ale_linters.cpp = ['clangcheck', 'clangtidy', 'cppcheck'] | |
" various options for clang_complete | |
set concealcursor=inv | |
let g:clang_snippets = 1 | |
set completeopt=menu,longest | |
let g:clang_complete_optional_args_in_snippets = 1 | |
let g:clang_trailing_placeholder = 1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
set -euo #strict mode | |
#set -x #debug mode | |
CLANG_COMPLETE_DIR="build_native" | |
if [ ! -d $CLANG_COMPLETE_DIR ] | |
then | |
rm -rf $CLANG_COMPLETE_DIR | |
fi | |
mkdir -p $CLANG_COMPLETE_DIR | |
pushd $CLANG_COMPLETE_DIR | |
# Generate compile_commands file | |
cmake -DCMAKE_EXPORT_COMPILE_COMMANDS=ON .. | |
mv compile_commands.json .. | |
# Generate clang_complete file | |
# rm -rf ./* | |
# https://github.com/Rip-Rip/clang_complete/blob/master/doc/clang_complete.txt | |
# Optional since the clang_complete plugin knows how to use compile_commands.json now | |
# CCARGS=$HOME/.vim/bundle/clang_complete/bin/cc_args.py | |
# chmod a+x $CCARGS | |
# CXX="$CCARGS clang++" cmake .. | |
# make | |
# mv .clang_complete .. | |
popd | |
rm -rf $CLANG_COMPLETE_DIR | |
# Generate clean build dir | |
BUILD_DIR_NATIVE="build_native" | |
if [ ! -d $BUILD_DIR_NATIVE ] | |
then | |
mkdir -p $BUILD_DIR_NATIVE | |
fi | |
pushd $BUILD_DIR_NATIVE | |
cmake .. | |
popd |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment