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

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

View File

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