Merge pull request #226 from probonopd/TheAssassin/version-statement
Implement "fancy" version statement
This commit is contained in:
@@ -11,6 +11,10 @@ env:
|
|||||||
before_install:
|
before_install:
|
||||||
- ./tests/tests-environment.sh
|
- ./tests/tests-environment.sh
|
||||||
|
|
||||||
|
before_script:
|
||||||
|
# fetch all tags
|
||||||
|
- git fetch --unshallow
|
||||||
|
|
||||||
script:
|
script:
|
||||||
- ./tests/tests-ci.sh
|
- ./tests/tests-ci.sh
|
||||||
|
|
||||||
|
|||||||
@@ -5,4 +5,52 @@ cmake_minimum_required(VERSION 3.2)
|
|||||||
|
|
||||||
project(linuxdeployqt)
|
project(linuxdeployqt)
|
||||||
|
|
||||||
|
# read Git revision ID
|
||||||
|
execute_process(
|
||||||
|
COMMAND git rev-parse --short HEAD
|
||||||
|
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
|
||||||
|
OUTPUT_VARIABLE GIT_COMMIT
|
||||||
|
OUTPUT_STRIP_TRAILING_WHITESPACE
|
||||||
|
)
|
||||||
|
|
||||||
|
# make sure Git revision ID and latest tag is not stored in the CMake cache
|
||||||
|
# otherwise, one would have to reset the CMake cache on every new commit to make sure the Git commit ID is up to date
|
||||||
|
unset(GIT_COMMIT CACHE)
|
||||||
|
unset(GIT_LATEST_TAG CACHE)
|
||||||
|
|
||||||
|
# read Git revision ID and latest tag number
|
||||||
|
execute_process(
|
||||||
|
COMMAND git rev-parse --short HEAD
|
||||||
|
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
|
||||||
|
OUTPUT_VARIABLE GIT_COMMIT
|
||||||
|
OUTPUT_STRIP_TRAILING_WHITESPACE
|
||||||
|
)
|
||||||
|
execute_process(
|
||||||
|
COMMAND git rev-list --tags --skip=1 --max-count=1
|
||||||
|
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
|
||||||
|
OUTPUT_VARIABLE GIT_TAG_ID
|
||||||
|
OUTPUT_STRIP_TRAILING_WHITESPACE
|
||||||
|
)
|
||||||
|
execute_process(
|
||||||
|
COMMAND git describe --tags ${GIT_TAG_ID} --abbrev=0
|
||||||
|
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
|
||||||
|
OUTPUT_VARIABLE GIT_TAG_NAME
|
||||||
|
OUTPUT_STRIP_TRAILING_WHITESPACE
|
||||||
|
)
|
||||||
|
|
||||||
|
# set version and build number
|
||||||
|
set(VERSION 1-alpha)
|
||||||
|
if("$ENV{TRAVIS_BUILD_NUMBER}" STREQUAL "")
|
||||||
|
set(BUILD_NUMBER "<local dev build>")
|
||||||
|
else()
|
||||||
|
set(BUILD_NUMBER "$ENV{TRAVIS_BUILD_NUMBER}")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
# get current date
|
||||||
|
execute_process(
|
||||||
|
COMMAND env LC_ALL=C date -u "+%Y-%m-%d %H:%M:%S %Z"
|
||||||
|
OUTPUT_VARIABLE DATE
|
||||||
|
OUTPUT_STRIP_TRAILING_WHITESPACE
|
||||||
|
)
|
||||||
|
|
||||||
add_subdirectory(tools/linuxdeployqt)
|
add_subdirectory(tools/linuxdeployqt)
|
||||||
|
|||||||
@@ -1,5 +1,11 @@
|
|||||||
set(CMAKE_AUTOMOC ON)
|
set(CMAKE_AUTOMOC ON)
|
||||||
|
|
||||||
|
# expose version data as compiler definition
|
||||||
|
add_definitions("-DLINUXDEPLOYQT_VERSION=\"${GIT_TAG_NAME}\"")
|
||||||
|
add_definitions("-DLINUXDEPLOYQT_GIT_COMMIT=\"${GIT_COMMIT}\"")
|
||||||
|
add_definitions("-DBUILD_DATE=\"${DATE}\"")
|
||||||
|
add_definitions("-DBUILD_NUMBER=\"${BUILD_NUMBER}\"")
|
||||||
|
|
||||||
find_package(Qt5 REQUIRED COMPONENTS Core)
|
find_package(Qt5 REQUIRED COMPONENTS Core)
|
||||||
|
|
||||||
add_executable(linuxdeployqt main.cpp shared.cpp)
|
add_executable(linuxdeployqt main.cpp shared.cpp)
|
||||||
|
|||||||
@@ -15,3 +15,19 @@ SOURCES += main.cpp \
|
|||||||
shared.cpp
|
shared.cpp
|
||||||
|
|
||||||
DEFINES -= QT_USE_QSTRINGBUILDER #leads to compile errors if not disabled
|
DEFINES -= QT_USE_QSTRINGBUILDER #leads to compile errors if not disabled
|
||||||
|
|
||||||
|
# versioning
|
||||||
|
# don't break the quotes -- at the moment, the shell commands are injected into the Makefile to have them run on every
|
||||||
|
# build and not during configure time
|
||||||
|
|
||||||
|
DEFINES += LINUXDEPLOYQT_GIT_COMMIT="'\"$(shell git rev-parse --short HEAD)\"'"
|
||||||
|
|
||||||
|
DEFINES += BUILD_DATE="'\"$(shell env LC_ALL=C date -u '+%Y-%m-%d %H:%M:%S %Z')\"'"
|
||||||
|
|
||||||
|
equals($$(TRAVIS_BUILD_NUMBER), "") {
|
||||||
|
DEFINES += BUILD_NUMBER="'\"<local dev build>\"'"
|
||||||
|
} else {
|
||||||
|
DEFINES += BUILD_NUMBER="'\"$$(TRAVIS_BUILD_NUMBER)\"'"
|
||||||
|
}
|
||||||
|
|
||||||
|
DEFINES += LINUXDEPLOYQT_VERSION="'\"$(shell git describe --tags $(shell git rev-list --tags --skip=1 --max-count=1) --abbrev=0)\"'"
|
||||||
|
|||||||
@@ -33,6 +33,7 @@
|
|||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <QSettings>
|
#include <QSettings>
|
||||||
#include <QDirIterator>
|
#include <QDirIterator>
|
||||||
|
#include <sstream>
|
||||||
|
|
||||||
int main(int argc, char **argv)
|
int main(int argc, char **argv)
|
||||||
{
|
{
|
||||||
@@ -43,41 +44,61 @@ int main(int argc, char **argv)
|
|||||||
|
|
||||||
QString firstArgument = QString::fromLocal8Bit(argv[1]);
|
QString firstArgument = QString::fromLocal8Bit(argv[1]);
|
||||||
|
|
||||||
if (argc < 2 || firstArgument.startsWith("-")) {
|
// print version statement
|
||||||
qDebug() << "Usage: linuxdeployqt <app-binary|desktop file> [options]";
|
std::stringstream version;
|
||||||
qDebug() << "";
|
version << "linuxdeployqt " << LINUXDEPLOYQT_VERSION
|
||||||
qDebug() << "Options:";
|
<< " (commit " << LINUXDEPLOYQT_GIT_COMMIT << "), "
|
||||||
qDebug() << " -verbose=<0-3> : 0 = no output, 1 = error/warning (default),";
|
<< "build " << BUILD_NUMBER << " built on " << BUILD_DATE;
|
||||||
qDebug() << " 2 = normal, 3 = debug";
|
qInfo().noquote() << QString::fromStdString(version.str());
|
||||||
qDebug() << " -no-plugins : Skip plugin deployment";
|
|
||||||
qDebug() << " -appimage : Create an AppImage (implies -bundle-non-qt-libs)";
|
// due to the structure of the argument parser, we have to check all arguments at first to check whether the user
|
||||||
qDebug() << " -no-strip : Don't run 'strip' on the binaries";
|
// wants to get the version only
|
||||||
qDebug() << " -bundle-non-qt-libs : Also bundle non-core, non-Qt libraries";
|
// TODO: replace argument parser with position independent, less error prone version
|
||||||
qDebug() << " -executable=<path> : Let the given executable use the deployed libraries";
|
for (int i = 0; i < argc; i++ ) {
|
||||||
qDebug() << " too";
|
QString argument = argv[i];
|
||||||
qDebug() << " -qmldir=<path> : Scan for QML imports in the given path";
|
if (argument == "-version" || argument == "-V" || argument == "--version") {
|
||||||
qDebug() << " -always-overwrite : Copy files even if the target file exists";
|
// can just exit normally, version has been printed above
|
||||||
qDebug() << " -qmake=<path> : The qmake executable to use";
|
return 0;
|
||||||
qDebug() << " -no-translations : Skip deployment of translations.";
|
}
|
||||||
qDebug() << " -extra-plugins=<list> : List of extra plugins which should be deployed,";
|
}
|
||||||
qDebug() << " separated by comma.";
|
|
||||||
qDebug() << "";
|
if (argc < 2 || (firstArgument.startsWith("-"))) {
|
||||||
qDebug() << "linuxdeployqt takes an application as input and makes it";
|
qInfo() << "";
|
||||||
qDebug() << "self-contained by copying in the Qt libraries and plugins that";
|
qInfo() << "Usage: linuxdeployqt <app-binary|desktop file> [options]";
|
||||||
qDebug() << "the application uses.";
|
qInfo() << "";
|
||||||
qDebug() << "";
|
qInfo() << "Options:";
|
||||||
qDebug() << "By default it deploys the Qt instance that qmake on the $PATH points to.";
|
qInfo() << " -verbose=<0-3> : 0 = no output, 1 = error/warning (default),";
|
||||||
qDebug() << "The '-qmake' option can be used to point to the qmake executable";
|
qInfo() << " 2 = normal, 3 = debug";
|
||||||
qDebug() << "to be used instead.";
|
qInfo() << " -no-plugins : Skip plugin deployment";
|
||||||
qDebug() << "";
|
qInfo() << " -appimage : Create an AppImage (implies -bundle-non-qt-libs)";
|
||||||
qDebug() << "Plugins related to a Qt library are copied in with the library.";
|
qInfo() << " -no-strip : Don't run 'strip' on the binaries";
|
||||||
|
qInfo() << " -bundle-non-qt-libs : Also bundle non-core, non-Qt libraries";
|
||||||
|
qInfo() << " -executable=<path> : Let the given executable use the deployed libraries";
|
||||||
|
qInfo() << " too";
|
||||||
|
qInfo() << " -qmldir=<path> : Scan for QML imports in the given path";
|
||||||
|
qInfo() << " -always-overwrite : Copy files even if the target file exists";
|
||||||
|
qInfo() << " -qmake=<path> : The qmake executable to use";
|
||||||
|
qInfo() << " -no-translations : Skip deployment of translations.";
|
||||||
|
qInfo() << " -extra-plugins=<list> : List of extra plugins which should be deployed,";
|
||||||
|
qInfo() << " separated by comma.";
|
||||||
|
qInfo() << " -version : Print version statement and exit.";
|
||||||
|
qInfo() << "";
|
||||||
|
qInfo() << "linuxdeployqt takes an application as input and makes it";
|
||||||
|
qInfo() << "self-contained by copying in the Qt libraries and plugins that";
|
||||||
|
qInfo() << "the application uses.";
|
||||||
|
qInfo() << "";
|
||||||
|
qInfo() << "By default it deploys the Qt instance that qmake on the $PATH points to.";
|
||||||
|
qInfo() << "The '-qmake' option can be used to point to the qmake executable";
|
||||||
|
qInfo() << "to be used instead.";
|
||||||
|
qInfo() << "";
|
||||||
|
qInfo() << "Plugins related to a Qt library are copied in with the library.";
|
||||||
/* TODO: To be implemented
|
/* TODO: To be implemented
|
||||||
qDebug() << "The accessibility, image formats, and text codec";
|
qDebug() << "The accessibility, image formats, and text codec";
|
||||||
qDebug() << "plugins are always copied, unless \"-no-plugins\" is specified.";
|
qDebug() << "plugins are always copied, unless \"-no-plugins\" is specified.";
|
||||||
*/
|
*/
|
||||||
qDebug() << "";
|
qInfo() << "";
|
||||||
qDebug() << "See the \"Deploying Applications on Linux\" topic in the";
|
qInfo() << "See the \"Deploying Applications on Linux\" topic in the";
|
||||||
qDebug() << "documentation for more information about deployment on Linux.";
|
qInfo() << "documentation for more information about deployment on Linux.";
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
@@ -389,8 +410,11 @@ int main(int argc, char **argv)
|
|||||||
} else if (argument.startsWith("-extra-plugins=")) {
|
} else if (argument.startsWith("-extra-plugins=")) {
|
||||||
LogDebug() << "Argument found:" << argument;
|
LogDebug() << "Argument found:" << argument;
|
||||||
int index = argument.indexOf("=");
|
int index = argument.indexOf("=");
|
||||||
extraQtPlugins = QString(argument.mid(index+1)).split(",");
|
extraQtPlugins = QString(argument.mid(index + 1)).split(",");
|
||||||
} else if (argument.startsWith("-")) {
|
} else if (argument.startsWith("-")) {
|
||||||
|
LogError() << "Error: arguments must not start with --, only -" << "\n";
|
||||||
|
return 1;
|
||||||
|
} else {
|
||||||
LogError() << "Unknown argument" << argument << "\n";
|
LogError() << "Unknown argument" << argument << "\n";
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user