当前位置:网站首页>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}
边栏推荐
- 【推薦系統 01】Rechub
- 2022年7月10日“五心公益”活动通知+报名入口(二维码)
- JS实现链式调用
- 【推荐系统 01】Rechub
- 1321: [example 6.3] deletion problem (noip1994)
- Realize ray detection, drag the mouse to move the object and use the pulley to scale the object
- What are the test preparation materials and methods for soft exam information processing technicians?
- How much review time does it usually take to take the intermediate soft exam?
- How to get hardware information in unity
- Find the root of equation ax^2+bx+c=0 (C language)
猜你喜欢
Pre knowledge reserve of TS type gymnastics to become an excellent TS gymnastics master
简单易修改的弹框组件
Mendeley -- a free document management tool that automatically inserts references into papers
单调性约束与反单调性约束的区别 monotonicity and anti-monotonicity constraint
小程序跳转H5,配置业务域名经验教程
How to successfully pass the senior system architecture designer in the second half of the year?
Deep understanding of Apache Hudi asynchronous indexing mechanism
Application of OpenGL gllightfv function and related knowledge of light source
路由器开发知识汇总
高级软考(网络规划设计师)该如何备考?
随机推荐
Some online academic report websites and machine learning videos
TypeScript 接口继承
深入理解Apache Hudi异步索引机制
多线程-异步编排
Applet jump to H5, configure business domain name experience tutorial
Schnuka: machine vision positioning technology machine vision positioning principle
软考中级电子商务师含金量高嘛?
【作业】2022.7.6 写一个自己的cal函数
leetcode-303:区域和检索 - 数组不可变
JS实现链式调用
原型与原型链
leetcode-304:二维区域和检索 - 矩阵不可变
P1223 queuing for water /1319: [example 6.1] queuing for water
Online hard core tools
Summary of router development knowledge
Monai version has been updated to 0.9. See what new functions it has
SQL Server 知识汇集11 : 约束
Operation method of Orange Pie orangepi 4 lts development board connecting SATA hard disk through mini PCIe
How to successfully pass the senior system architecture designer in the second half of the year?
[OneNote] can't connect to the network and can't sync the problem