当前位置:网站首页>Compile QT project script with qmake
Compile QT project script with qmake
2022-07-07 10:50:00 【Taylor lance】
This needs to be compiled by yourself qt, Specific compilation qt See other contents of the blog .
# 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 [email protected]"
PROCESS_ARGS=$(getopt -o q:s:b:i:d:v:r --long qt:,source:,build:,install:,depends:,version:,rebuild -- "[email protected]")
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
Specific usage :
#!/bin/bash
VERSION="release"
REBUILD="YES"
if [ -n "$1" ];then
VERSION=$1
fi
if [ -n "$2" ];then
REBUILD=$2
fi
MYQTPATH=${
PWD}/../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}
边栏推荐
- Mendeley--免费的文献管理工具,给论文自动插入参考文献
- leetcode-303:区域和检索 - 数组不可变
- 【实战】霸榜各大医学分割挑战赛的Transformer架构--nnFormer
- [installation system] U disk installation system tutorial, using UltraISO to make U disk startup disk
- 施努卡:机器人视觉抓取工作原理 机器视觉抓取
- 书签整理-程序员常用网站导航
- [recommendation system 02] deepfm, youtubednn, DSSM, MMOE
- [homework] 2022.7.6 write your own cal function
- Laya common script commands
- Use of dotween
猜你喜欢
July 10, 2022 "five heart public welfare" activity notice + registration entry (two-dimensional code)
小程序跳转H5,配置业务域名经验教程
[recommendation system 01] rechub
使用U2-Net深层网络实现——证件照生成程序
leetcode-560:和为 K 的子数组
Operation method of Orange Pie orangepi 4 lts development board connecting SATA hard disk through mini PCIe
[installation system] U disk installation system tutorial, using UltraISO to make U disk startup disk
Basic introduction of yarn and job submission process
Application of OpenGL gllightfv function and related knowledge of light source
Applet jump to H5, configure business domain name experience tutorial
随机推荐
What are the contents of the intermediate soft test, the software designer test, and the test outline?
Laya common script commands
Schnuka: working principle of robot visual grasping machine visual grasping
2021 summary and 2022 outlook
Leetcode-304: two dimensional area and retrieval - matrix immutable
想考中级软考,一般需要多少复习时间?
Basic introduction of yarn and job submission process
一些线上学术报告网站与机器学习视频
SQL Server 知识汇集11 : 约束
ThreadLocal is not enough
Using U2 net deep network to realize -- certificate photo generation program
P1223 queuing for water /1319: [example 6.1] queuing for water
MySQL insert data create trigger fill UUID field value
宁愿把简单的问题说一百遍,也不把复杂的问题做一遍
[recommendation system 02] deepfm, youtubednn, DSSM, MMOE
1324: [example 6.6] integer interval
【推薦系統 01】Rechub
【亲测可行】error while loading shared libraries的解决方案
Some superficial understanding of word2vec
TypeScript 接口继承