From a9d38e1ca6d814eb968b542bdfbb222c8d85d8d3 Mon Sep 17 00:00:00 2001 From: Andrey Astafyev Date: Tue, 21 May 2019 10:48:00 +0300 Subject: [PATCH] =?UTF-8?q?=D0=92=D0=B0=D1=80=D0=B8=D0=B0=D0=BD=D1=82?= =?UTF-8?q?=D1=8B=20=D1=81=D0=B1=D0=BE=D1=80=D0=BA=D0=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- cmake.sh | 119 +++++++++++++++------------------------------ qtcreator-debug.sh | 2 +- 2 files changed, 39 insertions(+), 82 deletions(-) diff --git a/cmake.sh b/cmake.sh index 89d89b1..b400ee5 100755 --- a/cmake.sh +++ b/cmake.sh @@ -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 diff --git a/qtcreator-debug.sh b/qtcreator-debug.sh index 9343bb8..ed3f442 100755 --- a/qtcreator-debug.sh +++ b/qtcreator-debug.sh @@ -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