Created
February 20, 2014 13:44
-
-
Save shadone/9113883 to your computer and use it in GitHub Desktop.
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
commit 880b4e7b9509f2c1c1b25034ddaf706d5f23c769 | |
Author: Denis Dzyubenko <denis@ddenis.info> | |
Date: Thu Feb 20 14:44:39 2014 +0100 | |
Separated fake_compiler into C and CXX parts | |
Otherwise it doesn't work for projects mixing .c and .cpp files | |
diff --git a/scripts/fake_c b/scripts/fake_c | |
new file mode 120000 | |
index 0000000..c4053c6 | |
--- /dev/null | |
+++ b/scripts/fake_c | |
@@ -0,0 +1 @@ | |
+./fake_compiler.sh | |
\ No newline at end of file | |
diff --git a/scripts/fake_compiler.sh b/scripts/fake_compiler.sh | |
index 0d56686..3f32836 100755 | |
--- a/scripts/fake_compiler.sh | |
+++ b/scripts/fake_compiler.sh | |
@@ -1,4 +1,4 @@ | |
-#! /bin/sh | |
+#! /bin/bash | |
# | |
# This script can be used to generate the compile_commands.json file. | |
@@ -9,22 +9,32 @@ | |
# Example: | |
# | |
# export COMPILATION_COMMANDS=/path/to/compile_commands.json | |
-# export FORWARD_COMPILER=g++ | |
+# export FORWARD_COMPILER_C=gcc | |
+# export FORWARD_COMPILER_CXX=g++ | |
# CXX=/path/to/fake_compiler.sh ./configure | |
# echo "[" > $COMPILATION_COMMANDS | |
# make | |
# echo " { \"directory\": \".\", \"command\": \"true\", \"file\": \"/dev/null\" } ]" >> $COMPILATION_COMMANDS | |
+if [ -z $COMPILATION_COMMANDS ]; then | |
+ echo "Please set environment varible COMPILATION_COMMANDS" | |
+ exit 1; | |
+fi | |
directory=$PWD; | |
args=$@; | |
-file=`echo $args | sed 's/.* \([^ ]*\)/\1/'`; | |
+file=`echo $args | sed 's/.* \([^ ]*\)/\1/'`; | |
new_file=`cd $directory && readlink -f $file 2>/dev/null | xargs echo -n`; | |
args=`echo $args | sed "s, -I\.\./, -I$directory/../,g" | sed "s, -I\. , -I$directory ,g" | sed "s, -I\./, -I$directory,g" | sed "s, -I\(/]\), -I$directory/\1,g" | sed 's,\\\\,\\\\\\\\,g' | sed 's | |
echo "{ \"directory\": \"$directory\", \"command\": \"c++ $args\", \"file\": \"$new_file\" } , " >> $COMPILATION_COMMANDS; | |
-if [ -z $FORWARD_COMPILER ]; then | |
- true | |
+FORWARD_COMPILER_C=${FORWARD_COMPILER_C:-true} | |
+FORWARD_COMPILER_CXX=${FORWARD_COMPILER_CXX:-true} | |
+ | |
+compiler=`basename $0` | |
+if [ "$compiler" == "fake_cxx" ]; then | |
+ $FORWARD_COMPILER_CXX $@ | |
else | |
- $FORWARD_COMPILER $@ | |
+ $FORWARD_COMPILER_C $@ | |
fi | |
+ | |
diff --git a/scripts/fake_cxx b/scripts/fake_cxx | |
new file mode 120000 | |
index 0000000..c4053c6 | |
--- /dev/null | |
+++ b/scripts/fake_cxx | |
@@ -0,0 +1 @@ | |
+./fake_compiler.sh | |
\ No newline at end of file |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment