스크립트파일

git-svn-id: svn://192.168.0.12/source@336 8346c931-da38-4b9b-9d4c-e48b93cbd075
This commit is contained in:
admin
2017-01-06 10:23:35 +00:00
parent 40f29bdf51
commit 80224e09b1
4 changed files with 611 additions and 0 deletions

155
compile.sh Normal file
View File

@@ -0,0 +1,155 @@
#!/bin/bash
WORKING_DIRECTORY=$(pwd)
PATH_SOURCE="$WORKING_DIRECTORY/source"
PATH_COMPILE_PREFIX="$PATH_SOURCE/build-"
PATH_COMPILE_SUFFIX="-Desktop_Qt_5_4_0_GCC_64bit-Release"
QT_QMAKE_PATH="/home/testdb/Qt5.4.0/5.4/gcc_64/bin"
QMAKE="$QT_QMAKE_PATH/qmake"
MAKE_CLEAN=
usage()
{
echo "Usage : compile.sh [options] directory1 [directory2...]"
echo ""
echo " -s, --source Set Qt Project parent directory"
echo " -o, --output Copy executable files to specific directory"
echo " -c, --clean make clean"
echo " -h, --help help"
echo ""
echo "Purpose : compile a Qt project in source/directory1"
}
PATH_OUTPUT=
qtcompile()
{
echo "$1 : "
if [ ! -d "$PATH_SOURCE" ]; then
echo "Fatal Error : Source path does not exists"
echo "Quit compile"
exit 1
fi
if [ ! -d "$PATH_SOURCE/$1" ]; then
echo "Error : Project directory $PATH_SOURCE/$1 does not exists"
return 1
fi
path_source="$PATH_SOURCE/$1/$1"".pro"
if [ ! -f "$path_source" ]; then
echo "Error : Project file $path_source does not exists"
return 1
fi
path_compile="$PATH_COMPILE_PREFIX""$1""$PATH_COMPILE_SUFFIX"
if [ ! -d "$path_compile" ]; then
mkdir $path_compile
fi
if ! cd $path_compile; then
echo "Error : Cannot access $path_compile"
return 1
fi
if [ -n "$MAKE_CLEAN" ]; then
if "$QMAKE" "$path_source" "-r" "-spec" "linux-g++" && "/usr/bin/make" "clean" 1>&/dev/null && "/usr/bin/make" 1>&/dev/null ; then
echo "Success : Make Clean $path_compile"
echo "Success : Compile complete $path_source"
echo "Success : Create File in $path_compile"
else
echo "Error : Compile error - $path_source"
return 1
fi
else
if "$QMAKE" "$path_source" "-r" "-spec" "linux-g++" && "/usr/bin/make" 1>&/dev/null ; then
echo "Success : Compile complete $path_source"
echo "Success : Create File in $path_compile"
else
echo "Error : Compile error - $path_source"
return 1
fi
fi
if [ -n "$PATH_OUTPUT" ]; then
if ! cp "$path_compile/$1" "$PATH_OUTPUT/"; then
echo "Error : Copy error $path_compile/$1 to $PATH_OUTPUT/"
return 1
else
echo "Success : Copy $path_compile/$1 to $PATH_OUTPUT/"
fi
fi
echo ""
return 0
}
if [ $# -eq 0 ]; then
usage
exit 1
fi
#basename
#dirname
while [ "$1" != "" ]; do
case $1 in
-s | --source ) shift
path_source="$(dirname $1)"
if [[ $path_source =~ ^/([^/]+) ]]; then
PATH_SOURCE="$path_source"
elif [ "$path_source" = "." ]; then
PATH_SOURCE="$WORKING_DIRECTORY/$1"
else
PATH_SOURCE="$WORKING_DIRECTORY/$path_source"
fi
;;
-o | --ouput ) shift
if [[ $1 =~ ^/([^/]+) ]]; then
PATH_OUTPUT="$1"
else
PATH_OUTPUT="$WORKING_DIRECTORY/$1"
fi
;;
-c | --clean ) MAKE_CLEAN="clean"
;;
-h | --help ) usage
exit
;;
-* | --* ) echo "Error : Unknown Option $1"
echo " Please check option"
usage
exit 1
;;
* ) dir_name=$(dirname $1)
arg=$(basename $1)
if [ ! "$dir_name" = "." ]; then
path_source="$dir_name"
if [[ $path_source =~ ^/([^/]+) ]]; then
PATH_SOURCE="$path_source"
else
PATH_SOURCE="$WORKING_DIRECTORY/$path_source"
fi
fi
qtcompile $arg
;;
esac
shift
done
exit