Fix version bump system, add "-v" for version

This commit is contained in:
Matti Viljanen 2020-03-23 04:08:09 +02:00
parent fe8b27d18c
commit 98749ef219
No known key found for this signature in database
GPG key ID: CF32A1495158F888
4 changed files with 30 additions and 10 deletions

View file

@ -12,9 +12,14 @@
# The name of your application
TARGET = harbour-batterybuddy
CONFIG += sailfishapp sailfishapp_i18n
CONFIG += console sailfishapp sailfishapp_i18n
DEFINES += QT_NO_DEBUG_OUTPUT
VER = 2.1
REL = 2
VERSION = $${VER}-$${REL}
$$system(bash update-spec-version.sh $$TARGET $$VER $$REL)
DEFINES += APP_VERSION=\"\\\"$$VERSION\\\"\"
HEADERS += \
src/battery.h \

View file

@ -72,7 +72,7 @@ Page {
AboutLabel {
font.pixelSize: Theme.fontSizeSmall
color: Theme.secondaryColor
text: qsTr("Version") + " 2.1-2"
text: qsTr("Version") + " " + app_version
}
AboutLabel {

View file

@ -27,9 +27,7 @@
#include <QQmlEngine>
#include <QTimer>
#include <QDebug>
#ifdef QT_NO_DEBUG_OUTPUT
#include <QLoggingCategory>
#endif
#include <iostream>
#include "battery.h"
#include "settings.h"
@ -46,10 +44,13 @@ int main(int argc, char *argv[])
//
// To display the view, call "show()" (will show fullscreen on device).
#ifdef QT_NO_DEBUG_OUTPUT
// Disable QML debug level logging
QLoggingCategory::setFilterRules("*.debug=false");
#endif
const char* logEnvVar = "QT_LOGGING_RULES";
for(int i = 1; i < argc; i++) {
if(!strcmp(argv[i],"-v")) {
std::cout << "Battery Buddy " << APP_VERSION << std::endl << std::flush;
return 0;
}
}
qInfo() << "Starting Battery Buddy...";
@ -68,6 +69,7 @@ int main(int argc, char *argv[])
view->rootContext()->setContextProperty("battery", battery);
view->rootContext()->setContextProperty("settings", settings);
view->rootContext()->setContextProperty("app_version", APP_VERSION);
view->setSource(SailfishApp::pathTo("qml/harbour-batterybuddy.qml"));
view->showFullScreen();

13
update-spec-version.sh Executable file
View file

@ -0,0 +1,13 @@
#!/bin/bash
SPEC=rpm/$1.spec
if [[ $(grep "^Version: $2$" $SPEC | wc -l) = 0 ]]
then
sed -i "/^Version: /c\Version: $2" $SPEC
touch src/$1.cpp
fi
if [[ $(grep "^Release: $3$" $SPEC | wc -l) = 0 ]]
then
sed -i "/^Release: /c\Release: $3" $SPEC
touch src/$1.cpp
fi
echo true