meson: get version up front

Run the scraper command to establish the project version immediately,
rather than wait for the build to be configured. This simplifies the
code and ensures that project introspection works correctly.
This commit is contained in:
Eli Schwartz 2022-11-05 21:52:51 -04:00
parent 4d82a4d3f2
commit 6c3ed93c27
No known key found for this signature in database
GPG Key ID: CEB167EFB5722BD6

View File

@ -23,7 +23,9 @@ project('zstd',
# so this isn't safe
#'werror=true'
],
version: 'DUMMY',
version: run_command(
find_program('GetZstdLibraryVersion.py'), '../../lib/zstd.h',
check: true).stdout().strip(),
meson_version: '>=0.48.0')
cc = meson.get_compiler('c')
@ -45,16 +47,6 @@ compiler_msvc = 'msvc'
zstd_version = meson.project_version()
zstd_h_file = join_paths(meson.current_source_dir(), '../../lib/zstd.h')
GetZstdLibraryVersion_py = find_program('GetZstdLibraryVersion.py', native : true)
r = run_command(GetZstdLibraryVersion_py, zstd_h_file)
if r.returncode() == 0
zstd_version = r.stdout().strip()
message('Project version is now: @0@'.format(zstd_version))
else
error('Cannot find project version in @0@'.format(zstd_h_file))
endif
zstd_libversion = zstd_version
# =============================================================================