aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarvin W <git@larma.de>2026-08-22 16:21:13 +0200
committerMarvin W <git@larma.de>2026-10-23 16:58:29 +0200
commitc71601077699df8464fce4cf9dc11bea598c071e (patch)
tree7d2e785dc45c0707638c0752b67f07646b356fa6
parentd34b9fcb37fa79738582392e194e76651cd4adc2 (diff)
Use meson native project version
-rw-r--r--build-aux/version.py (renamed from libdino/version.py)19
-rw-r--r--libdino/meson.build17
-rw-r--r--libdino/src/application.vala8
-rw-r--r--libdino/src/version.c.in4
-rw-r--r--libdino/src/version.vala.in5
-rw-r--r--main/src/ui/main_window.vala3
-rw-r--r--meson.build45
7 files changed, 62 insertions, 39 deletions
diff --git a/libdino/version.py b/build-aux/version.py
index 87490d18..45fdfcd3 100644
--- a/libdino/version.py
+++ b/build-aux/version.py
@@ -54,11 +54,26 @@ def main():
p = argparse.ArgumentParser(description="Compute the Dino version")
p.add_argument("--git-repo", help="Path to checked out git repository")
p.add_argument("--git", help="Path to git executable", default="git")
+ p.add_argument("--depfile", help="Create depfile")
+ p.add_argument("--deptarget", help="Target in depfile")
p.add_argument("version_file", metavar="VERSION_FILE",
help="Use this file's contents as version if the file exists")
args, unknown = p.parse_known_args()
- version = compute_version(args.version_file, args.git_repo, args.git)
- print(version)
+ if args.depfile:
+ with open(args.depfile, mode='w') as f:
+ f.write("version.stamp: ")
+ f.write(args.git_repo + "/VERSION ")
+ f.write(args.git_repo + "/.git/HEAD ")
+ try:
+ with open(args.git_repo + "/.git/HEAD") as f2:
+ head = f2.read().strip()
+ if head.startswith("ref:"):
+ f.write(args.git_repo + "/.git/" + head[4:].strip())
+ except FileNotFoundError:
+ pass
+ else:
+ version = compute_version(args.version_file, args.git_repo, args.git)
+ print(version)
if __name__ == "__main__":
diff --git a/libdino/meson.build b/libdino/meson.build
index 12665b18..d0bb2cef 100644
--- a/libdino/meson.build
+++ b/libdino/meson.build
@@ -1,17 +1,4 @@
-# version_vala
-version_py = files('version.py')[0]
-if meson.version().version_compare('>=1.4.0')
- version_py_path = version_py.full_path()
-else
- version_py_path = meson.current_source_dir() / 'version.py'
-endif
-command = [prog_python, version_py_path, version_file_path, '--git-repo', meson.current_source_dir()]
-if prog_git.found()
- command += ['--git', prog_git]
-endif
-# We add those dummy args to ensure meson sees the dependency
-command += [version_py, version_file]
-version_vala = vcs_tag(command: command, input: 'src/version.vala.in', output: 'version.vala', replace_string: '%VERSION%')
+version_c = configure_file(input: 'src/version.c.in', output: 'version.c', configuration: {'VERSION': meson.project_version()})
# libdino
dependencies = [
@@ -86,7 +73,7 @@ sources = files(
'src/util/util.vala',
'src/util/weak_timeout.vala',
)
-sources += [version_vala]
+sources += [version_c]
c_args = [
'-DDINO_SYSTEM_LIBDIR_NAME="@0@"'.format(get_option('prefix') / get_option('libdir')),
'-DDINO_SYSTEM_PLUGIN_DIR="@0@"'.format(get_option('prefix') / get_option('libdir') / get_option('plugindir')),
diff --git a/libdino/src/application.vala b/libdino/src/application.vala
index 35b706a4..f2e3cc9b 100644
--- a/libdino/src/application.vala
+++ b/libdino/src/application.vala
@@ -2,10 +2,12 @@ using Dino.Entities;
namespace Dino {
-public string get_version() { return VERSION; }
+public extern unowned string get_version();
+
public string get_short_version() {
- if (!VERSION.contains("~")) return VERSION;
- return VERSION.split("~")[0] + "+";
+ string version = get_version();
+ if (!version.contains("~")) return version;
+ return version.split("~")[0] + "+";
}
public interface Application : GLib.Application {
diff --git a/libdino/src/version.c.in b/libdino/src/version.c.in
new file mode 100644
index 00000000..44603c04
--- /dev/null
+++ b/libdino/src/version.c.in
@@ -0,0 +1,4 @@
+const char* dino_get_version ()
+{
+ return "@VERSION@";
+} \ No newline at end of file
diff --git a/libdino/src/version.vala.in b/libdino/src/version.vala.in
deleted file mode 100644
index 2711d4a6..00000000
--- a/libdino/src/version.vala.in
+++ /dev/null
@@ -1,5 +0,0 @@
-namespace Dino {
-
-public const string VERSION = "%VERSION%";
-
-}
diff --git a/main/src/ui/main_window.vala b/main/src/ui/main_window.vala
index 6cabfea7..d2a23954 100644
--- a/main/src/ui/main_window.vala
+++ b/main/src/ui/main_window.vala
@@ -52,6 +52,9 @@ public class MainWindow : Adw.ApplicationWindow {
this.title = "Dino";
this.add_css_class("dino-main");
+ if (Dino.get_version().contains("~git")) {
+ this.add_css_class("devel");
+ }
((Widget)this).realize.connect(restore_window_size);
diff --git a/meson.build b/meson.build
index eb372b6a..0fbe797d 100644
--- a/meson.build
+++ b/meson.build
@@ -1,9 +1,37 @@
-project('Dino', 'c', 'cpp', 'vala', license: 'GPL-3.0', meson_version: '>=1.3.0')
+project(
+ 'Dino',
+ 'c', 'cpp', 'vala',
+ license: 'GPL-3.0',
+ meson_version: '>=1.3.0',
+ version: run_command(
+ find_program('python3', required: true), # Can't use import('python').find_installation() here
+ meson.current_source_dir() / 'build-aux' / 'version.py',
+ meson.current_source_dir() / 'VERSION',
+ '--git-repo', meson.current_source_dir(),
+ '--git', find_program('git', required: false),
+ check: true
+ ).stdout().strip()
+)
-fs = import('fs')
gnome = import('gnome')
i18n = import('i18n')
-python = import('python')
+
+# Trigger recomnfiguration on version change
+version_stamp = configure_file(
+ command: [
+ # Keep in sync with above
+ find_program('python3', required: true),
+ meson.current_source_dir() / 'build-aux' / 'version.py',
+ meson.current_source_dir() / 'VERSION',
+ '--git-repo', meson.current_source_dir(),
+ '--git', find_program('git', required: false),
+ # Trigger depfile generation
+ '--depfile', '@DEPFILE@'
+ ],
+ input: 'build-aux' / 'version.py',
+ output: 'version.stamp',
+ depfile: 'version.d'
+)
# plugin_crypto is enabled if any of the crypto plugins is enabled, auto if
# none of them are explicitly enabled but at least one is set to auto, or
@@ -53,17 +81,6 @@ if not dep_webrtc_audio_processing.found()
dep_webrtc_audio_processing = disabler()
endif
-prog_git = find_program('git', required: false)
-prog_python = python.find_installation()
-
-if import('fs').is_file('VERSION') and meson.version().version_compare('>=1.4.0')
- version_file = files('VERSION')[0]
- version_file_path = version_file.full_path()
-else
- version_file = 'invalid'
- version_file_path = meson.current_source_dir() / 'VERSION'
-endif
-
default_install_rpath = ''
if get_option('set-install-rpath')
default_install_rpath = get_option('prefix') / get_option('libdir')