improve build script

This commit is contained in:
Syping 2020-05-05 18:12:28 +02:00
parent 2d8db19710
commit 2bca83df66

174
qt_build
View file

@ -330,7 +330,10 @@ function zlib_clean {
}
function zlib_strip {
return 0
if [ ! "${TARGET_OS}" == "Windows" ]; then
cd "${PREFIX_DIR}/lib/${COMPILER}/zlib-${ZLIB_VERSION}${TARGET_SUFFIX}"
rm -rf share
fi
}
function zlib_register {
@ -371,7 +374,7 @@ function libpng_clean {
function libpng_strip {
cd "${PREFIX_DIR}/lib/${COMPILER}/libpng-${LIBPNG_VERSION}"
rm -rf bin
rm -rf bin share
}
function libpng_register {
@ -457,26 +460,33 @@ function openssl_install {
cd "${BUILD_DIR}/openssl-${OPENSSL_VERSION}_${TARGET_PLATFORM}_${TARGET_TYPE}"
if [ "${CUSTOM_OPENSSL_INSTALL}" == "YES" ]; then
mkdir -p "${PREFIX_DIR}/lib/${COMPILER}/openssl-${OPENSSL_VERSION}${TARGET_SUFFIX}" \
"${PREFIX_DIR}/lib/${COMPILER}/openssl-${OPENSSL_VERSION}${TARGET_SUFFIX}/bin" \
"${PREFIX_DIR}/lib/${COMPILER}/openssl-${OPENSSL_VERSION}${TARGET_SUFFIX}/include" \
"${PREFIX_DIR}/lib/${COMPILER}/openssl-${OPENSSL_VERSION}${TARGET_SUFFIX}/include/openssl" \
"${PREFIX_DIR}/lib/${COMPILER}/openssl-${OPENSSL_VERSION}${TARGET_SUFFIX}/lib" \
"${PREFIX_DIR}/lib/${COMPILER}/openssl-${OPENSSL_VERSION}${TARGET_SUFFIX}/lib/pkgconfig"
"${PREFIX_DIR}/lib/${COMPILER}/openssl-${OPENSSL_VERSION}${TARGET_SUFFIX}/lib/pkgconfig" \
"${PREFIX_DIR}/include/openssl-${OPENSSL_VERSION}" \
"${PREFIX_DIR}/include/openssl-${OPENSSL_VERSION}/openssl"
if [ "${TARGET_TYPE}" == "shared" ]; then
cp -Rf lib*.dll "${PREFIX_DIR}/lib/${COMPILER}/openssl-${OPENSSL_VERSION}${TARGET_SUFFIX}/bin/"
cp -Rf libcrypto.dll.a libssl.dll.a "${PREFIX_DIR}/lib/${COMPILER}/openssl-${OPENSSL_VERSION}${TARGET_SUFFIX}/lib/"
if [ "${TARGET_OS}" == "Windows" ]; then
mkdir -p "${PREFIX_DIR}/lib/${COMPILER}/openssl-${OPENSSL_VERSION}${TARGET_SUFFIX}/bin"
cp -Rf lib*.dll "${PREFIX_DIR}/lib/${COMPILER}/openssl-${OPENSSL_VERSION}${TARGET_SUFFIX}/bin/"
cp -Rf libcrypto.dll.a libssl.dll.a "${PREFIX_DIR}/lib/${COMPILER}/openssl-${OPENSSL_VERSION}${TARGET_SUFFIX}/lib/"
else
cp -Rf lib*.so* "${PREFIX_DIR}/lib/${COMPILER}/openssl-${OPENSSL_VERSION}${TARGET_SUFFIX}/lib/"
fi
fi
cp -Rf libcrypto.a libssl.a "${PREFIX_DIR}/lib/${COMPILER}/openssl-${OPENSSL_VERSION}${TARGET_SUFFIX}/lib/"
cp -Rf libcrypto.pc libssl.pc openssl.pc "${PREFIX_DIR}/lib/${COMPILER}/openssl-${OPENSSL_VERSION}${TARGET_SUFFIX}/lib/pkgconfig/"
cp -Rf include/openssl/*.h "${PREFIX_DIR}/lib/${COMPILER}/openssl-${OPENSSL_VERSION}${TARGET_SUFFIX}/include/openssl/"
cp -Rf include/openssl/*.h "${PREFIX_DIR}/include/openssl-${OPENSSL_VERSION}/openssl/"
cd "${SOURCE_DIR_OPENSSL}"
cp -Rf include/openssl/*.h "${PREFIX_DIR}/lib/${COMPILER}/openssl-${OPENSSL_VERSION}${TARGET_SUFFIX}/include/openssl/"
cp -Rf include/openssl/*.h "${PREFIX_DIR}/include/openssl-${OPENSSL_VERSION}/openssl/"
cd "${BUILD_DIR}/openssl-${OPENSSL_VERSION}_${TARGET_PLATFORM}_${TARGET_TYPE}"
if [ ! -L "${PREFIX_DIR}/lib/${COMPILER}/openssl-${OPENSSL_VERSION}${TARGET_SUFFIX}/include" ]; then
ln -sf "${PREFIX_DIR}/include/openssl-${OPENSSL_VERSION}" "${PREFIX_DIR}/lib/${COMPILER}/openssl-${OPENSSL_VERSION}${TARGET_SUFFIX}/include"
fi
else
${MAKE_GENERATOR_INSTALL}
fi
if [ ! -L "${PREFIX_DIR}/include/openssl-${OPENSSL_VERSION}" ]; then
ln -sf "${PREFIX_DIR}/lib/${COMPILER}/openssl-${OPENSSL_VERSION}${TARGET_SUFFIX}/include" "${PREFIX_DIR}/include/openssl-${OPENSSL_VERSION}"
if [ ! -L "${PREFIX_DIR}/include/openssl-${OPENSSL_VERSION}" ]; then
ln -sf "${PREFIX_DIR}/lib/${COMPILER}/openssl-${OPENSSL_VERSION}${TARGET_SUFFIX}/include" "${PREFIX_DIR}/include/openssl-${OPENSSL_VERSION}"
fi
fi
}
@ -489,9 +499,9 @@ function openssl_strip {
cd "${PREFIX_DIR}/lib/${COMPILER}/openssl-${OPENSSL_VERSION}${TARGET_SUFFIX}"
if [ ! "${CUSTOM_OPENSSL_INSTALL}" == "YES" ]; then
if [ "${TARGET_OS}" == "Windows" ]; then
rm -rf bin/*.exe etc share
rm -rf bin/*.exe bin/c_rehash etc share
else
rm -rf etc share
rm -rf bin etc share ssl
fi
fi
}
@ -503,7 +513,11 @@ function openssl_register {
local EXTRA_SSLLIBS=
fi
export OPENSSL_LIBS="-L${PREFIX_DIR}/lib/${COMPILER}/openssl-${OPENSSL_VERSION}${TARGET_SUFFIX}/lib -lssl -lcrypto ${EXTRA_SSLLIBS}"
QT_LIBS_FLAGS="${QT_LIBS_FLAGS} -openssl-linked -L ${PREFIX_DIR}/lib/${COMPILER}/openssl-${OPENSSL_VERSION}${TARGET_SUFFIX}/lib -I ${PREFIX_DIR}/include/openssl-${OPENSSL_VERSION}"
if [ "${CUSTOM_OPENSSL_INSTALL}" == "YES" ]; then
QT_LIBS_FLAGS="${QT_LIBS_FLAGS} -openssl-linked -L ${PREFIX_DIR}/lib/${COMPILER}/openssl-${OPENSSL_VERSION}${TARGET_SUFFIX}/lib -I ${PREFIX_DIR}/include/openssl-${OPENSSL_VERSION}"
else
QT_LIBS_FLAGS="${QT_LIBS_FLAGS} -openssl-linked -L ${PREFIX_DIR}/lib/${COMPILER}/openssl-${OPENSSL_VERSION}${TARGET_SUFFIX}/lib -I ${PREFIX_DIR}/lib/${COMPILER}/openssl-${OPENSSL_VERSION}${TARGET_SUFFIX}/include"
fi
}
function openssl_source {
@ -542,7 +556,6 @@ function icu_build_stdthreads {
function icu_build {
icu_build_native
icu_build_stdthreads
cd "${BUILD_DIR}/icu4c-${ICU_VERSION}_${TARGET_PLATFORM}_${TARGET_TYPE}"
if [ "${TARGET_TYPE}" == "static" ]; then
local EXTRA_FLAGS=--disable-shared
@ -561,7 +574,14 @@ function icu_build {
local CC=${COMPILER}-cc
local CXX=${COMPILER}-c++
fi
CC=${CC} CXX=${CXX} CXXFLAGS="-I${BUILD_DIR}/icu4c-${ICU_VERSION}_stdthreads_${TARGET_PLATFORM}/cmake_stdheaders_generator/cmake_stdheaders_generator" "${SOURCE_DIR_ICU}/configure" --host=${COMPILER} ${EXTRA_FLAGS} --disable-samples --disable-tests --prefix="${PREFIX_DIR}/lib/${COMPILER}/icu4c-${ICU_VERSION}${TARGET_SUFFIX}" --includedir="${PREFIX_DIR}/include/icu4c-${ICU_VERSION}" --with-cross-build="${BUILD_DIR}/icu4c-${ICU_VERSION}_native" --with-data-packaging=${DATA_PACKAGING}
if [ "${TARGET_OS}" == "Windows" ]; then
icu_build_stdthreads
local CXXFLAGS="-I${BUILD_DIR}/icu4c-${ICU_VERSION}_stdthreads_${TARGET_PLATFORM}/cmake_stdheaders_generator/cmake_stdheaders_generator"
cd "${BUILD_DIR}/icu4c-${ICU_VERSION}_${TARGET_PLATFORM}_${TARGET_TYPE}"
else
local CXXFLAGS=
fi
CC=${CC} CXX=${CXX} CXXFLAGS=${CXXFLAGS} "${SOURCE_DIR_ICU}/configure" --host=${COMPILER} ${EXTRA_FLAGS} --disable-samples --disable-tests --prefix="${PREFIX_DIR}/lib/${COMPILER}/icu4c-${ICU_VERSION}${TARGET_SUFFIX}" --includedir="${PREFIX_DIR}/include/icu4c-${ICU_VERSION}" --with-cross-build="${BUILD_DIR}/icu4c-${ICU_VERSION}_native" --with-data-packaging=${DATA_PACKAGING}
${MAKE_GENERATOR}
}
@ -587,17 +607,23 @@ function icu_clean {
cd "${BUILD_DIR}/icu4c-${ICU_VERSION}_${TARGET_PLATFORM}_${TARGET_TYPE}"
rm -rf "${BUILD_DIR}/icu4c-${ICU_VERSION}_${TARGET_PLATFORM}_${TARGET_TYPE}"
icu_clean_native
icu_clean_stdthreads
if [ "${TARGET_OS}" == "Windows" ]; then
icu_clean_stdthreads
fi
}
function icu_strip {
cd "${PREFIX_DIR}/lib/${COMPILER}/icu4c-${ICU_VERSION}${TARGET_SUFFIX}"
rm -rf bin lib/icu share
if [ "${TARGET_OS}" == "Windows" ]; then
rm -rf bin lib/icu share
else
rm -rf bin lib/icu sbin share
fi
}
function icu_register {
export ICU_LIBS="-L${PREFIX_DIR}/lib/${COMPILER}/icu4c-${ICU_VERSION}${TARGET_SUFFIX} -licuin -licuuc -licudt"
QT_LIBS_FLAGS="${QT_LIBS_FLAGS} -icu -L ${PREFIX_DIR}/lib/${COMPILER}/icu4c-${ICU_VERSION}${TARGET_SUFFIX} -I ${PREFIX_DIR}/include/icu4c-${ICU_VERSION}"
QT_LIBS_FLAGS="${QT_LIBS_FLAGS} -icu -L ${PREFIX_DIR}/lib/${COMPILER}/icu4c-${ICU_VERSION}${TARGET_SUFFIX}/lib -I ${PREFIX_DIR}/include/icu4c-${ICU_VERSION}"
}
function icu_source {
@ -711,6 +737,18 @@ function qt_source {
wget -O ${ARCHIVE}.tar.xz "https://download.qt.io/official_releases/qt/${SERIES}/${VERSION}/single/${ARCHIVE}.tar.xz"
tar xfJ ${ARCHIVE}.tar.xz
fi
# Create Linux armhf g++ mkspec when not already exists
if [ ! -d "${ARCHIVE}/qtbase/mkspecs/linux-arm-gnueabihf-g++" ]; then
mkdir -p "${ARCHIVE}/qtbase/mkspecs/linux-arm-gnueabihf-g++"
echo -e "MAKEFILE_GENERATOR=UNIX\nCONFIG+=incremental\nQMAKE_INCREMENTAL_STYLE=sublib\ninclude(../common/linux.conf)\ninclude(../common/gcc-base-unix.conf)\ninclude(../common/g++-unix.conf)\nQMAKE_CC=arm-linux-gnueabihf-gcc\nQMAKE_CXX=arm-linux-gnueabihf-g++\nQMAKE_LINK=arm-linux-gnueabihf-g++\nQMAKE_LINK_SHLIB=arm-linux-gnueabihf-g++\nQMAKE_AR=arm-linux-gnueabihf-ar cqs\nQMAKE_OBJCOPY=arm-linux-gnueabihf-objcopy\nQMAKE_NM=arm-linux-gnueabihf-nm -P\nQMAKE_STRIP=arm-linux-gnueabihf-strip\nload(qt_config)" > "${ARCHIVE}/qtbase/mkspecs/linux-arm-gnueabihf-g++/qmake.conf"
echo -e "#include \"../linux-g++/qplatformdefs.h\"" > "${ARCHIVE}/qtbase/mkspecs/linux-arm-gnueabihf-g++/qplatformdefs.h"
fi
# Create Linux aarch64 g++ mkspec when not already exists
if [ ! -d "${ARCHIVE}/qtbase/mkspecs/linux-aarch64-gnu-g++" ]; then
mkdir -p "${ARCHIVE}/qtbase/mkspecs/linux-aarch64-gnu-g++"
echo -e "MAKEFILE_GENERATOR=UNIX\nCONFIG+=incremental\nQMAKE_INCREMENTAL_STYLE=sublib\ninclude(../common/linux.conf)\ninclude(../common/gcc-base-unix.conf)\ninclude(../common/g++-unix.conf)\nQMAKE_CC=aarch64-linux-gnu-gcc\nQMAKE_CXX=aarch64-linux-gnu-g++\nQMAKE_LINK=aarch64-linux-gnu-g++\nQMAKE_LINK_SHLIB=aarch64-linux-gnu-g++\nQMAKE_AR=aarch64-linux-gnu-ar cqs\nQMAKE_OBJCOPY=aarch64-linux-gnu-objcopy\nQMAKE_NM=aarch64-linux-gnu-nm -P\nQMAKE_STRIP=aarch64-linux-gnu-strip\nload(qt_config)" > "${ARCHIVE}/qtbase/mkspecs/linux-aarch64-gnu-g++/qmake.conf"
echo -e "#include \"../linux-g++/qplatformdefs.h\"" > "${ARCHIVE}/qtbase/mkspecs/linux-aarch64-gnu-g++/qplatformdefs.h"
fi
QT_VERSION=${VERSION}
SOURCE_DIR_QT="${SOURCE_DIR}/${ARCHIVE}"
}
@ -719,7 +757,6 @@ function qt_patch {
cd "${SOURCE_DIR_QT}"
if [ -f "qtbase/config.tests/openssl/openssl.cpp" ]; then
rm -f qtbase/config.tests/openssl/openssl.cpp
touch qtbase/config.tests/openssl/openssl.cpp
echo -e "#include <openssl/opensslv.h>\n#if !defined(OPENSSL_VERSION_NUMBER) || OPENSSL_VERSION_NUMBER-0 < 0x0090700fL\n#error \"OpenSSL >= 0.9.7 is required\"\n#endif\n#include <openssl/ssl.h>\n#if OPENSSL_VERSION_NUMBER-0 >= 0x10002000L && !defined(OPENSSL_NO_EC) && !defined(SSL_CTRL_SET_CURVES)\n#error \"OpenSSL was reported as >= 1.0.2 but is missing required features, possibly it's libressl which is unsupported\"\n#endif\nint main(){}" > qtbase/config.tests/openssl/openssl.cpp
fi
}
@ -952,7 +989,7 @@ function build_type {
fi
SSL_PLATFORM=mingw
TARGET_OS=Windows
TARGET_CPU=X86
TARGET_CPU=x86
local SET_RC=$(command -v ${COMPILER}-windres)
if [ "${SET_CC}" == "" ] || [ "${SET_CXX}" == "" ] || [ "${SET_RC}" == "" ]; then
echo "Incomplete or missing ${TARGET_PLATFORM} compiler for current build, please install one!"
@ -976,7 +1013,7 @@ function build_type {
fi
SSL_PLATFORM=mingw64
TARGET_OS=Windows
TARGET_CPU=AMD64
TARGET_CPU=amd64
local SET_RC=$(command -v ${COMPILER}-windres)
if [ "${SET_CC}" == "" ] || [ "${SET_CXX}" == "" ] || [ "${SET_RC}" == "" ]; then
echo "Incomplete or missing ${TARGET_PLATFORM} compiler for current build, please install one!"
@ -984,6 +1021,52 @@ function build_type {
fi
echo -e "set(CMAKE_SYSTEM_NAME ${TARGET_OS})\nset(CMAKE_SYSTEM_PROCESSOR ${TARGET_CPU})\nset(CMAKE_C_COMPILER ${SET_CC})\nset(CMAKE_CXX_COMPILER ${SET_CXX})\nset(CMAKE_RC_COMPILER ${SET_RC})" > "${BUILD_DIR}/cmake.${TARGET_PLATFORM}.toolchain"
CMAKE_TOOLCHAIN_FLAGS="-DCMAKE_TOOLCHAIN_FILE=${BUILD_DIR}/cmake.${TARGET_PLATFORM}.toolchain"
elif [ "${TARGET_PLATFORM}" == "linux-armhf" ] || [ "${TARGET_PLATFORM}" == "arm-linux-gnueabihf" ]; then
TARGET_PLATFORM=linux-armhf
COMPILER=arm-linux-gnueabihf
if [ "${LINUX_ARMHF_USE_CLANG}" == "YES" ]; then
USE_CLANG=YES
QT_XPLATFORM=linux-clang
local SET_CC=$(command -v ${COMPILER}-clang)
local SET_CXX=$(command -v ${COMPILER}-clang++)
else
USE_GCC=YES
QT_XPLATFORM=linux-arm-gnueabihf-g++
local SET_CC=$(command -v ${COMPILER}-gcc)
local SET_CXX=$(command -v ${COMPILER}-g++)
fi
SSL_PLATFORM=linux-armv4
TARGET_OS=Linux
TARGET_CPU=armhf
if [ "${SET_CC}" == "" ] || [ "${SET_CXX}" == "" ]; then
echo "Incomplete or missing ${TARGET_PLATFORM} compiler for current build, please install one!"
exit 1
fi
echo -e "set(CMAKE_SYSTEM_NAME ${TARGET_OS})\nset(CMAKE_SYSTEM_PROCESSOR ${TARGET_CPU})\nset(CMAKE_C_COMPILER ${SET_CC})\nset(CMAKE_CXX_COMPILER ${SET_CXX})" > "${BUILD_DIR}/cmake.${TARGET_PLATFORM}.toolchain"
CMAKE_TOOLCHAIN_FLAGS="-DCMAKE_TOOLCHAIN_FILE=${BUILD_DIR}/cmake.${TARGET_PLATFORM}.toolchain"
elif [ "${TARGET_PLATFORM}" == "linux-aarch64" ] || [ "${TARGET_PLATFORM}" == "aarch64-linux-gnu" ]; then
TARGET_PLATFORM=linux-aarch64
COMPILER=aarch64-linux-gnu
if [ "${LINUX_AARCH64_USE_CLANG}" == "YES" ]; then
USE_CLANG=YES
QT_XPLATFORM=linux-clang
local SET_CC=$(command -v ${COMPILER}-clang)
local SET_CXX=$(command -v ${COMPILER}-clang++)
else
USE_GCC=YES
QT_XPLATFORM=linux-aarch64-gnu-g++
local SET_CC=$(command -v ${COMPILER}-gcc)
local SET_CXX=$(command -v ${COMPILER}-g++)
fi
SSL_PLATFORM=linux-aarch64
TARGET_OS=Linux
TARGET_CPU=aarch64
if [ "${SET_CC}" == "" ] || [ "${SET_CXX}" == "" ]; then
echo "Incomplete or missing ${TARGET_PLATFORM} compiler for current build, please install one!"
exit 1
fi
echo -e "set(CMAKE_SYSTEM_NAME ${TARGET_OS})\nset(CMAKE_SYSTEM_PROCESSOR ${TARGET_CPU})\nset(CMAKE_C_COMPILER ${SET_CC})\nset(CMAKE_CXX_COMPILER ${SET_CXX})" > "${BUILD_DIR}/cmake.${TARGET_PLATFORM}.toolchain"
CMAKE_TOOLCHAIN_FLAGS="-DCMAKE_TOOLCHAIN_FILE=${BUILD_DIR}/cmake.${TARGET_PLATFORM}.toolchain"
else
COMPILER=${TARGET_PLATFORM}
if [ "${CUSTOM_USE_CLANG}" == "YES" ]; then
@ -1173,16 +1256,21 @@ if [ "${CUSTOM_SET}" == "YES" ]; then
build_clean_env
build_tl_set ${TARGET_PLATFORM}
if [ "${CUSTOM_SET_TYPE}" == "all" ]; then
build_clean_env reregister
build_set ${TARGET_PLATFORM} shared _d
build_clean_env reregister
build_set ${TARGET_PLATFORM} static _s
elif [ "${CUSTOM_SET_TYPE}" == "mshared" ]; then
build_clean_env reregister
build_set ${TARGET_PLATFORM} shared _d
elif [ "${CUSTOM_SET_TYPE}" == "mstatic" ]; then
build_clean_env reregister
build_set ${TARGET_PLATFORM} static _s
elif [ "${CUSTOM_SET_TYPE}" == "static" ]; then
build_clean_env reregister
build_set ${TARGET_PLATFORM} static
else
build_clean_env reregister
build_set ${TARGET_PLATFORM} shared
fi
fi
@ -1194,12 +1282,12 @@ if [ ! "${BUILD_MINGW32_SHARED}" == "NO" ] || [ ! "${BUILD_MINGW32_STATIC}" == "
build_tl_set mingw32
fi
if [ ! "${BUILD_MINGW32_SHARED}" == "NO" ]; then
build_set mingw32 shared _d
build_clean_env reregister
build_set mingw32 shared _d
fi
if [ ! "${BUILD_MINGW32_STATIC}" == "NO" ]; then
build_set mingw32 static _s
build_clean_env reregister
build_set mingw32 static _s
fi
# Windows 64-Bit builds
@ -1209,10 +1297,40 @@ if [ ! "${BUILD_MINGW64_SHARED}" == "NO" ] || [ ! "${BUILD_MINGW64_STATIC}" == "
build_tl_set mingw64
fi
if [ ! "${BUILD_MINGW64_SHARED}" == "NO" ]; then
build_set mingw64 shared _d
build_clean_env reregister
build_set mingw64 shared _d
fi
if [ ! "${BUILD_MINGW64_STATIC}" == "NO" ]; then
build_set mingw64 static _s
build_clean_env reregister
build_set mingw64 static _s
fi
# Linux armhf builds
if [ "${BUILD_LINUX_ARMHF_SHARED}" == "YES" ] || [ "${BUILD_LINUX_ARMHF_STATIC}" == "YES" ]; then
build_clean_env
build_tl_set linux-armhf
fi
if [ "${BUILD_LINUX_ARMHF_SHARED}" == "YES" ]; then
build_clean_env reregister
build_set linux-armhf shared _d
fi
if [ "${BUILD_LINUX_ARMHF_STATIC}" == "YES" ]; then
build_clean_env reregister
build_set linux-armhf static _s
fi
# Linux aarch64 builds
if [ "${BUILD_LINUX_AARCH64_SHARED}" == "YES" ] || [ "${BUILD_LINUX_AARCH64_STATIC}" == "YES" ]; then
build_clean_env
build_tl_set linux-aarch64
fi
if [ "${BUILD_LINUX_AARCH64_SHARED}" == "YES" ]; then
build_clean_env reregister
build_set linux-aarch64 shared _d
fi
if [ "${BUILD_LINUX_AARCH64_STATIC}" == "YES" ]; then
build_clean_env reregister
build_set linux-aarch64 static _s
fi