From 08a6c0d73d2badedfbac3e80ecb52a230d953356 Mon Sep 17 00:00:00 2001 From: King_DuckZ Date: Tue, 2 Aug 2016 02:11:05 +0200 Subject: [PATCH] Detect compiler to use. For example if you run the script from dindexer/clang_debug you will tell cmake to make a debug build using clang. You can also use gcc_debug but there is no way to specify a particular version. --- tools/cmake_default | 4 +++- tools/export_compile_commands | 20 +++++++++++++++++--- 2 files changed, 20 insertions(+), 4 deletions(-) diff --git a/tools/cmake_default b/tools/cmake_default index 6a31619..9d2edeb 100755 --- a/tools/cmake_default +++ b/tools/cmake_default @@ -10,4 +10,6 @@ exec "$script_path/export_compile_commands" \ -DDINDEXER_WITH_NICE_MEDIA_TYPES=OFF \ -DDINDEXER_NATIVE_RELEASE=ON \ -DDINDEXER_CXX11_ABI=OFF \ - -DDINDEXER_DB_OWNER_NAME=dindexer-user + -DDINDEXER_DB_OWNER_NAME=dindexer-user \ + -DDINDEXER_ENABLED_BACKENDS=redis,postgresql \ + -DDINDEXER_CONFIG_FILE=$(realpath --no-symlinks --canonicalize-missing $PWD/..)/dindexer.yml diff --git a/tools/export_compile_commands b/tools/export_compile_commands index 4dfb6f0..ebbee93 100755 --- a/tools/export_compile_commands +++ b/tools/export_compile_commands @@ -22,16 +22,30 @@ if [ -z "$project_path" ]; then exit 1 fi -config_name=$(pwd | sed -r "s_$build_dir/$project_name/([^/]+).*\$_\1_") +config_name=$(pwd | sed -r "s@$build_dir/$project_name/([^/_]+_)?([^/]+).*\$@\2@") +compiler_name=$(pwd | sed -r "s@$build_dir/$project_name/([^/_]+_)?([^/]+).*\$@\1@") +compiler_option="" +if [ -n "$compiler_name" ]; then + compiler_name="${compiler_name%?}" + case "$compiler_name" in + "clang") + compiler_option="CXX=clang++ CC=clang" + ;; + "gcc") + compiler_option="CXX=g++ CC=gcc" + ;; + esac +fi + 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" +eval $compiler_option cmake -DCMAKE_EXPORT_COMPILE_COMMANDS=ON "$config_option" $@ "$project_path" -if [ -f "$project_path/$json_file" ]; then +if [ -h "$project_path/$json_file" ]; then unlink "$project_path/$json_file" fi work_dir="$PWD"