]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
meson: Use configure_file when version-tag is specified
authorDaan De Meyer <daan.j.demeyer@gmail.com>
Sun, 10 Jan 2021 12:18:36 +0000 (13:18 +0100)
committerDaan De Meyer <daan.j.demeyer@gmail.com>
Fri, 15 Jan 2021 18:34:44 +0000 (19:34 +0100)
vcs_tag() is slow. When the version-tag meson option is set,
we can use configure_file() directly to speed up incremental
builds.

Before (with version-tag set to v247):

```
‣ Running build script...
[1/418] Generating version.h with a custom command

real    0m0.521s
user    0m0.229s
sys     0m0.067s
```

After (with version-tag set to v247):

```
‣ Running build script...
ninja: no work to do.

real    0m0.094s
user    0m0.048s
sys     0m0.022s
```

meson.build
tools/meson-vcs-tag.sh

index a8afa0dd2f75af5b69a8bdf470a9655446d12fa2..99d203d145225e85b60ad445cdbbdd270e67e3a7 100644 (file)
@@ -555,15 +555,24 @@ endif
 
 #####################################################################
 
-vcs_tagger = [project_source_root + '/tools/meson-vcs-tag.sh',
-              project_source_root,
-              get_option('version-tag'),
-              meson.project_version()]
-
-version_h = vcs_tag(
-        input : 'src/version/version.h.in',
-        output : 'version.h',
-        command: vcs_tagger)
+version_tag = get_option('version-tag')
+if version_tag != ''
+        vcs_data = configuration_data()
+        vcs_data.set('VCS_TAG', version_tag)
+        version_h = configure_file(configuration : vcs_data,
+                                   input : 'src/version/version.h.in',
+                                   output : 'version.h')
+else
+        vcs_tagger = [
+                project_source_root + '/tools/meson-vcs-tag.sh',
+                project_source_root,
+                meson.project_version()]
+
+        version_h = vcs_tag(
+                input : 'src/version/version.h.in',
+                output : 'version.h',
+                command: vcs_tagger)
+endif
 
 versiondep = declare_dependency(sources: version_h)
 
index 1c3814d4830b3c523e0fc1cedd7e4c5e947bf98d..a285210f9649a553443818e38c19a6db4bfd5bb9 100755 (executable)
@@ -4,13 +4,7 @@ set -eu
 set -o pipefail
 
 dir="$1"
-tag="$2"
-fallback="$3"
-
-if [ -n "$tag" ]; then
-    echo "$tag"
-    exit 0
-fi
+fallback="$2"
 
 # Apparently git describe has a bug where it always considers the work-tree
 # dirty when invoked with --git-dir (even though 'git status' is happy). Work