当前位置:网站首页>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}
边栏推荐
- Five simple and practical daily development functions of chrome are explained in detail. Unlock quickly to improve your efficiency!
- TypeScript 接口继承
- 南航 PA3.1
- Using U2 net deep network to realize -- certificate photo generation program
- 中级软件评测师考什么
- IIC Basics
- 使用Tansformer分割三维腹部多器官--UNETR实战
- Mendeley--免费的文献管理工具,给论文自动插入参考文献
- I'd rather say simple problems a hundred times than do complex problems once
- Typescript interface inheritance
猜你喜欢
CSAPP bomb lab parsing
[pro test feasible] error while loading shared libraries solution
【推荐系统 01】Rechub
The gun startles the dragon, and the crowd "locks" Zhou Zhi
【STM32】实战3.1—用STM32与TB6600驱动器驱动42步进电机(一)
原型与原型链
【实战】霸榜各大医学分割挑战赛的Transformer架构--nnFormer
[système recommandé 01] rechub
【亲测可行】error while loading shared libraries的解决方案
Network engineer test questions and answers in May of the first half of 2022
随机推荐
CC2530 ZigBee iar8.10.1 environment construction
【推薦系統 01】Rechub
Multithreaded asynchronous orchestration
小程序跳转H5,配置业务域名经验教程
Opencv installation and environment configuration - vs2017
MONAI版本更新到 0.9 啦,看看有什么新功能
打算参加安全方面工作,信息安全工程师怎么样,软考考试需要怎么准备?
【安装系统】U盘安装系统教程,使用UltraISO制作U盘启动盘
CAS mechanism
Records on the use of easyflash v3.3
Pre knowledge reserve of TS type gymnastics to become an excellent TS gymnastics master
枪出惊龙,众“锁”周之
使用Tansformer分割三维腹部多器官--UNETR实战
2022年上半年5月网络工程师试题及答案
What are the test preparation materials and methods for soft exam information processing technicians?
leetcode-303:区域和检索 - 数组不可变
施努卡:机器视觉定位技术 机器视觉定位原理
Schnuka: machine vision positioning technology machine vision positioning principle
[machine learning 03] Lagrange multiplier method
[homework] 2022.7.6 write your own cal function