收集网址:
https://blog.csdn.net/u012020854/article/details/107104441/
https://blog.csdn.net/weixin_39864453/article/details/112702456
参考二
https://www.bilibili.com/read/cv12524130/
下面是qt编译的时候配置参数:
./configure -prefix /home/kylin/crystalmedia/server/media/depends-source-bak/qt-everywhere-src-5.12.3-release/qt_gcc_64 \
-release -opensource -confirm-license -no-openssl -no-opengl -skip qtquickcontrols -skip qtquickcontrols2 -skip qtsensors -skip qtdoc -no-compile-examples -skip qtlocation
其中要安装一些xcb的库,具体遇到自己百度一下。
使用qmake的时候遇到的一些问题:
Qmake error: Unknown module(s) in QT: network widgets gui core
在qmake 文件夹下,也就是bin目录下新建一个文件qt.conf
添加安装路径:
[Paths]
Prefix=/home/kylin/qt-gcc_64
下面是一个通过qmake编译qt项目的脚本:
# Build Qt project.
####################################################
### step 1: collect shell arguments
PROMPT=${PROMPT:-"[CI] "}
function usage () {
echo ${PROMPT}-----------------
echo ${PROMPT}"Usage:"
echo $PROMPT{PROMPT}"./$(basename $0) \\"
echo ${PROMPT}" --qt <abs-dir of Qt executables>"
echo ${PROMPT}" --source <abs-dir of source codes>"
echo ${PROMPT}" --build <abs-dir for building process>"
echo ${PROMPT}" --install <abs-dir for intalling targets>"
echo ${PROMPT}" --depends <abs-dir of dependencies>"
echo ${PROMPT}" [--rebuild"]
echo ${PROMPT}""
echo ${PROMPT}"Example:"
echo ${PROMPT}"./$(basename $0) \\"
echo ${PROMPT}" --qt \"/home/builder01/Workplace/depends/libqt\" \\"
echo ${PROMPT}" --source \"/home/builder01/Workplace/libdarknet\" \\"
echo ${PROMPT}" --build \"/home/builder01/Workplace/libdarknet-build\" \\"
echo ${PROMPT}" --install \"/home/builder01/Workplace/depends/libdarknet\" \\"
echo ${PROMPT}" --depends \"/home/builder01/Workplace/depends\""
echo ${PROMPT}" --rebuild"
}
if [ "$1" == "" ]; then
usage
exit 1;
fi
INPUT="$0 $@"
PROCESS_ARGS=$(getopt -o q:s:b:i:d:v:r --long qt:,source:,build:,install:,depends:,version:,rebuild -- "$@")
eval set -- "$PROCESS_ARGS"
while true; do
case "$1" in
-q|--qt) DIR_LIBQT=$2 ; shift 2 ;;
-s|--source) DIR_SOURCE=$2 ; shift 2 ;;
-b|--build) DIR_BUILD=$2 ; shift 2 ;;
-i|--install) DIR_INSTALL=$2 ; shift 2 ;;
-d|--depends) DIR_DEPENDS=$2 ; shift 2 ;;
-v|--version) VERSION=$2 ; shift 2 ;;
-r|--rebuild) REBUILD=YES ; shift ;;
--) shift ; break ;;
*)
echo "Internal error!" ; exit 1 ;;
esac
done
### change to use qt in flow-depends,songky,2020-05-12
#DIR_LIBQT="${DIR_DEPENDS}/qt-gcc_64"
[ -z "$DIR_LIBQT" ] && PAR_ERROR=YES
[ -z "$DIR_SOURCE" ] && PAR_ERROR=YES
[ -z "$DIR_INSTALL" ] && PAR_ERROR=YES
[ -z "$DIR_DEPENDS" ] && PAR_ERROR=YES
# version choice is disabled. You can enable it uncomment the lines below
#[ -z "$VERSION" ] && PAR_ERROR=YES
#VERSION="debug release" ### defined in job stage
if [ "#$PAR_ERROR" = "#YES" ]; then
echo ${PROMPT}Parameter error!. You input is interieted as:
echo ${PROMPT}--------------------------
echo ${PROMPT}$INPUT
echo ${PROMPT}--------------------------
echo ${PROMPT} Type \"./$(basename $0)\" for help.
exit 1
fi
#if test $REBUILD
#then
# REBUILD=YES
#else
# REBUILD=NO
#fi
#trans git-lab viriables to project viriables
SMB_DIR=${sambaServer_flow:=---Empty---}
SMB_SERVER=${sambaServer_IP:=---Empty---}
SMB_USER=${sambaServer_user:=---Empty---}
#build different versions in individual folder
cd ..
rm -r ./${CI_PROJECT_NAME}_${VERSION}
cp -a ${CI_PROJECT_NAME} ./${CI_PROJECT_NAME}_${VERSION}
cd ${CI_PROJECT_NAME}_${VERSION}
#DIR_SOURCE=${PWD}
### print some debug info
if [[ ! "${flie_to_cat}" == "-" && -f "${flie_to_cat}" ]]; then
echo ""
echo "contents of ${flie_to_cat}"
cat ${flie_to_cat}
fi
if [[ ! "${floder_to_ls}" == "-" && -d "${floder_to_ls}" ]]; then
echo ""
echo "contents of ${floder_to_ls}"
ls -l ${floder_to_ls}
fi
####################################################
### step 2: check settings
echo ${PROMPT}QtLib=$DIR_LIBQT
echo ${PROMPT}Source=$DIR_SOURCE
echo ${PROMPT}Build=$DIR_BUILD
echo ${PROMPT}Install=$DIR_INSTALL
echo ${PROMPT}Depends=$DIR_DEPENDS
echo ${PROMPT}Version=$VERSION
echo ${PROMPT}Rebuild=$REBUILD
[ ! -d ${DIR_LIBQT} ] && echo "${DIR_LIBQT} not exists!" && exit 1
[ ! -d ${DIR_SOURCE} ] && echo "${DIR_SOURCE} not exists!" && exit 1
[ ! -d ${DIR_DEPENDS} ] && echo "${DIR_DEPENDS} not exists!" && exit 1
#rm -fr ${DIR_INSTALL}/*
#mkdir -p ${DIR_BUILD}/debug
#mkdir -p ${DIR_BUILD}/release
#mkdir -p ${DIR_INSTALL}/debug
#mkdir -p ${DIR_INSTALL}/release
rm -fr ${DIR_INSTALL}/${VERSION}
mkdir -p ${DIR_BUILD}/${VERSION}
mkdir -p ${DIR_INSTALL}/${VERSION}
# the .pro files in flow need environment variable 'DEPENDS_ROOT' to tell
# the path to the dependencies
export DEPENDS_ROOT=${DIR_DEPENDS}
# Qt screen output settings
export QT_QPA_PLATFORM_PLUGIN_PATH=${DIR_DEPENDS}/qt-gcc_64/plugins
export QT_QPA_PLATFORM=offscreen
export LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:${DIR_DEPENDS}/qt-gcc_64/plugins/platforms
echo "QT_QPA_PLATFORM_PLUGIN_PATH="${QT_QPA_PLATFORM_PLUGIN_PATH}
echo "QT_QPA_PLATFORM="${QT_QPA_PLATFORM}
echo "LD_LIBRARY_PATH="${LD_LIBRARY_PATH}
####################################################
### step 3: make and run shell command lines
CPPCHECK_PASS=YES
for build_version in $VERSION ; do
if [ "#${build_version}" = "#debug" ] || [ "#${build_version}" = "#DEBUG" ] || [ "#${build_version}" = "#Debug" ] ; then
VER_STR=debug
else
VER_STR=release
fi
if [ $REBUILD = "YES" ] ; then
cmd_clear_build="rm -fr /${DIR_BUILD}/${VER_STR}/*"
else
cmd_clear_build="echo Incremental build."
fi
export BUILD_PATH=${DIR_BUILD}/${VER_STR}
export INSTALL_PATH=${DIR_INSTALL}/${VER_STR}
first_pass=YES
echo ${PROMPT} Run QMake and make...
echo Dir of Source:${DIR_SOURCE}
for pro_file in $(ls ${DIR_SOURCE}/*.pro); do
if [ $first_pass = "YES" ] ; then
#clear install directory
cmd_clear="rm -fr ${DIR_INSTALL}/${VER_STR}/* && ${cmd_clear_build}"
first_pass=NO
else
cmd_clear="echo 2nd pass..."
fi
cmd_db="compiledb -n make"
if [ $VER_STR = "debug" ] ; then
cmd_qmake="${DIR_LIBQT}/bin/qmake ${DIR_SOURCE}/$(basename ${pro_file}) -spec ${DIR_LIBQT}/mkspecs/linux-g++ CONFIG+=debug CONFIG+=qml_debug"
else
cmd_qmake="${DIR_LIBQT}/bin/qmake ${DIR_SOURCE}/$(basename ${pro_file}) -spec ${DIR_LIBQT}/mkspecs/linux-g++ CONFIG+=qtquickcompiler"
fi
# ${qmake_xxxxxx} is run twice to include the built targets for installation.
build_cmd="${cmd_qmake} && make -j 8 && cd ${DIR_BUILD}/${VER_STR} && rm -fr \`find -name Makefile\` && ${cmd_qmake} && make install"
# generate log file
cmd_log="echo Built at $(date +%y%m%d_%H%M%S) >> ${DIR_INSTALL}/${VER_STR}/build-log-$(date +%y%m%d_%H%M%S).txt"
cmdline="${cmd_clear} && cd ${DIR_BUILD}/${VER_STR} && ${build_cmd} && ${cmd_log}"
eval ${cmdline}
if [ $? -eq 0 ]; then
echo ${PROMPT}"${pro_file}-${VER_STR} has been successfully built."
cp ${DIR_SOURCE}/scripts/startEngine.sh ${DIR_INSTALL}/${VER_STR}/
else
echo ${PROMPT}" Build failed."
exit 1
fi
done
##### write version info into file
releaseNotes_filename="ReleaseNotes-$(date +%y%m%d_%H%M).txt"
cmd_last_half=">> ${DIR_INSTALL}/${VER_STR}/${releaseNotes_filename}"
### add components updated info
version_cmd="echo build flow $(date +%y%m%d_%H%M%S) ${cmd_last_half}"
### add code info
version_cmd="${version_cmd} && echo ' ' ${cmd_last_half}"
version_cmd="${version_cmd} && echo Code info:---------- ${cmd_last_half}"
version_cmd="${version_cmd} && echo CI_COMMIT_SHA=${CI_COMMIT_SHA} ${cmd_last_half}"
version_cmd="${version_cmd} && echo CI_COMMIT_SHORT_SHA=${CI_COMMIT_SHORT_SHA} ${cmd_last_half}"
version_cmd="${version_cmd} && echo CI_COMMIT_REF_NAME=${CI_COMMIT_REF_NAME} ${cmd_last_half}"
version_cmd="${version_cmd} && echo CI_COMMIT_BRANCH=${CI_COMMIT_BRANCH} ${cmd_last_half}"
version_cmd="${version_cmd} && echo CI_COMMIT_TAG=${CI_COMMIT_TAG} ${cmd_last_half}"
### add building env.
version_cmd="${version_cmd} && echo ' ' ${cmd_last_half}"
version_cmd="${version_cmd} && echo Building Env.: ---------- ${cmd_last_half}"
version_cmd="${version_cmd} && echo depends_dir=${DIR_DEPENDS} ${cmd_last_half}"
version_cmd="${version_cmd} && echo docker_image=${docker_image} ${cmd_last_half}"
echo ${PROMPT} "write version info command:"
echo ${PROMPT} "${version_cmd}"
echo " "
eval "${version_cmd}"
if [ $? -eq 0 ]; then
echo ${PROMPT}"Write version info to file into finished."
else
echo ${PROMPT}"Write version info to file into failed."
exit 1
fi
done
####################################################
### step 4: zip release vesion files of branch master or branch customized-FlowDesk-by-Zhongshan-University, then copy to samba SMB_SERVER
# check if need to zip and scp new files to samba server and gitlab runners
if [[ ${zip_scp} == "yes" ]] && [[ ${VERSION} == "release" ]] ; then
echo ${PROMPT} "-----Continue to zip and scp release version to samba server-----"
else
exit 0
fi
if [[ ${CI_COMMIT_REF_NAME} = *Zhongshan* ]] || [[ ${CI_COMMIT_REF_NAME} = "master" ]] ; then
# auto add remote runners authenticity key
sed -i "/StrictHostKeyChecking/c StrictHostKeyChecking no" /etc/ssh/ssh_config
# zip package
filename_suffix="$(date +%y%m%d_%H%M)_${CI_COMMIT_SHORT_SHA}.zip"
if [[ ${CI_COMMIT_REF_NAME} = master ]];then
zip_filename="flow-master_"${filename_suffix}
elif [[ ${CI_COMMIT_REF_NAME} = *Zhongshan* ]];then
zip_filename="flow-SYSU_"${filename_suffix}
fi
zip_cmd="echo =====zip job begin====="
zip_cmd="${zip_cmd} && cd ${DIR_INSTALL}"
zip_cmd="${zip_cmd} && zip -ry ${zip_filename} ./release/*"
# copy zip files to sambaServer
cp_zipfiles="echo ----- copy files to samba server -----"
cp_zipfiles="${cp_zipfiles} && sshpass -p ${sambaServer_pwd} scp ${zip_filename} ${SMB_USER}@${SMB_SERVER}:${SMB_DIR}"
zip_cmdline="${zip_cmd} && ${cp_zipfiles} && rm ${zip_filename}"
echo ${PROMPT}"zip_cmdline:----------"
echo ${zip_cmdline}
echo ----------
eval "${zip_cmdline}"
if [ $? -eq 0 ]; then
echo ${PROMPT}"zip and copy ${zip_filename} to ${SMB_SERVER}/${SMB_DIR} finished."
else
echo ${PROMPT}" zip and copy files failed."
exit 0
fi
fi
使用:
#!/bin/bash
VERSION="release"
REBUILD="YES"
if [ -n "$1" ];then
VERSION=$1
fi
if [ -n "$2" ];then
REBUILD=$2
fi
MYQTPATH=/home/kylin/crystalmedia/server/media/media-depends/qt-gcc_64
export QMAKESPEC=$MYQTPATH/mkspecs/linux-g++
./build-tg.sh \
-q ${MYQTPATH} \
-s ${PWD}/crystal-media \
-b ${PWD}/build \
-i ${PWD}/install \
-d ${PWD}/media-depends \
-v ${VERSION} \
-r ${REBUILD} \
cp ../build/${VERSION}/engine/lib* ../install/
cp ../build/${VERSION}/server/Flow* ../install/
echo `date`
echo ${VERSION} "rebuild":${REBUILD}