qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Paolo Bonzini <pbonzini@redhat.com>
To: qemu-devel@nongnu.org
Cc: marcandre.lureau@redhat.com
Subject: [PATCH v2 21/34] meson, configure: move --with-pkgversion, CONFIG_STAMP to meson
Date: Sat, 23 Apr 2022 14:51:38 +0200	[thread overview]
Message-ID: <20220423125151.27821-22-pbonzini@redhat.com> (raw)
In-Reply-To: <20220423125151.27821-1-pbonzini@redhat.com>

The hash is now generated with a Python script.

Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
 configure                     | 23 -----------------------
 docs/meson.build              |  2 +-
 meson.build                   | 10 +++++++++-
 meson_options.txt             |  2 ++
 scripts/meson-buildoptions.py |  1 +
 scripts/meson-buildoptions.sh |  3 +++
 scripts/qemu-stamp.py         | 24 ++++++++++++++++++++++++
 7 files changed, 40 insertions(+), 25 deletions(-)
 create mode 100644 scripts/qemu-stamp.py

diff --git a/configure b/configure
index 56dcc7ba8e..3f0fe1c4e1 100755
--- a/configure
+++ b/configure
@@ -306,7 +306,6 @@ qemu_suffix="qemu"
 softmmu="yes"
 linux_user=""
 bsd_user=""
-pkgversion=""
 pie=""
 coroutine=""
 plugins="$default_feature"
@@ -896,8 +895,6 @@ for opt do
   ;;
   --enable-fdt=*) fdt="$optarg"
   ;;
-  --with-pkgversion=*) pkgversion="$optarg"
-  ;;
   --with-coroutine=*) coroutine="$optarg"
   ;;
   --disable-vhost-net) vhost_net="no"
@@ -1135,7 +1132,6 @@ Advanced options (experts only):
   --firmwarepath=PATH      search PATH for firmware files
   --efi-aarch64=PATH       PATH of efi file to use for aarch64 VMs.
   --with-suffix=SUFFIX     suffix for QEMU data inside datadir/libdir/sysconfdir/docdir [$qemu_suffix]
-  --with-pkgversion=VERS   use specified string as sub-version of the package
   --without-default-features default all --enable-* options to "disabled"
   --without-default-devices  do not include any device that is not needed to
                            start the emulator (only use if you are including
@@ -1722,21 +1718,6 @@ if ! compile_prog "$glib_cflags -Werror" "$glib_libs" ; then
     fi
 fi
 
-##########################################
-# SHA command probe for modules
-if test "$modules" = yes; then
-    shacmd_probe="sha1sum sha1 shasum"
-    for c in $shacmd_probe; do
-        if has $c; then
-            shacmd="$c"
-            break
-        fi
-    done
-    if test "$shacmd" = ""; then
-        error_exit "one of the checksum commands is required to enable modules: $shacmd_probe"
-    fi
-fi
-
 ##########################################
 # fdt probe
 
@@ -2173,13 +2154,9 @@ if test "$static" = "yes" ; then
   echo "CONFIG_STATIC=y" >> $config_host_mak
 fi
 qemu_version=$(head $source_path/VERSION)
-echo "PKGVERSION=$pkgversion" >>$config_host_mak
 echo "SRC_PATH=$source_path" >> $config_host_mak
 echo "TARGET_DIRS=$target_list" >> $config_host_mak
 if test "$modules" = "yes"; then
-  # $shacmd can generate a hash started with digit, which the compiler doesn't
-  # like as an symbol. So prefix it with an underscore
-  echo "CONFIG_STAMP=_$( (echo $qemu_version; echo $pkgversion; cat $0) | $shacmd - | cut -f1 -d\ )" >> $config_host_mak
   echo "CONFIG_MODULES=y" >> $config_host_mak
 fi
 
diff --git a/docs/meson.build b/docs/meson.build
index 831d4aea2b..9136fed3b7 100644
--- a/docs/meson.build
+++ b/docs/meson.build
@@ -35,7 +35,7 @@ if sphinx_build.found()
 endif
 
 if build_docs
-  SPHINX_ARGS += ['-Dversion=' + meson.project_version(), '-Drelease=' + config_host['PKGVERSION']]
+  SPHINX_ARGS += ['-Dversion=' + meson.project_version(), '-Drelease=' + get_option('pkgversion')]
 
   man_pages = {
         'qemu-ga.8': (have_ga ? 'man8' : ''),
diff --git a/meson.build b/meson.build
index da8d3076d7..66b2a3aa31 100644
--- a/meson.build
+++ b/meson.build
@@ -1626,6 +1626,14 @@ config_host_data.set_quoted('CONFIG_QEMU_LOCALSTATEDIR', get_option('prefix') /
 config_host_data.set_quoted('CONFIG_QEMU_MODDIR', get_option('prefix') / qemu_moddir)
 config_host_data.set_quoted('CONFIG_SYSCONFDIR', get_option('prefix') / get_option('sysconfdir'))
 
+if config_host.has_key('CONFIG_MODULES')
+  config_host_data.set('CONFIG_STAMP', run_command(
+      meson.current_source_dir() / 'scripts/qemu-stamp.py',
+      meson.project_version(), get_option('pkgversion'), '--',
+      meson.current_source_dir() / 'configure',
+      capture: true, check: true).stdout().strip())
+endif
+
 have_slirp_smbd = get_option('slirp_smbd') \
   .require(targetos != 'windows', error_message: 'Host smbd not supported on this platform.') \
   .allowed()
@@ -2796,7 +2804,7 @@ tracetool_depends = files(
 
 qemu_version_cmd = [find_program('scripts/qemu-version.sh'),
                     meson.current_source_dir(),
-                    config_host['PKGVERSION'], meson.project_version()]
+                    get_option('pkgversion'), meson.project_version()]
 qemu_version = custom_target('qemu-version.h',
                              output: 'qemu-version.h',
                              command: qemu_version_cmd,
diff --git a/meson_options.txt b/meson_options.txt
index ec974003b3..dc6fb796c6 100644
--- a/meson_options.txt
+++ b/meson_options.txt
@@ -8,6 +8,8 @@ option('docdir', type : 'string', value : 'doc',
        description: 'Base directory for documentation installation (can be empty)')
 option('qemu_firmwarepath', type : 'string', value : '',
        description: 'search PATH for firmware files')
+option('pkgversion', type : 'string', value : '',
+       description: 'use specified string as sub-version of the package')
 option('smbd', type : 'string', value : '',
        description: 'Path to smbd for slirp networking')
 option('sphinx_build', type : 'string', value : '',
diff --git a/scripts/meson-buildoptions.py b/scripts/meson-buildoptions.py
index 3e540e8bb3..0f9603a7f6 100755
--- a/scripts/meson-buildoptions.py
+++ b/scripts/meson-buildoptions.py
@@ -36,6 +36,7 @@
 
 OPTION_NAMES = {
     "malloc": "enable-malloc",
+    "pkgversion": "with-pkgversion",
     "trace_backends": "enable-trace-backends",
     "trace_file": "with-trace-file",
 }
diff --git a/scripts/meson-buildoptions.sh b/scripts/meson-buildoptions.sh
index 4c49d4af08..bf9878e24f 100644
--- a/scripts/meson-buildoptions.sh
+++ b/scripts/meson-buildoptions.sh
@@ -44,6 +44,8 @@ meson_options_help() {
   printf "%s\n" '  --sphinx-build=VALUE     Use specified sphinx-build for building document'
   printf "%s\n" '  --tls-priority=VALUE     Default TLS protocol/cipher priority string'
   printf "%s\n" '                           [NORMAL]'
+  printf "%s\n" '  --with-pkgversion=VALUE  use specified string as sub-version of the'
+  printf "%s\n" '                           package'
   printf "%s\n" '  --with-trace-file=VALUE  Trace file prefix for simple backend [trace]'
   printf "%s\n" ''
   printf "%s\n" 'Optional features, enabled with --enable-FEATURE and'
@@ -309,6 +311,7 @@ _meson_option_parse() {
     --disable-pa) printf "%s" -Dpa=disabled ;;
     --enable-parallels) printf "%s" -Dparallels=enabled ;;
     --disable-parallels) printf "%s" -Dparallels=disabled ;;
+    --with-pkgversion=*) quote_sh "-Dpkgversion=$2" ;;
     --enable-profiler) printf "%s" -Dprofiler=true ;;
     --disable-profiler) printf "%s" -Dprofiler=false ;;
     --enable-pvrdma) printf "%s" -Dpvrdma=enabled ;;
diff --git a/scripts/qemu-stamp.py b/scripts/qemu-stamp.py
new file mode 100644
index 0000000000..7beeeb07ed
--- /dev/null
+++ b/scripts/qemu-stamp.py
@@ -0,0 +1,24 @@
+#! /usr/bin/env python3
+
+# Usage: scripts/qemu-stamp.py STRING1 STRING2... -- FILE1 FILE2...
+import hashlib
+import os
+import sys
+
+sha = hashlib.sha1()
+is_file = False
+for arg in sys.argv[1:]:
+    if arg == '--':
+        is_file = True
+        continue
+    if is_file:
+        with open(arg, 'rb') as f:
+            for chunk in iter(lambda: f.read(65536), b''):
+                sha.update(chunk)
+    else:
+        sha.update(os.fsencode(arg))
+        sha.update(b'\n')
+
+# The hash can start with a digit, which the compiler doesn't
+# like as an symbol. So prefix it with an underscore
+print("_" + sha.hexdigest())
-- 
2.35.1




  parent reply	other threads:[~2022-04-23 13:10 UTC|newest]

