Add auto version generation script
This commit is contained in:
parent
21fb07b81c
commit
a67ff36c68
20
DCPlugin.pro
20
DCPlugin.pro
@ -45,7 +45,9 @@ contains( CONFIG, PTU5_YOCTO ) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
TARGET = CashAgentLib
|
TARGET = CashAgentLib
|
||||||
DESTDIR = ../plugins
|
#DESTDIR = ../plugins
|
||||||
|
INTERFACE = DeviceController
|
||||||
|
INTERFACE_DEFINITION = $${PWD}/include/ATBAPP/DeviceControllerInterface.h
|
||||||
|
|
||||||
|
|
||||||
# The following define makes your compiler emit warnings if you use
|
# The following define makes your compiler emit warnings if you use
|
||||||
@ -66,3 +68,19 @@ DEFINES += QT_DEPRECATED_WARNINGS
|
|||||||
#else: unix:!android: target.path = /opt/$${TARGET}/bin
|
#else: unix:!android: target.path = /opt/$${TARGET}/bin
|
||||||
#!isEmpty(target.path): INSTALLS += target
|
#!isEmpty(target.path): INSTALLS += target
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
DISTFILES += \
|
||||||
|
generate-version.sh
|
||||||
|
|
||||||
|
|
||||||
|
# Define how to create version.h
|
||||||
|
VERSION_H = $$PWD/include/version.h
|
||||||
|
version.output = $$PWD/include/version.h
|
||||||
|
version.commands = $$PWD/generate-version.sh $${ARCH} $${TARGET} $${INTERFACE} $${INTERFACE_DEFINITION} $${VERSION_H}
|
||||||
|
version.depends = FORCE
|
||||||
|
version.input = VERSION_H
|
||||||
|
version.variable_out = HEADERS
|
||||||
|
QMAKE_EXTRA_COMPILERS += version
|
||||||
|
QMAKE_CLEAN += $${PWD}/include/version.h
|
||||||
|
155
generate-version.sh
Executable file
155
generate-version.sh
Executable file
@ -0,0 +1,155 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
VERSION_STRING=""
|
||||||
|
|
||||||
|
#GIT='/cygdrive/c/Program Files \(x86\)/Git/bin/git'
|
||||||
|
GIT=git
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
parse_git_branch () {
|
||||||
|
$GIT branch --no-color 2> /dev/null | sed -e '/^[^*]/d' -e "s/* \(.*\)/\1/"
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
ARCH=$1
|
||||||
|
TARGET=$2
|
||||||
|
INTERFACE=$3
|
||||||
|
INTERFACE_DEFINITION=$4
|
||||||
|
VERSION_H=$5
|
||||||
|
|
||||||
|
SCRIPT=$(readlink -f $0)
|
||||||
|
SCRIPTPATH=`dirname $SCRIPT`
|
||||||
|
OUTPUTDIR=$(pwd)
|
||||||
|
echo " current dir is : " $(pwd)
|
||||||
|
echo $SCRIPT
|
||||||
|
echo $SCRIPTPATH
|
||||||
|
|
||||||
|
echo "changing dir to script path: " $SCRIPTPATH
|
||||||
|
cd $SCRIPTPATH
|
||||||
|
|
||||||
|
# set version string ##################################################################
|
||||||
|
if [ -z $VERSION_STRING ] ; then
|
||||||
|
VERSION_STRING=$(date +%Y%m%d_%H%M)
|
||||||
|
fi
|
||||||
|
GIT_DESCRIBE=$($GIT describe)
|
||||||
|
GIT_BRANCH=$(parse_git_branch)
|
||||||
|
|
||||||
|
# extract path from branchname:
|
||||||
|
IFS='_' read -ra TMP_ARRAY <<< "${GIT_BRANCH}"
|
||||||
|
BRANCH_PATH=${TMP_ARRAY[0]}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
# detect if we have a development version:
|
||||||
|
if [ ${#TMP_ARRAY[1]} -gt 0 ] ; then
|
||||||
|
DEV_SUFFIX="_dev"
|
||||||
|
else
|
||||||
|
DEV_SUFFIX=""
|
||||||
|
fi
|
||||||
|
|
||||||
|
# detect if git status is dirty
|
||||||
|
GIT_DESCRIBE_DIRTY=$($GIT describe --dirty)
|
||||||
|
if [ "${GIT_DESCRIBE_DIRTY:(-6)}" == "-dirty" ] ; then
|
||||||
|
DIRTY_SUFFIX="_dirty"
|
||||||
|
else
|
||||||
|
DIRTY_SUFFIX=""
|
||||||
|
fi
|
||||||
|
|
||||||
|
|
||||||
|
if [ -n "$DIRTY_SUFFIX" ] || [ -n "$DEV_SUFFIX" ] ; then
|
||||||
|
DEVDIRTY=true
|
||||||
|
else
|
||||||
|
DEVDIRTY=false
|
||||||
|
fi
|
||||||
|
|
||||||
|
|
||||||
|
# extract interface definition
|
||||||
|
|
||||||
|
#
|
||||||
|
#Q_DECLARE_INTERFACE(CCInterface,
|
||||||
|
# "eu.atb.ptu.plugin.CCInterface/2.9.0")
|
||||||
|
# -> extract whole string within quotation marks
|
||||||
|
INTERFACE_VERSION=$(grep 'eu.atb.ptu.plugin.' ${INTERFACE_DEFINITION})
|
||||||
|
# get string within quotes:
|
||||||
|
INTERFACE_VERSION=`echo ${INTERFACE_VERSION} | awk -F \" '{print $2}'`
|
||||||
|
|
||||||
|
|
||||||
|
#
|
||||||
|
# write version.h
|
||||||
|
|
||||||
|
|
||||||
|
echo " TARGET is: $TARGET"
|
||||||
|
echo " ARCH is: $ARCH"
|
||||||
|
echo " "
|
||||||
|
echo " PluginName: $TARGET"
|
||||||
|
echo " Interface: $INTERFACE"
|
||||||
|
echo " InterfaceVersion: $INTERFACE_VERSION"
|
||||||
|
echo " "
|
||||||
|
echo " new version is: $VERSION_STRING"
|
||||||
|
echo " git describe is: $GIT_DESCRIBE"
|
||||||
|
echo " git branch is: $GIT_BRANCH"
|
||||||
|
echo " branch-path is: $BRANCH_PATH"
|
||||||
|
echo " "
|
||||||
|
|
||||||
|
echo " dev suffix: $DEV_SUFFIX"
|
||||||
|
echo " dirty suffix: $DIRTY_SUFFIX"
|
||||||
|
|
||||||
|
|
||||||
|
PLUGIN_VERSION=${VERSION_STRING}
|
||||||
|
#ATB_QT_GIT_DESCRIBE=${GIT_DESCRIBE}_${GIT_BRANCH}
|
||||||
|
PLUGIN_GIT_DESCRIBE=${GIT_DESCRIBE}_${BRANCH_PATH}${DEV_SUFFIX}${DIRTY_SUFFIX}
|
||||||
|
|
||||||
|
#TARGET=IngenicoZVT_CCPlugin
|
||||||
|
|
||||||
|
|
||||||
|
# build version.h #####################################################################
|
||||||
|
|
||||||
|
echo " building new version info (version.h) ..."
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
echo "#ifndef VERSION_H" > ${VERSION_H}
|
||||||
|
echo "#define VERSION_H" >> ${VERSION_H}
|
||||||
|
echo "" >> ${VERSION_H}
|
||||||
|
echo "" >> ${VERSION_H}
|
||||||
|
echo "#define INTERFACE_VERSION \"${INTERFACE_VERSION}\"" >> ${VERSION_H}
|
||||||
|
echo "#define PLUGIN_VERSION \"${PLUGIN_VERSION}\"" >> ${VERSION_H}
|
||||||
|
echo "" >> ${VERSION_H}
|
||||||
|
echo "#define PLUGIN_GIT_DESCRIBE \"${PLUGIN_GIT_DESCRIBE}\"" >> ${VERSION_H}
|
||||||
|
echo "" >> ${VERSION_H}
|
||||||
|
echo "" >> ${VERSION_H}
|
||||||
|
|
||||||
|
cat <<EOT >> ${VERSION_H}
|
||||||
|
|
||||||
|
const std::string pluginInfoString = R"(
|
||||||
|
{
|
||||||
|
"Interface": "${INTERFACE}",
|
||||||
|
"InterfaceVersion": "${INTERFACE_VERSION}",
|
||||||
|
"PluginName": "${TARGET}",
|
||||||
|
"Version": "${PLUGIN_VERSION}",
|
||||||
|
"git-describe": "${PLUGIN_GIT_DESCRIBE}",
|
||||||
|
}
|
||||||
|
)";
|
||||||
|
|
||||||
|
EOT
|
||||||
|
|
||||||
|
echo "" >> ${VERSION_H}
|
||||||
|
echo "" >> ${VERSION_H}
|
||||||
|
if [ ${DEVDIRTY} == "true" ] ; then
|
||||||
|
echo "#define DEVDIRTY" >> ${VERSION_H}
|
||||||
|
echo "" >> ${VERSION_H}
|
||||||
|
echo "" >> ${VERSION_H}
|
||||||
|
fi
|
||||||
|
echo "#define SYSTEM_ARCH \"${ARCH}\"" >> ${VERSION_H}
|
||||||
|
echo "#define ARCH_${ARCH}" >> ${VERSION_H}
|
||||||
|
echo "" >> ${VERSION_H}
|
||||||
|
echo "" >> ${VERSION_H}
|
||||||
|
echo "#endif //VERSION_H" >> ${VERSION_H}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user