]> git.ipfire.org Git - thirdparty/zstd.git/commitdiff
meson: get version up front 3327/head
authorEli Schwartz <eschwartz@archlinux.org>
Sun, 6 Nov 2022 01:52:51 +0000 (21:52 -0400)
committerEli Schwartz <eschwartz@archlinux.org>
Thu, 1 Dec 2022 02:36:24 +0000 (21:36 -0500)
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.

build/meson/meson.build

index f264760a34c30e38668b26a306347d709898fc71..98d556aa3bf0a4e588947ad15a27072cfb950457 100644 (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
 
 # =============================================================================