Thread overview: 36+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-04-23 12:51 [PATCH v2 00/34] Misc meson conversions for QEMU 7.1 Paolo Bonzini
2022-04-23 12:51 ` [PATCH v2 01/34] meson: show final set of compiler flags Paolo Bonzini
2022-04-23 12:51 ` [PATCH v2 02/34] configure: remove dead code Paolo Bonzini
2022-04-23 12:51 ` [PATCH v2 03/34] qga: wixl: get path to sysroot from pkg-config as intended Paolo Bonzini
2022-04-23 12:51 ` [PATCH v2 04/34] configure: pc-bios/qemu-icon.bmp does not exist Paolo Bonzini
2022-04-23 12:51 ` [PATCH v2 05/34] configure: gcov should not exclude fortify-source Paolo Bonzini
2022-04-23 12:51 ` [PATCH v2 06/34] configure: move --enable/--disable-debug-info to second option parsing pass Paolo Bonzini
2022-04-23 12:51 ` [PATCH v2 07/34] configure, meson: move OpenGL check to meson Paolo Bonzini
2022-04-23 12:51 ` [PATCH v2 08/34] meson, configure: move RDMA options " Paolo Bonzini
2022-04-23 12:51 ` [PATCH v2 09/34] meson, configure: move keyctl test " Paolo Bonzini
2022-04-23 12:51 ` [PATCH v2 10/34] meson, configure: move usbfs " Paolo Bonzini
2022-04-23 12:51 ` [PATCH v2 11/34] meson, configure: move libgio " Paolo Bonzini
2022-04-23 12:51 ` [PATCH v2 12/34] meson: remove CONFIG_XEN_PCI_PASSTHROUGH from config-target.h Paolo Bonzini
2022-04-23 12:51 ` [PATCH v2 13/34] meson, configure: move --enable-module-upgrades to meson Paolo Bonzini
2022-04-23 12:51 ` [PATCH v2 14/34] meson, configure: move Xen detection " Paolo Bonzini
2022-04-23 12:51 ` [PATCH v2 15/34] meson-buildoptions: add support for string options Paolo Bonzini
2022-04-23 12:51 ` [PATCH v2 16/34] configure, meson: move iasl detection to meson Paolo Bonzini
2022-04-23 12:51 ` [PATCH v2 17/34] configure: move Windows flags " Paolo Bonzini
2022-04-24 12:33   ` Marc-André Lureau
2022-04-23 12:51 ` [PATCH v2 18/34] configure: switch string options to automatic parsing Paolo Bonzini
2022-04-23 12:51 ` [PATCH v2 19/34] meson, configure: move --tls-priority to meson Paolo Bonzini
2022-04-23 12:51 ` [PATCH v2 20/34] meson, configure: move bdrv whitelists " Paolo Bonzini
2022-04-23 12:51 ` Paolo Bonzini [this message]
2022-04-23 12:51 ` [PATCH v2 22/34] meson, configure: move --interp-prefix " Paolo Bonzini
2022-04-23 12:51 ` [PATCH v2 23/34] meson: always combine directories with prefix Paolo Bonzini
2022-04-23 12:51 ` [PATCH v2 24/34] configure: switch directory options to automatic parsing Paolo Bonzini
2022-04-23 12:51 ` [PATCH v2 25/34] meson: pass more options directly as -D Paolo Bonzini
2022-04-23 12:51 ` [PATCH v2 26/34] configure: omit options with default values from meson command line Paolo Bonzini
2022-04-23 12:51 ` [PATCH v2 27/34] meson, virtio: place all virtio-pci devices under virtio_pci_ss Paolo Bonzini
2022-04-23 12:51 ` [PATCH v2 28/34] configure: simplify vhost-net-{user, vdpa} configuration Paolo Bonzini
2022-04-23 12:51 ` [PATCH v2 29/34] build: move vhost-vsock configuration to Kconfig Paolo Bonzini
2022-04-23 12:51 ` [PATCH v2 30/34] build: move vhost-scsi " Paolo Bonzini
2022-04-23 12:51 ` [PATCH v2 31/34] build: move vhost-user-fs " Paolo Bonzini
2022-04-23 12:51 ` [PATCH v2 32/34] meson: create have_vhost_* variables Paolo Bonzini
2022-04-23 12:51 ` [PATCH v2 33/34] meson: use have_vhost_* variables to pick sources Paolo Bonzini
2022-04-23 12:51 ` [PATCH v2 34/34] configure, meson: move vhost options to Meson Paolo Bonzini

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220423125151.27821-22-pbonzini@redhat.com \
    --to=pbonzini@redhat.com \
    --cc=marcandre.lureau@redhat.com \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).