当前位置:网站首页>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}
边栏推荐
- 在线硬核工具
- [recommendation system 02] deepfm, youtubednn, DSSM, MMOE
- Five simple and practical daily development functions of chrome are explained in detail. Unlock quickly to improve your efficiency!
- 多线程-异步编排
- 深入理解Apache Hudi异步索引机制
- 2021 summary and 2022 outlook
- Those confusing concepts (3): function and class
- 【PyTorch 07】 动手学深度学习——chapter_preliminaries/ndarray 习题动手版
- ADB utility commands (network package, log, tuning related)
- About hzero resource error (groovy.lang.missingpropertyexception: no such property: weight for class)
猜你喜欢

Socket communication principle and Practice

【STM32】实战3.1—用STM32与TB6600驱动器驱动42步进电机(一)

CSAPP Bomb Lab 解析

Find the root of equation ax^2+bx+c=0 (C language)

【实战】霸榜各大医学分割挑战赛的Transformer架构--nnFormer

Elegant controller layer code
![[daiy5] jz77 print binary tree in zigzag order](/img/ba/b2dfbf121798757c7b9fba4811221b.png)
[daiy5] jz77 print binary tree in zigzag order

【推荐系统 01】Rechub

ThreadLocal is not enough
![[pro test feasible] error while loading shared libraries solution](/img/e2/688ffa07861f38941cbf2cafdd9939.png)
[pro test feasible] error while loading shared libraries solution
随机推荐
Five simple and practical daily development functions of chrome are explained in detail. Unlock quickly to improve your efficiency!
Leetcode-303: region and retrieval - array immutable
What does intermediate software evaluator test
VR development optimization
枪出惊龙,众“锁”周之
CSAPP Bomb Lab 解析
在线硬核工具
Socket communication principle and Practice
Simple and easy to modify spring frame components
【推荐系统 01】Rechub
CC2530 zigbee IAR8.10.1环境搭建
深入理解Apache Hudi异步索引机制
ThreadLocal is not enough
What are the contents of the intermediate soft test, the software designer test, and the test outline?
2021 summary and 2022 outlook
[actual combat] transformer architecture of the major medical segmentation challenges on the list --nnformer
打算参加安全方面工作,信息安全工程师怎么样,软考考试需要怎么准备?
Multithreaded asynchronous orchestration
[detailed explanation of Huawei machine test] tall and short people queue up
Applet jump to H5, configure business domain name experience tutorial