From 8679ea9525672d74030303be062d9545c92b5840 Mon Sep 17 00:00:00 2001 From: solomoncyj Date: Sun, 15 Dec 2024 21:00:42 +0800 Subject: [PATCH] feat: set up dependencies generation for fedora --- data/macros.meson | 5 +++++ data/mesongenbuildreq.py | 16 ++++++++++++++++ 2 files changed, 21 insertions(+) create mode 100644 data/mesongenbuildreq.py diff --git a/data/macros.meson b/data/macros.meson index dcac9d98553c..63a070c8d7b1 100644 --- a/data/macros.meson +++ b/data/macros.meson @@ -45,3 +45,8 @@ --num-processes %{_smp_build_ncpus} \ --print-errorlogs \ %{nil}} + +%meson_buildrequires \ + %{shrink: python3 %{_rpmconfigdir}/mesongenbuildreq %{__meson} \ + %{nil}} + diff --git a/data/mesongenbuildreq.py b/data/mesongenbuildreq.py new file mode 100644 index 000000000000..8f20d62db564 --- /dev/null +++ b/data/mesongenbuildreq.py @@ -0,0 +1,16 @@ +import subprocess +import json +import sys +deps_json = json.loads(subprocess.run([sys.argv[1], "introspect", "--dependencies", "meson.build"], capture_output=True).stdout) +deps = dict(sorted(zip([x['name'] for x in deps_json],[x['version'] for x in deps_json]))) +deps.pop('', None) +for lib, versions in deps.items() : + # Prepare version constraint + version_str = ' ' + ' '.join(versions) if versions else '' + line = [] + for prefix in ["cmake", "pkgconfig", "qmake"] : + buildreq = (f"{prefix}({lib}){version_str}") + if buildreq.split('=')[-1] == '' and '=' in buildreq : + buildreq = buildreq.split('=')[0] + line.append(buildreq) + print(f"({' or '.join(line)})")