Варианты сборки

This commit is contained in:
Andrei Astafev 2019-05-21 10:48:00 +03:00
parent 4c57e48a3d
commit a9d38e1ca6
2 changed files with 39 additions and 82 deletions

119
cmake.sh
View File

@ -24,14 +24,8 @@ eval set -- "$PARSED"
[ -x "$(command -v make)" ] && GENERATOR="Unix Makefiles"
[ -x "$(command -v ninja)" ] && GENERATOR=Ninja
# Generate single build type
SINGLE_TYPE="n"
# Generate QtCreator build types
QTCREATOR="n"
# Generate CMake build types
CMAKE="n"
# Build types list separated with comma
TYPES="Release"
# Force destructive actions
FORCE="n"
@ -51,18 +45,10 @@ while true; do
GENERATOR="$2"
shift 2
;;
-t|--type)
SINGLE_TYPE="$2"
-t|--types)
TYPES="$2"
shift 2
;;
-q|--qtcreator)
QTCREATOR="y"
shift
;;
-c|--cmake)
CMAKE="y"
shift
;;
-f|--force)
FORCE="y"
shift
@ -84,7 +70,7 @@ while true; do
break
;;
*)
echo "Programming error"
echo "Wrong argument is set"
exit 3
;;
esac
@ -100,62 +86,37 @@ CMAKE_ARGS=""
[ ! -f "${SOURCE_DIR}/CMakeLists.txt" ] && { echo "Source directory does not contain CMakeLists.txt"; exit 4; }
if [ "x${SINGLE_TYPE}" != "xn" ]; then
case "${SINGLE_TYPE}" in
None|Debug|Release|Profile|RelWithDebInfo|MinSizeRel)
true
;;
*)
echo "Wrong CMake build type"
exit 6
;;
esac
fi
export CMAKE
export QTCREATOR
export GENERATOR
export SOURCE_DIR
export BUILD_DIR
export OUTPUT_DIR
export CMAKE_ARGS
export SINGLE_TYPE
export FORCE
CMAKE_BUILD_TYPES=(None Debug Release Profile RelWithDebInfo MinSizeRel)
QTCREATOR_BUILD_TYPES=(qtNone qtDebug qtRelease qtProfile)
generate_configuration() {
local BUILD_TYPE="${!#}"
local BUILD="$BUILD_TYPE"
if [ "x$QTCREATOR" == "xy" ]; then
case "$BUILD_TYPE" in
qtNone)
BUILD="unknown"
BUILD_TYPE="None"
;;
qtDebug)
BUILD="debug"
BUILD_TYPE="Debug"
;;
qtRelease)
BUILD="release"
BUILD_TYPE="Release"
;;
qtProfile)
BUILD="profile"
BUILD_TYPE="Profile"
;;
esac
fi
case "$BUILD_TYPE" in
qtNone)
BUILD="unknown"
BUILD_TYPE="None"
;;
qtDebug)
BUILD="debug"
BUILD_TYPE="Debug"
;;
qtRelease)
BUILD="release"
BUILD_TYPE="Release"
;;
qtProfile)
BUILD="profile"
BUILD_TYPE="Profile"
;;
esac
GEN_DIR="${BUILD_DIR}"
if [ "x${SINGLE_TYPE}" == "xn" ]; then
GEN_DIR="${BUILD_DIR}/${BUILD}"
else
GEN_DIR="${BUILD_DIR}/${SINGLE_TYPE}"
fi
GEN_DIR="${BUILD_DIR}/${BUILD}"
if [ -d "${GEN_DIR}" ]; then
if [ "x${FORCE}" == "xy" ]; then
@ -183,26 +144,22 @@ EOF
}
export -f generate_configuration
set -f
if [ "x$SINGLE_TYPE" != "xn" ]; then
BUILD_TYPES=("${SINGLE_TYPE}")
else
if [ "x$QTCREATOR" == "xy" ]; then
BUILD_TYPES=("${QTCREATOR_BUILD_TYPES[@]}")
elif [ "x$CMAKE" == "xy" ]; then
BUILD_TYPES=("${CMAKE_BUILD_TYPES[@]}")
else
BUILD_TYPES=("Release")
fi
fi
BUILD_TYPES=(${TYPES//,/ })
if [ ${#BUILD_TYPES[@]} -eq 0 ]; then
echo "No build type selected."
echo "Use -c for default CMake build types"
echo "Use -q for build types for QtCreator"
echo "Use -t name for build with type 'name'"
exit 0
fi
for i in "${!BUILD_TYPES[@]}"; do
case ${BUILD_TYPES[i]} in
None|Debug|Release|Profile|RelWithDebInfo|MinSizeRel|qtNone|qtDebug|qtRelease|qtProfile)
true
;;
*)
echo "Wrong CMake build type. Possible value are:"
echo "None,Debug,Release,Profile,RelWithDebInfo,MinSizeRel,qtNone,qtDebug,qtRelease,qtProfile"
exit 6
;;
esac
done
# Try to work in parallel
if [ -x "$(command -v parallel)" ]; then

View File

@ -2,5 +2,5 @@
PROJECT=$(grep -i "^Project" "$(dirname -- "$(dirname -- "$(pwd)")")/CMakeLists.txt" | awk -F'[()]' '{print $2}')
"$(dirname $0)/cmake.sh" -f -t Debug
"$(dirname $0)/cmake.sh" -f -t qtDebug,qtRelease,Debug,Release