mirror of
https://github.com/KingDuckZ/dindexer.git
synced 2024-11-25 00:53:43 +00:00
Add helper scripts for wrapping cmake invocation
export_compile_commands assumes you have your working copy in $HOME/dev/code/dindexer and you are running it from your build directory, which is in something like $HOME/dev/build/dindexer/<config> It will then invoke cmake with CMAKE_EXPORT_COMPILE_COMMANDS ON for YouCompleteMe to work. The exported .json file is automatically symlinked into your working copy. Any previous symlink or file is deleted from your working copy first, so if you run this script for Release and then for Debug, the appropriate symlink to Debug will be in your working tree. cmake_default simply wraps export_compile_commands passing default cmake values I normally like to use.
This commit is contained in:
parent
ec8e451481
commit
a10982533e
2 changed files with 51 additions and 0 deletions
13
tools/cmake_default
Executable file
13
tools/cmake_default
Executable file
|
@ -0,0 +1,13 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
#see: http://stackoverflow.com/questions/59895/can-a-bash-script-tell-which-directory-it-is-stored-in
|
||||
script_path="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
||||
|
||||
exec "$script_path/export_compile_commands" \
|
||||
-DBUILD_TESTING=ON \
|
||||
-DPBL_WITH_TESTS=OFF \
|
||||
-DDINDEXER_WITH_BUILD_DATE=ON \
|
||||
-DDINDEXER_WITH_NICE_MEDIA_TYPES=OFF \
|
||||
-DDINDEXER_NATIVE_RELEASE=ON \
|
||||
-DDINDEXER_CXX11_ABI=OFF \
|
||||
-DDINDEXER_DB_OWNER_NAME=dindexer-user
|
38
tools/export_compile_commands
Executable file
38
tools/export_compile_commands
Executable file
|
@ -0,0 +1,38 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
code_dirs[0]="$HOME/dev/code/cpp"
|
||||
code_dirs[1]="$HOME/dev/code"
|
||||
|
||||
build_dir="$HOME/dev/build"
|
||||
|
||||
json_file="compile_commands.json"
|
||||
|
||||
project_name=$(pwd | sed -r "s_$build_dir/([^/]+).*\$_\1_")
|
||||
project_path=""
|
||||
for z in "${code_dirs[@]}"
|
||||
do
|
||||
if [ -d "$z/$project_name" ]; then
|
||||
project_path="$z/$project_name"
|
||||
break;
|
||||
fi
|
||||
done
|
||||
|
||||
if [ -z "$project_path" ]; then
|
||||
>&2 echo "Project \"$project_name\" not found in any of the search paths"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
config_name=$(pwd | sed -r "s_$build_dir/$project_name/([^/]+).*\$_\1_")
|
||||
config_option=""
|
||||
if [ -n "$config_name" ]; then
|
||||
config_name="$(tr '[:lower:]' '[:upper:]' <<< ${config_name:0:1})${config_name:1}"
|
||||
config_option="-DCMAKE_BUILD_TYPE=$config_name"
|
||||
fi
|
||||
|
||||
cmake -DCMAKE_EXPORT_COMPILE_COMMANDS=ON "$config_option" $@ "$project_path"
|
||||
|
||||
if [ -f "$project_path/$json_file" ]; then
|
||||
unlink "$project_path/$json_file"
|
||||
fi
|
||||
work_dir="$PWD"
|
||||
(cd "$project_path" && ln -s "$work_dir/$json_file")
|
Loading…
Reference in a new issue