aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorRobin Jarry <robin@jarry.cc>2024-01-31 22:51:00 +0100
committerRobin Jarry <robin@jarry.cc>2024-02-01 00:59:01 +0100
commit69e63b529ae16d9f26ed67b2831d0c1756ef267d (patch)
treec0b6f145e9f169beebd6d6fad58147d3d265eec2 /lib
parent4cc2e6be3a010ecfba314909ce9b594f04e1be0e (diff)
downloadaerc-69e63b529ae16d9f26ed67b2831d0c1756ef267d.tar.gz
main: improve version string
Initialize a build variable to the date on which the binary was generated. Include the date in the build info string which is output when running aerc -v and in the crash logs. Do not rely on parsing the build flags via some obscure base64 voodoo to determine if notmuch support is available or not. Instead, use the symbols from the linked library directly if available. Before: $ aerc -v 0.16.0-183-g4cc2e6be3a01 +notmuch (go1.21.6 amd64 linux) After: $ aerc -v aerc 0.16.0-183-g4cc2e6be3a01 +notmuch-5.6.0 (go1.21.6 amd64 linux 2024-01-31) Signed-off-by: Robin Jarry <robin@jarry.cc> Acked-by: CiarĂ¡n Ainsworth <cda@sporiff.dev>
Diffstat (limited to 'lib')
-rw-r--r--lib/notmuch/notmuch.go11
-rw-r--r--lib/notmuch_version.go10
-rw-r--r--lib/notmuch_version_dummy.go8
3 files changed, 29 insertions, 0 deletions
diff --git a/lib/notmuch/notmuch.go b/lib/notmuch/notmuch.go
index 9b13878b..27c0bdfa 100644
--- a/lib/notmuch/notmuch.go
+++ b/lib/notmuch/notmuch.go
@@ -15,6 +15,17 @@ package notmuch
*/
import "C"
+import "fmt"
+
+const (
+ MAJOR_VERSION = C.LIBNOTMUCH_MAJOR_VERSION
+ MINOR_VERSION = C.LIBNOTMUCH_MINOR_VERSION
+ MICRO_VERSION = C.LIBNOTMUCH_MICRO_VERSION
+)
+
+func Version() string {
+ return fmt.Sprintf("%d.%d.%d", MAJOR_VERSION, MINOR_VERSION, MICRO_VERSION)
+}
// NOTE: Any CGO call which passes a reference to a pointer (**object) will fail
// gocritic:dupSubExpr. All of these calls are set to be ignored by the linter
diff --git a/lib/notmuch_version.go b/lib/notmuch_version.go
new file mode 100644
index 00000000..c2025bda
--- /dev/null
+++ b/lib/notmuch_version.go
@@ -0,0 +1,10 @@
+//go:build notmuch
+// +build notmuch
+
+package lib
+
+import "git.sr.ht/~rjarry/aerc/lib/notmuch"
+
+func NotmuchVersion() (string, bool) {
+ return notmuch.Version(), true
+}
diff --git a/lib/notmuch_version_dummy.go b/lib/notmuch_version_dummy.go
new file mode 100644
index 00000000..f04905e1
--- /dev/null
+++ b/lib/notmuch_version_dummy.go
@@ -0,0 +1,8 @@
+//go:build !notmuch
+// +build !notmuch
+
+package lib
+
+func NotmuchVersion() (string, bool) {
+ return "", false
+}