From: Zbigniew Jędrzejewski-Szmek Date: Thu, 20 Dec 2018 19:35:25 +0000 (+0100) Subject: meson: generate version tag from git X-Git-Tag: v241-rc1~131^2~6 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=681bd2c524ed71ac04045c90884ba8d55eee7b66;p=thirdparty%2Fsystemd.git meson: generate version tag from git $ build/systemctl --version systemd 239-3555-g6178cbb5b5 +PAM +AUDIT +SELINUX +IMA -APPARMOR +SMACK +SYSVINIT +UTMP +LIBCRYPTSETUP +GCRYPT +GNUTLS +ACL +XZ +LZ4 +SECCOMP +BLKID +ELFUTILS +KMOD -IDN2 +IDN +PCRE2 default-hierarchy=hybrid $ git tag v240 -m 'v240' $ ninja -C build ninja: Entering directory `build' [76/76] Linking target fuzz-unit-file. $ build/systemctl --version systemd 240 +PAM +AUDIT +SELINUX +IMA -APPARMOR +SMACK +SYSVINIT +UTMP +LIBCRYPTSETUP +GCRYPT +GNUTLS +ACL +XZ +LZ4 +SECCOMP +BLKID +ELFUTILS +KMOD -IDN2 +IDN +PCRE2 default-hierarchy=hybrid This is very useful during development, because a precise version string is embedded in the build product and displayed during boot, so we don't have to guess answers for questions like "did I just boot the latest version or the one from before?". This change creates an overhead for "noop" builds. On my laptop, 'ninja -C build' that does nothing goes from 0.1 to 0.5 s. It would be nice to avoid this, but I think that <1 s is still acceptable. Fixes #7183. PACKAGE_VERSION is renamed to GIT_VERSION, to make it obvious that this is the more dynamically changing version string. Why save to a file? It would be easy to generate the version tag using run_command(), but we want to go through a file so that stuff gets rebuilt when this file changes. If we just defined an variable in meson, ninja wouldn't know it needs to rebuild things. --- diff --git a/meson.build b/meson.build index 7816ba99490..100265570d5 100644 --- a/meson.build +++ b/meson.build @@ -21,7 +21,6 @@ libudev_version = '1.6.11' # set. Ugh, ugh, ugh! conf = configuration_data() conf.set('PROJECT_VERSION', meson.project_version()) -conf.set_quoted('PACKAGE_VERSION', meson.project_version()) substs = configuration_data() substs.set('PROJECT_URL', 'https://www.freedesktop.org/wiki/Software/systemd') @@ -584,6 +583,10 @@ endif ##################################################################### +vcs_tagger = [meson.source_root() + '/tools/meson-vcs-tag.sh', + '@0@/.git'.format(meson.source_root()), + meson.project_version()] + sed = find_program('sed') awk = find_program('awk') m4 = find_program('m4') diff --git a/src/analyze/analyze.c b/src/analyze/analyze.c index 1f69b9fda1b..3915b66739e 100644 --- a/src/analyze/analyze.c +++ b/src/analyze/analyze.c @@ -14,6 +14,7 @@ #include "alloc-util.h" #include "analyze-security.h" #include "analyze-verify.h" +#include "build.h" #include "bus-error.h" #include "bus-unit-util.h" #include "bus-util.h" @@ -696,7 +697,7 @@ static int analyze_plot(int argc, char *argv[], void *userdata) { "\n" "\n" "\n\n" - "\n\n", PACKAGE_VERSION); + "\n\n", GIT_VERSION); /* style sheet */ svg("\n