Исправления разбора аргументов через массивы

This commit is contained in:
Andrei Astafev 2019-02-14 14:33:44 +03:00
parent 9b0f1c3b75
commit 6c31d9f67e

View File

@ -89,8 +89,8 @@ while true; do
esac
done
CMAKE_ARGS=" "
[ ! -z "${@}" ] && CMAKE_ARGS="${@}"
CMAKE_ARGS=()
[ ${#@} -gt 0 ] && CMAKE_ARGS=("${@}")
[ ! -f "${SOURCE_DIR}/CMakeLists.txt" ] && { echo "Source directory does not contain CMakeLists.txt"; exit 4; }
@ -129,7 +129,6 @@ QTCREATOR_BUILD_TYPES=(qtNone qtDebug qtRelease qtProfile)
generate_configuration() {
local BUILD_TYPE="${!#}"
local BUILD="$BUILD_TYPE"
echo $BUILD_TYPE
if [ "x$QTCREATOR" == "xy" ]; then
case "$BUILD_TYPE" in
@ -157,7 +156,7 @@ generate_configuration() {
[ -d "${GEN_DIR}" ] && return 0
mkdir -p "${GEN_DIR}"
pushd "${GEN_DIR}" 2>/dev/null
cmake -G "${GENERATOR}" -DCMAKE_INSTALL_PREFIX="${OUTPUT_DIR}" -DCMAKE_BUILD_TYPE="${BUILD_TYPE}" ${CMAKE_ARGS} "${SOURCE_DIR}"
cmake -G "${GENERATOR}" -DCMAKE_INSTALL_PREFIX="${OUTPUT_DIR}" -DCMAKE_BUILD_TYPE="${BUILD_TYPE}" "${CMAKE_ARGS[@]}" "${SOURCE_DIR}"
if [ "x$GENERATOR" == "xNinja" ]; then
# Generate fake Makefile, so make can run ninja build
cat > Makefile <<EOF
@ -173,16 +172,16 @@ EOF
export -f generate_configuration
BUILD_TYPES=""
BUILD_TYPES=()
if [ "x$SINGLE_TYPE" != "xn" ]; then
BUILD_TYPES="${SINGLE_TYPE}"
BUILD_TYPES=("${SINGLE_TYPE}")
else
[ "x$QTCREATOR" == "xy" ] && BUILD_TYPES+=" ${QTCREATOR_BUILD_TYPES[@]}"
[ "x$CMAKE" == "xy" ] && BUILD_TYPES+=" ${CMAKE_BUILD_TYPES[@]}"
[ "x$QTCREATOR" == "xy" ] && BUILD_TYPES=("${BUILD_TYPES[@]}" "${QTCREATOR_BUILD_TYPES[@]}")
[ "x$CMAKE" == "xy" ] && BUILD_TYPES=("${BUILD_TYPES[@]}" "${CMAKE_BUILD_TYPES[@]}")
fi
if [ "x${BUILD_TYPES}" == "x" ]; then
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"
@ -194,13 +193,13 @@ fi
if [ -x "$(command -v parallel)" ]; then
PV=$(parallel --version | head -n 1 | awk '{ print $3; }')
if [ "$PV" -lt "20131121" ]; then
parallel generate_configuration ::: ${BUILD_TYPES}
parallel generate_configuration ::: "${BUILD_TYPES[@]}"
elif [ "$PV" -lt "20141023" ]; then
parallel --no-notice generate_configuration ::: ${BUILD_TYPES}
parallel --no-notice generate_configuration ::: "${BUILD_TYPES[@]}"
else
parallel --will-cite generate_configuration ::: ${BUILD_TYPES}
parallel --will-cite generate_configuration ::: "${BUILD_TYPES[@]}"
fi
else
for T in ${BUILD_TYPES}; do generate_configuration "${T}"; done
for T in "${BUILD_TYPES[@]}"; do generate_configuration "${T}"; done
fi