mirror of
https://github.com/systemd/systemd.git
synced 2024-11-27 04:03:36 +08:00
meson: simplify version_tag handling
Let's also use vcs_tag() when we're doing a non-git build. In those scenarios, the build would normally be done just once in a given copy, so doing an extra call does not matter. We can save a few lines of meson config. The special path was added in064b8e2c99
, with the justifaction that vcs_tag() is slow and -Dversion-tag=foo can be used to fix the version tag and speed up partial rebuilds. I think the justification for this is weak: having an accurate version tag is particularly useful when developing the code. Shaving of a fraction of a second at the cost of having to manually update the version seems iffy. Secondly, with vcs_tag() we can be pretty sure that meson will build the version file first and that it'll be available to all build steps. Because we didn't use version tag, we had to manually specify the dependency on version.h in various places. It seems nicer to use vcs_tag() and not have to deal with this problem at all. Finally, the savings in time seem much smaller than back when064b8e2c99
was made. It reported a change from 94 ms to 521 ms. But now the difference seems to be about 50 ms: Before this patch: $ time ninja -C build ninja: Entering directory `build' ninja: no work to do. ninja -C build 0.04s user 0.02s system 97% cpu 0.057 total ninja -C build 0.03s user 0.01s system 97% cpu 0.049 total ninja -C build 0.03s user 0.02s system 96% cpu 0.051 total ninja -C build 0.03s user 0.01s system 96% cpu 0.049 total ninja -C build 0.03s user 0.01s system 97% cpu 0.046 total With the two patches in this PR: systemd-stable [drop-versiondep] time ninja -C build ninja: Entering directory `build' [1/669] Generating version.h with a custom command ninja -C build 0.08s user 0.03s system 98% cpu 0.106 total ninja -C build 0.08s user 0.03s system 98% cpu 0.104 total ninja -C build 0.09s user 0.02s system 98% cpu 0.116 total ninja -C build 0.08s user 0.02s system 97% cpu 0.108 total Overall, I think the tiny time savings are not worth the complexity.
This commit is contained in:
parent
c78b611e48
commit
1671799bee
35
meson.build
35
meson.build
@ -1811,28 +1811,25 @@ version_tag = get_option('version-tag')
|
||||
# Check that we have either .git/ (a normal clone) or a .git file (a work-tree) and that we don't
|
||||
# get confused if a tarball is extracted in a higher-level git repository.
|
||||
if version_tag == '' and git.found() and fs.exists(project_source_root / '.git')
|
||||
version_h = vcs_tag(
|
||||
input : 'src/version/version.h.in',
|
||||
output : 'version.h',
|
||||
# If the working tree has no tags (CI builds), the first git-describe will fail
|
||||
# and we fall back to project_version-commitid instead.
|
||||
# TODO: Use 'sh' variable with meson >= 0.63.0
|
||||
command: ['sh',
|
||||
'-euc',
|
||||
'''git -C "$1" describe --abbrev=7 --dirty=^ 2>/dev/null ||
|
||||
echo "$2-$(git -C "$1" describe --always --abbrev=7)" |
|
||||
sed 's/^v//; s/-rc/~rc/' ''',
|
||||
'_',
|
||||
project_source_root,
|
||||
meson.project_version()])
|
||||
# If the working tree has no tags (CI builds), the first git-describe will fail
|
||||
# and we fall back to project_version-commitid instead.
|
||||
version_cmd = '''git -C "$1" describe --abbrev=7 --dirty=^ 2>/dev/null ||
|
||||
echo "$2-$(git -C "$1" describe --always --abbrev=7)" |
|
||||
sed 's/^v//; s/-rc/~rc/' '''
|
||||
else
|
||||
vcs_data = configuration_data()
|
||||
vcs_data.set('VCS_TAG', version_tag == '' ? meson.project_version() : version_tag)
|
||||
version_h = configure_file(configuration : vcs_data,
|
||||
input : 'src/version/version.h.in',
|
||||
output : 'version.h')
|
||||
version_cmd = '''echo "$2" '''
|
||||
endif
|
||||
|
||||
version_h = vcs_tag(
|
||||
input : 'src/version/version.h.in',
|
||||
output : 'version.h',
|
||||
# TODO: Use 'sh' variable with meson >= 0.63.0
|
||||
command: ['sh', '-euc', version_cmd,
|
||||
'_',
|
||||
project_source_root,
|
||||
version_tag == '' ? meson.project_version() : version_tag,
|
||||
])
|
||||
|
||||
versiondep = declare_dependency(
|
||||
sources : version_h,
|
||||
include_directories : include_directories('.'),
|
||||
|
Loading…
Reference in New Issue
Block a user