aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorDanilo M. <danix@danix.xyz>2026-08-25 17:32:53 +0200
committerDanilo M. <danix@danix.xyz>2026-08-25 17:32:53 +0200
commit1cc12b86dfb036ea4ee5100ca6653d3c3b054195 (patch)
treece3dfa3e9b288cd1090f5c6839a481fa200d7ff2 /src
parent6ea6980d064d1a27470b077c17adab286e4510b1 (diff)
downloadqtmaildir-1cc12b86dfb036ea4ee5100ca6653d3c3b054195.tar.gz
qtmaildir-1cc12b86dfb036ea4ee5100ca6653d3c3b054195.zip
feat: number each build of a dev tree
The version alone cannot tell one build of an unreleased X.Y.Z from another, and the user rebuilds and hand-tests unreleased builds daily. They chose a counter over a git description: what they want to know is that the binary is newer than the one they were running, not which commit it came from. QTMAILDIR_BUILD_NUMBER is a cmake option, ON by default, that runs cmake/BuildNumber.cmake as a build step to increment a counter and write buildnumber.h. It had to be a build step: configure_file runs once per cmake run, so a counter interpolated into version.h.in would sit still across exactly the rebuilds this exists to distinguish, which is why version.h.in includes a second generated header rather than carrying the number itself. Two macros, and the split is load-bearing. QTMAILDIR_VERSION stays a clean X.Y.Z and keeps the window title, applicationVersion and anything that might ever compare versions; QTMAILDIR_VERSION_DISPLAY carries the number and goes to the three surfaces the user picked, --version and --help, the About dialog, and the placeholder pane. The window title was offered and declined, since the number would then be in every screenshot. The counter lives in the build directory and is not tracked, so it cannot conflict on a pull or leave the tree dirty; a fresh build directory restarts at 1, which is honest, because it is a different build tree. A release passes -DQTMAILDIR_BUILD_NUMBER=OFF and the header is written empty. The SlackBuild in the my-slackbuilds repo needs that flag and is a separate commit there. Verified by running it, since none of this is reachable from a C++ test: three consecutive builds reported build 2, 3 and 4, and a separate Release configure with the option OFF reported a clean 0.27.0. Passing the flag to a tree that does not have the option yet is an unused-cli warning and exit 0, so the SlackBuild change is safe before 0.28.0 ships. The suite is 37 of 38, the one failure being item 136 on an unrelated path. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01HFuRPtzFrSxCQjFk6tq7gD
Diffstat (limited to 'src')
-rw-r--r--src/CMakeLists.txt6
-rw-r--r--src/main.cpp4
-rw-r--r--src/mainwindow.cpp2
-rw-r--r--src/messageview.cpp2
-rw-r--r--src/version.h.in23
5 files changed, 33 insertions, 4 deletions
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 700b185..4d9dbaa 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -44,6 +44,12 @@ target_include_directories(qtmaildir_lib
PUBLIC ${CMAKE_CURRENT_SOURCE_DIR} ${NOTMUCH_INCLUDE_DIR}
${CMAKE_BINARY_DIR}/generated/qtmaildir)
+# The counter target rewrites buildnumber.h, which version.h includes, so the
+# library must not start compiling before it has run.
+if(TARGET qtmaildir_buildnumber)
+ add_dependencies(qtmaildir_lib qtmaildir_buildnumber)
+endif()
+
target_link_libraries(qtmaildir_lib
PUBLIC Qt6::Widgets Qt6::Svg Qt6::WebEngineWidgets PkgConfig::GMIME
${NOTMUCH_LIBRARY} PkgConfig::CMARK_GFM
diff --git a/src/main.cpp b/src/main.cpp
index 2ed8057..a7908d0 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -43,7 +43,7 @@ int main(int argc, char *argv[])
for (int i = 1; i < argc; ++i) {
if (std::strcmp(argv[i], "--version") == 0
|| std::strcmp(argv[i], "-v") == 0) {
- std::printf("qtmaildir %s\n", QTMAILDIR_VERSION);
+ std::printf("qtmaildir %s\n", QTMAILDIR_VERSION_DISPLAY);
return 0;
}
if (std::strcmp(argv[i], "--help") == 0
@@ -59,7 +59,7 @@ int main(int argc, char *argv[])
"Configuration: ~/.config/qtmaildir/qtmaildir.conf\n"
"qtmaildir reads a notmuch-indexed Maildir. It does no network\n"
"protocol work: fetching and sending are external commands.\n",
- QTMAILDIR_VERSION);
+ QTMAILDIR_VERSION_DISPLAY);
return 0;
}
}
diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp
index 5845922..6b48880 100644
--- a/src/mainwindow.cpp
+++ b/src/mainwindow.cpp
@@ -2446,7 +2446,7 @@ void MainWindow::showAbout()
"version 2.</p>"
"<p>Developed with AI assistance. All code is reviewed, "
"tested and curated by the maintainer.</p>")
- .arg(QStringLiteral(QTMAILDIR_VERSION)));
+ .arg(QStringLiteral(QTMAILDIR_VERSION_DISPLAY)));
auto *link = new QLabel(
QStringLiteral("<a href='https://danix.xyz/qtmaildir'>"
diff --git a/src/messageview.cpp b/src/messageview.cpp
index 86e40eb..eb0dccd 100644
--- a/src/messageview.cpp
+++ b/src/messageview.cpp
@@ -544,7 +544,7 @@ void MessageView::showPlaceholder(
// uses it: a style sheet or a themed parent can give this pane different
// colours from the application.
setDocument(HtmlBuilder::buildPlaceholder(
- helpers, QStringLiteral(QTMAILDIR_VERSION),
+ helpers, QStringLiteral(QTMAILDIR_VERSION_DISPLAY),
HtmlBuilder::brandPaletteFrom(palette())));
}
diff --git a/src/version.h.in b/src/version.h.in
index 8d76a3a..743adc5 100644
--- a/src/version.h.in
+++ b/src/version.h.in
@@ -25,3 +25,26 @@
#define QTMAILDIR_VERSION_MINOR @PROJECT_VERSION_MINOR@
#define QTMAILDIR_VERSION_PATCH @PROJECT_VERSION_PATCH@
#define QTMAILDIR_VERSION "@PROJECT_VERSION@"
+
+/// The version as shown to a person, which in a DEV build carries the build
+/// number and in a release build is exactly QTMAILDIR_VERSION.
+///
+/// Two separate macros deliberately. The release procedure checks `--version`
+/// against a clean X.Y.Z, the SlackBuild builds from a release tarball where
+/// no build counter exists, and the window title is a poor place for a number
+/// that changes on every rebuild. Anything comparing versions uses
+/// QTMAILDIR_VERSION; anything a person reads to answer "which build am I
+/// running" uses this one.
+///
+/// buildnumber.h is generated at BUILD time, not here: this file is written
+/// by configure_file(), which runs once per cmake run, so a counter
+/// interpolated into it would sit still across every rebuild, which is the
+/// entire thing item 167 is about. It defines QTMAILDIR_BUILD_NUMBER only in
+/// a dev build.
+#include "buildnumber.h"
+
+#ifdef QTMAILDIR_BUILD_NUMBER
+# define QTMAILDIR_VERSION_DISPLAY QTMAILDIR_VERSION " build " QTMAILDIR_BUILD_NUMBER
+#else
+# define QTMAILDIR_VERSION_DISPLAY QTMAILDIR_VERSION
+#endif