aboutsummaryrefslogtreecommitdiff
path: root/libdino
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 /libdino
parentd34b9fcb37fa79738582392e194e76651cd4adc2 (diff)
Use meson native project version
Diffstat (limited to 'libdino')
-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--libdino/version.py65
5 files changed, 11 insertions, 88 deletions
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/libdino/version.py b/libdino/version.py
deleted file mode 100644
index 87490d18..00000000
--- a/libdino/version.py
+++ /dev/null
@@ -1,65 +0,0 @@
-import argparse
-import subprocess
-import re
-
-
-def compute_version_from_file(file):
- try:
- with open(file) as f:
- version_from_file = f.read().strip()
- if version_from_file != "":
- if version_from_file.startswith("RELEASE "):
- return version_from_file[8:].strip()
- if version_from_file.startswith("PRERELEASE "):
- return version_from_file[11:].strip()
- return version_from_file
- except FileNotFoundError:
- pass
- return None
-
-
-def compute_version_from_git(git_repo, git):
- try:
- git_release_tag = subprocess.check_output([git, "describe", "--tags", "--abbrev=0"],
- cwd=git_repo, text=True).strip()
- if re.match("^v?([0-9]+[.]?[0-9]*[.]?[0-9]*)(-[.0-9A-Za-z-]+)?([+][.0-9A-Za-z-]+)?$", git_release_tag) is None:
- return None
- git_describe = subprocess.check_output([git, "describe", "--tags"], cwd=git_repo, text=True).strip()
- if git_release_tag == git_describe:
- return git_release_tag[1:]
- matches = re.match("^.*-([0-9]+)-g([0-9a-f]+)$", git_describe)
- if matches is None:
- return None
- git_tag_offset = matches.groups()[0]
- git_commit_hash = matches.groups()[1]
- git_commit_time = subprocess.check_output([git, "show", "--format=%cd", "--date=format:%Y%m%d", "-s"],
- cwd=git_repo, text=True).strip()
- return "%s~git%s.%s.%s" % (git_release_tag[1:], git_tag_offset, git_commit_time, git_commit_hash)
- except subprocess.CalledProcessError:
- pass
- return None
-
-
-def compute_version(file, git_repo, git):
- version_from_file = compute_version_from_file(file)
- if version_from_file is not None:
- return version_from_file
- version_from_git = compute_version_from_git(git_repo, git)
- if version_from_git is not None:
- return version_from_git
- return ""
-
-
-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("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 __name__ == "__main__":
- main()