diff --git a/CMakeLists.txt b/CMakeLists.txt index 27fa9ae5d..052ec48de 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -3,7 +3,6 @@ cmake_minimum_required(VERSION 3.16 FATAL_ERROR) # Policies <= CMP0097 default t list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake/Modules) project(qBittorrent - VERSION 4.4.0.0 DESCRIPTION "The qBittorrent BitTorrent client" HOMEPAGE_URL "https://www.qbittorrent.org/" LANGUAGES CXX @@ -55,25 +54,12 @@ include(GNUInstallDirs) add_subdirectory(src) add_subdirectory(dist) -# Generate version header -set(QBT_VER_STATUS "alpha1" CACHE STRING "Project status version. Should be empty for release builds.") - -set(QBT_PROJECT_VERSION "${qBittorrent_VERSION_MAJOR}.${qBittorrent_VERSION_MINOR}.${qBittorrent_VERSION_PATCH}") -if (NOT ${qBittorrent_VERSION_TWEAK} EQUAL 0) - set(QBT_PROJECT_VERSION "${QBT_PROJECT_VERSION}.${qBittorrent_VERSION_TWEAK}") -endif() -set(QBT_PROJECT_VERSION "${QBT_PROJECT_VERSION}${QBT_VER_STATUS}") - -file(READ "src/base/version.h.in" versionHeader) -string(REPLACE "@VER_MAJOR@" ${qBittorrent_VERSION_MAJOR} versionHeader "${versionHeader}") -string(REPLACE "@VER_MINOR@" ${qBittorrent_VERSION_MINOR} versionHeader "${versionHeader}") -string(REPLACE "@VER_BUGFIX@" ${qBittorrent_VERSION_PATCH} versionHeader "${versionHeader}") -string(REPLACE "@VER_BUILD@" ${qBittorrent_VERSION_TWEAK} versionHeader "${versionHeader}") -string(REPLACE "@PROJECT_VERSION@" ${QBT_PROJECT_VERSION} versionHeader "${versionHeader}") -file(WRITE "src/base/version.h" "${versionHeader}") - if (VERBOSE_CONFIGURE) feature_summary(WHAT ALL) else() feature_summary(WHAT ENABLED_FEATURES DISABLED_FEATURES) endif() + +# Generate version header +file(READ "src/base/version.h.in" versionHeader) +file(WRITE "src/base/version.h" "${versionHeader}") diff --git a/build_dist.sh b/build_dist.sh new file mode 100755 index 000000000..aa00205d7 --- /dev/null +++ b/build_dist.sh @@ -0,0 +1,19 @@ +#!/bin/sh + +# get version numbers +versionSrc="src/base/version.h.in" +versionMajor="$(grep -Po '(?<=QBT_VERSION_MAJOR )\d+' "$versionSrc")" +versionMinor="$(grep -Po '(?<=QBT_VERSION_MINOR )\d+' "$versionSrc")" +versionBugfix="$(grep -Po '(?<=QBT_VERSION_BUGFIX )\d+' "$versionSrc")" +versionBuild="$(grep -Po '(?<=QBT_VERSION_BUILD )\d+' "$versionSrc")" +versionStatus="$(grep -Po '(?<=QBT_VERSION_STATUS ")\w+' "$versionSrc")" + +if [ "$versionBuild" != "0" ]; then + projectVersion="$versionMajor.$versionMinor.$versionBugfix.$versionBuild$versionStatus" +else + projectVersion="$versionMajor.$versionMinor.$versionBugfix$versionStatus" +fi + +# pack archives +git archive --format=tar --prefix="qbittorrent-$projectVersion/" HEAD | gzip -9 > "qbittorrent-$projectVersion.tar.gz" +git archive --format=tar --prefix="qbittorrent-$projectVersion/" HEAD | xz -9 > "qbittorrent-$projectVersion.tar.xz" diff --git a/qbittorrent.pro b/qbittorrent.pro index a7f2a137d..0d5f80872 100644 --- a/qbittorrent.pro +++ b/qbittorrent.pro @@ -4,19 +4,6 @@ SUBDIRS += src include(version.pri) -# Make target to create release tarball. Use 'make tarball' -tarball.commands += rm -fR ../$${PROJECT_NAME}-$${PROJECT_VERSION}/ && -tarball.commands += git clone . ../$${PROJECT_NAME}-$${PROJECT_VERSION} && -tarball.commands += rm -fR ../$${PROJECT_NAME}-$${PROJECT_VERSION}/.git && -tarball.commands += rm -f ../$${PROJECT_NAME}-$${PROJECT_VERSION}/.gitignore && -tarball.commands += cd .. && -tarball.commands += tar czf $${PROJECT_NAME}-$${PROJECT_VERSION}.tar.gz $${PROJECT_NAME}-$${PROJECT_VERSION} && -tarball.commands += tar cf $${PROJECT_NAME}-$${PROJECT_VERSION}.tar $${PROJECT_NAME}-$${PROJECT_VERSION} && -tarball.commands += xz -f $${PROJECT_NAME}-$${PROJECT_VERSION}.tar && -tarball.commands += rm -fR $${PROJECT_NAME}-$${PROJECT_VERSION} - -QMAKE_EXTRA_TARGETS += tarball - # For Qt Creator beautifier DISTFILES += \ uncrustify.cfg diff --git a/src/base/version.h.in b/src/base/version.h.in index 070f5228f..a2000289e 100644 --- a/src/base/version.h.in +++ b/src/base/version.h.in @@ -28,10 +28,20 @@ #pragma once -#define QBT_VERSION_MAJOR @VER_MAJOR@ -#define QBT_VERSION_MINOR @VER_MINOR@ -#define QBT_VERSION_BUGFIX @VER_BUGFIX@ -#define QBT_VERSION_BUILD @VER_BUILD@ +#define QBT_VERSION_MAJOR 4 +#define QBT_VERSION_MINOR 4 +#define QBT_VERSION_BUGFIX 0 +#define QBT_VERSION_BUILD 0 +#define QBT_VERSION_STATUS "alpha1" // Should be empty for stable releases! -#define QBT_VERSION "v@PROJECT_VERSION@" -#define QBT_VERSION_2 "@PROJECT_VERSION@" +#define QBT__STRINGIFY(x) #x +#define QBT_STRINGIFY(x) QBT__STRINGIFY(x) + +#if (QBT_VERSION_BUILD != 0) +#define PROJECT_VERSION QBT_STRINGIFY(QBT_VERSION_MAJOR.QBT_VERSION_MINOR.QBT_VERSION_BUGFIX.QBT_VERSION_BUILD) QBT_VERSION_STATUS +#else +#define PROJECT_VERSION QBT_STRINGIFY(QBT_VERSION_MAJOR.QBT_VERSION_MINOR.QBT_VERSION_BUGFIX) QBT_VERSION_STATUS +#endif + +#define QBT_VERSION "v" PROJECT_VERSION +#define QBT_VERSION_2 PROJECT_VERSION diff --git a/version.pri b/version.pri index 9c6f2864e..39c55c73b 100644 --- a/version.pri +++ b/version.pri @@ -1,27 +1,3 @@ -# keep it all lowercase to match program naming convention on *nix systems -PROJECT_NAME = qbittorrent - -# Define version numbers here -VER_MAJOR = 4 -VER_MINOR = 4 -VER_BUGFIX = 0 -VER_BUILD = 0 -VER_STATUS = alpha1 # Should be empty for stable releases! - -# Don't touch the rest part -PROJECT_VERSION = $${VER_MAJOR}.$${VER_MINOR}.$${VER_BUGFIX} - -!equals(VER_BUILD, 0) { - PROJECT_VERSION = $${PROJECT_VERSION}.$${VER_BUILD} -} - -PROJECT_VERSION = $${PROJECT_VERSION}$${VER_STATUS} - # Generate version header versionHeader = $$cat(src/base/version.h.in, blob) -versionHeader = $$replace(versionHeader, "@VER_MAJOR@", $$VER_MAJOR) -versionHeader = $$replace(versionHeader, "@VER_MINOR@", $$VER_MINOR) -versionHeader = $$replace(versionHeader, "@VER_BUGFIX@", $$VER_BUGFIX) -versionHeader = $$replace(versionHeader, "@VER_BUILD@", $$VER_BUILD) -versionHeader = $$replace(versionHeader, "@PROJECT_VERSION@", $$PROJECT_VERSION) write_file(src/base/version.h, versionHeader)