Add compilation database file fooor clang-tidy
This commit is contained in:
parent
99ef9d3111
commit
60f22dbd7f
1 changed files with 61 additions and 18 deletions
77
nb_create.sh
77
nb_create.sh
|
|
@ -59,9 +59,38 @@ EOF
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if_no_dir_then_exit()
|
||||||
|
{
|
||||||
|
exist_dir=$1
|
||||||
|
message=$2
|
||||||
|
|
||||||
|
if [ ! -d $exist_dir ]; then
|
||||||
|
echo "ERROR: Can't find: "$exist_dir
|
||||||
|
echo " $message"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if_no_file_then_exit()
|
||||||
|
{
|
||||||
|
exist_file=$1
|
||||||
|
message=$2
|
||||||
|
|
||||||
|
if [ ! -f $exist_file ]; then
|
||||||
|
echo "ERROR: Can't find: "$exist_file
|
||||||
|
echo " $message"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
main()
|
main()
|
||||||
{
|
{
|
||||||
#OPT_DEBUG=False # By default, debugging is off
|
OPT_DEBUG=False # By default, debugging is off
|
||||||
|
|
||||||
OPT_ALL="$(getopt -o dhm:p:r: -l debug,help,main:,project:,repo: --name "$0" -- "$@")"
|
OPT_ALL="$(getopt -o dhm:p:r: -l debug,help,main:,project:,repo: --name "$0" -- "$@")"
|
||||||
eval set -- "$OPT_ALL"
|
eval set -- "$OPT_ALL"
|
||||||
|
|
@ -146,26 +175,40 @@ main()
|
||||||
|
|
||||||
echo "Checking out repo..."
|
echo "Checking out repo..."
|
||||||
cd $pwd
|
cd $pwd
|
||||||
$(git clone $REPO .)
|
# $(git clone $REPO .)
|
||||||
|
|
||||||
if [ ! -d $pwd/nbproject ]; then
|
if_no_dir_then_exit $pwd/nbproject "Not a NetBeans project"
|
||||||
echo "ERROR: Not a NetBeans project"
|
if_no_file_then_exit $pwd/nbproject/project.xml "Netbeans project without a configuration file!"
|
||||||
echo " Can't find: "$pwd"/nbproject"
|
|
||||||
exit 1
|
|
||||||
fi
|
if [ ! -f "compile_commands.json" ]; then
|
||||||
if [ ! -f $pwd/nbproject/project.xml ]; then
|
echo "WARNING: ./compile_commands.json not found"
|
||||||
echo "ERROR: Missing ./nbproject/project.xml"
|
echo " Netbeans project without a compilation database"
|
||||||
echo " Netbeans project without a configuration file!"
|
echo " Target check2 will not work"
|
||||||
exit 1
|
echo " Generate compilation database: bear -- make"
|
||||||
|
else
|
||||||
|
replace="directory"
|
||||||
|
replacement="$pwd"
|
||||||
|
sed -i "s%^\s*\"$replace\"\:.*%\"directory\"\:\ \"$replacement\"\,%g" compile_commands.json
|
||||||
|
|
||||||
|
replace="file"
|
||||||
|
replacement="$pwd""/src/${MAIN}.cpp"
|
||||||
|
sed -i "s%^\s*\"$replace\"\:.*%\"file\"\:\ \"$replacement\"\,%g" compile_commands.json
|
||||||
|
|
||||||
|
replace="output"
|
||||||
|
replacement="$pwd""/obj/${MAIN}.obj"
|
||||||
|
sed -i "s%^\s*\"$replace\"\:.*%\"output\"\:\ \"$replacement\"\,%g" compile_commands.json
|
||||||
fi
|
fi
|
||||||
|
|
||||||
cd $pwd/nbproject
|
|
||||||
sed -i -e "s/\(<name>\).*\(<\/name>\)/<name>$PROJECT<\/name>/g" project.xml
|
|
||||||
|
|
||||||
cd "$pwd"/src
|
exit 0
|
||||||
if [ -f ./myapp.cpp ]; then
|
# cd $pwd/nbproject
|
||||||
mv myapp.cpp "$MAIN".cpp
|
# sed -i -e "s/\(<name>\).*\(<\/name>\(/<name>$PROJECT<\/name>/g" project.xml
|
||||||
fi
|
#
|
||||||
|
# cd "$pwd"/src
|
||||||
|
# if [ -f ./myapp.cpp ]; then
|
||||||
|
# mv myapp.cpp "$MAIN".cpp
|
||||||
|
# fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue