From nobody Mon Nov 23 04:36:06 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1793902550; cv=none; d=zohomail.com; s=zohoarc; b=KrbhVA1QhrSd2ELUwmniCzya7Um0XFEde42UMHDYrSczWWXJ1awhPGqFd02j6YvZMgY8xMg9FsXlATECDg5Dw9pPpqI1DXbCv73i/P7+dldBVuGadsYQYzPjNzwpNm8MJTiAt+juHFHDpbKG4wjg/3VIQOfKfEHCO1S3ggr5cQY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1793902550; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=54QiAGJ4S2aXZee0pnGYxbqmMzUlPa+3h8prkSYwPOk=; b=E7kthZgCIPiia/Pn/GiysQfb9GaDlVTuE0zZ+NwRzkwEvNnhvnJWfn4Q7goff6VqkFsoNsvQl4yN8CT+wGqVY+AFeKl/1ZrRZ+vq/or8xNIP+R7L1kOqZfPhTFkJnkkcmj5hcGnt9657HNYIE+xtZ+1gEBiniL648XcmmBEO6sc= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1793902550028842.4035122267214; Thu, 5 Nov 2026 10:15:50 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xP1zO-0001wt-Mm; Thu, 05 Nov 2026 13:15:06 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xP1zK-0001wY-S4 for qemu-devel@nongnu.org; Thu, 05 Nov 2026 13:15:04 -0500 Received: from mail-dy1-x1336.google.com ([2607:f8b0:4864:20::1336]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1xP1zH-0005Fr-1z for qemu-devel@nongnu.org; Thu, 05 Nov 2026 13:15:01 -0500 Received: by mail-dy1-x1336.google.com with SMTP id 5a478bee46e88-36a18fc7a38so2818498eec.1 for ; Thu, 05 Nov 2026 10:14:58 -0800 (PST) Received: from DESKTOP-Q716RM7 ([103.94.185.75]) by smtp.googlemail.com with ESMTPSA id a92af1059eb24-1b245c6f0dcsm25150323c88.21.2026.11.05.10.14.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 05 Nov 2026 10:14:56 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20260707; t=1793902497; x=1794507297; darn=nongnu.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to:content-type; bh=54QiAGJ4S2aXZee0pnGYxbqmMzUlPa+3h8prkSYwPOk=; b=jbD0LDAu7smFBwn5dMvwrG43ycQL8bRuuCd+fM8CkcaLZbnpnon3wxO+K/Fkaa7KT+ Q/LT04A8fFq4dlmz1IX9hi7gLa4U6nIPJ09QnGripjfQXWklFeG19fEqE4lfA4PSntXr 4nw4ayD8wz6q9DrnwufcheDIvoeUQy9/0kQY5tXGWHWKzanIVf73BkOxIVnynHnZ7Gbe HnKMFs/5cIxVZV8NWbLX90rdxiWQFFqQjPXta4X6ZySEa4L8NOQ6wVq/F4oNnoGeqELm 9VlinPzvniaQMz7G7W7tZ8OVmzkF16P7XMBFsdurkEH9NAiPjZFNnPYKisKvg21Wq+FL hAbw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1793902497; x=1794507297; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to:content-type; bh=54QiAGJ4S2aXZee0pnGYxbqmMzUlPa+3h8prkSYwPOk=; b=cxYGn9nByn9tKT975XK4oolro9756WdTBq60V989nQPDec+I1aiQI5/fMMBE0XG8b7 SzKdBtrB5LW877ZcyGvPa8C3sX1y2pRMSB5vUny1d11Oivl3Hz61QSdU3yMSwOZuNRrL P4cT/aVSS6Q9LiaMdMJf1i8pBYHHjJmtjJyIeOPCd3Fkx/J65vo8wob6nce6MweUaEJe eKWvT0uDSq/0cEW3W1i6bL0zK96u9qC5C6W1jjvpNIQvj6pSkq0R4wxxjDpu3vp6fVEr E+B0/6YaCfLwQYw6mz2ggeu6cw7S2KMm6Kd5toVQnt0YlHr03gDAtn11gbye/BERiZFr HfIw== X-Gm-Message-State: APuU4Z+aQncTL9izWLgN/p119bXqh4PpOdClSAxx3sz5/lyP99m453B3 t6bDmwkpDnhwQVCgPO/WIAkhxSjsse6EbSpby6aenxYcn50O+H01RHzxrOJa/l5ZBnU= X-Gm-Gg: AYBFou3c9Jlzp+9Ifh1Z2huwMP7iZITmOcUHsPG0ttRERWQBpOuQgydmpnJeEz7Ebyp Nw38gAmZQs2gYBX/Ai5yN1nqBloPPHKqZSojFFcBzh59Zyo79ZogxrSGlFzPle31fSzdfTRa+Pw XdArgHjpuNijgLXPUilQcmcUejmCLpnB+NEcEZavPv8T74Ot5o27DBvxh4fHn7O4rduQxuHOtPQ Az1MeuD3U8JfcHU4ZJWmzltStQxH/A0f0iuT1JPVeRgXqMLpMBfI4H7oMZkpSOnfxehjEMtJNun dAD9TqTZc9AGoOLJoWlEE3T2ogqm+I2m4Oxc2W5RLQi4eOhaRLJ+o9xcSqNz1RgEqQ/T1d4HKOZ J2NWjpwh7ipq4LOkH+2pJGaGYNUxH7amIyMkwQI3XVf9PTE7pih+5/MYkBYK9xFI5sN/ovZtcNH CFSg7raNFX/mdW4fOt/E8tHFfyhnBUFG2vDmYrj/aF9hUj1rhN4KLKDNJRZQqPXWR75k8zFcGcg jBydCbxz6j8qX7WAVUgQj6l2SBDPZxV14Sadsd+4XjKqyfgzi8Vlktp6PwLCAk6/iEiuLtVNroQ zJTdytEKccV7HxiEpP182o6ckUp1dVL/WlCEeKK2Zm2O7i1bdChzpwU8qsG2uPKsKfIYoA== X-Received: by 2002:a05:7022:3f04:b0:16b:fdbf:4a9c with SMTP id a92af1059eb24-1ac5ac4cd7emr30862998c88.23.1793902497161; Thu, 05 Nov 2026 10:14:57 -0800 (PST) From: Yonggang Luo To: qemu-devel@nongnu.org Cc: Cleber Rosa , Paolo Bonzini , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , Pierrick Bouvier , John Snow , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Philippe Mathieu-Daude Subject: [PATCH] meson: generate qemu-version.h with a custom target Date: Fri, 6 Nov 2026 02:14:48 +0800 Message-ID: <20261105181449.1691-1-luoyonggang@gmail.com> X-Mailer: git-send-email 2.55.0.windows.3 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists1p.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::1336; envelope-from=luoyonggang@gmail.com; helo=mail-dy1-x1336.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1793902552163158500 Content-Type: text/plain; charset="utf-8" configure_file() writes qemu-version.h at setup time. That result is not a ninja edge, so a missing header is never rebuilt and compiles that include it do not order on it. Generate the header with custom_target and list it in genh. scripts/qemu-version.py reads scripts/qemu-version.h.in and substitutes -version. An empty pkgversion drops the QEMU_PKGVERSION line. Link: https://lore.kernel.org/qemu-devel/CAFEAcA8bGODxRfRzrimhGN1v2HtcWvApR= syucemZbMUUBVkYwA@mail.gmail.com/ Signed-off-by: Yonggang Luo --- meson.build | 14 +++++++++----- scripts/qemu-version.py | 26 ++++++++++++++++++++++++++ 2 files changed, 35 insertions(+), 5 deletions(-) create mode 100644 scripts/qemu-version.py diff --git a/meson.build b/meson.build index d7bcb581c1..78cbc91296 100644 --- a/meson.build +++ b/meson.build @@ -3574,11 +3574,15 @@ else # Unlike vcs_tag(), which always defines QEMU_PKGVERSION, leave it out if # empty. include/qemu/version.h then omits the parentheses from # QEMU_FULL_VERSION. - qemu_version_data =3D configuration_data() - if qemu_pkgversion !=3D '' - qemu_version_data.set_quoted('QEMU_PKGVERSION', qemu_pkgversion) - endif - qemu_version =3D configure_file(output: 'qemu-version.h', configuration:= qemu_version_data) + # custom_target is a genh source, so consumers order on qemu-version.h + # and ninja recreates it when the template or pkgversion changes. + qemu_version =3D custom_target( + 'qemu-version.h', + input: files('scripts/qemu-version.h.in'), + output: 'qemu-version.h', + capture: true, + command: [python, files('scripts/qemu-version.py'), + '-version', qemu_pkgversion, '@INPUT@']) endif genh +=3D qemu_version =20 diff --git a/scripts/qemu-version.py b/scripts/qemu-version.py new file mode 100644 index 0000000000..a10cc5e03c --- /dev/null +++ b/scripts/qemu-version.py @@ -0,0 +1,26 @@ +#!/usr/bin/env python3 +# SPDX-License-Identifier: GPL-2.0-or-later + +# Usage: scripts/qemu-version.py -version PKGVERSION INPUT +# @VCS_TAG@ in INPUT is replaced with PKGVERSION. An empty PKGVERSION +# drops that line. + +import argparse +import sys + +parser =3D argparse.ArgumentParser() +parser.add_argument('-version', default=3D'') +parser.add_argument('input') +args =3D parser.parse_args() + +version =3D args.version +with open(args.input, 'rb') as template_file: + template =3D template_file.read() +if version: + version =3D version.replace('\\', '\\\\').replace('"', '\\"') + template =3D template.replace(b'@VCS_TAG@', version.encode('utf-8')) + sys.stdout.buffer.write(template) +else: + kept =3D [line for line in template.splitlines(True) + if b'@VCS_TAG@' not in line] + sys.stdout.buffer.write(b''.join(kept) if kept else b'\n') --=20 2.55.0.windows.3