From nobody Mon Feb 9 04:46:02 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=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1596745011; cv=none; d=zohomail.com; s=zohoarc; b=ghc+gkDBh2XlZ4pWoZvdErb6hxrNps44dPM/oyzliHSz4w0UX5unzXrJF1S1l8+V0wv9dtQoR6bOm1n4DqWJpKftHwuSHdAbAGS3Ux2HjC11KkwIBnGzpLoRnlpIZiBy2cQOl4eeeli4yFyvNPMvOIxIkWe65IZ5Edu71Y3IjR0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1596745011; h=Content-Type:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To; bh=PnW1d/mMnK2iy+7KtWSCMbUu0Dgra3qRDQymmCUa7ZE=; b=e2QYVkluAFVyHNpwfhVjmh+hSu0hcpNzXFl3IMMChu2/ovuDGZdp8gpKTz1pHE610biRypEcO2QtoGI9aNnumx9XCiBNo4Edfn0g70usbH4YwVv93ZuIPXBIzqG2DGPkeQygx5zLtnLxu0jnPwmIpF6K7Hv0kycNlPNoJt7ajQQ= 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) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1596745011705987.2973189929123; Thu, 6 Aug 2020 13:16:51 -0700 (PDT) Received: from localhost ([::1]:37946 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1k3mJm-0006Dt-AC for importer@patchew.org; Thu, 06 Aug 2020 16:16:50 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:44676) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1k3lRO-0003J3-2Y for qemu-devel@nongnu.org; Thu, 06 Aug 2020 15:20:38 -0400 Received: from us-smtp-delivery-124.mimecast.com ([63.128.21.124]:31676) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1k3lRK-00070Z-SM for qemu-devel@nongnu.org; Thu, 06 Aug 2020 15:20:37 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-230-d6CvKEdkPG-XnR54Cshffw-1; Thu, 06 Aug 2020 15:20:32 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 4DDA11DE4 for ; Thu, 6 Aug 2020 19:20:31 +0000 (UTC) Received: from 640k.localdomain.com (unknown [10.36.110.10]) by smtp.corp.redhat.com (Postfix) with ESMTP id 969961D3 for ; Thu, 6 Aug 2020 19:20:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1596741634; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:content-type:content-type:in-reply-to:in-reply-to: references:references; bh=PnW1d/mMnK2iy+7KtWSCMbUu0Dgra3qRDQymmCUa7ZE=; b=YgKavgs9BIyrJS6KSlr0h8dhzAYOeaLA4HK+A4Aewg+5SNvUockzySGQ36tFa5NoZ8P33b j9PB8mXOECQT9+RjOnrsBvte3/84NGf32ECUNQJ3G/jV8quh9R/NT42k7uoEyVoVBf++Xt nmDlB7esbRhpE1rwlOh3GuGPC4uIwog= X-MC-Unique: d6CvKEdkPG-XnR54Cshffw-1 From: Paolo Bonzini To: qemu-devel@nongnu.org Subject: [PATCH 138/143] meson: replace create-config with meson configure_file Date: Thu, 6 Aug 2020 21:16:14 +0200 Message-Id: <1596741379-12902-139-git-send-email-pbonzini@redhat.com> In-Reply-To: <1596741379-12902-1-git-send-email-pbonzini@redhat.com> References: <1596741379-12902-1-git-send-email-pbonzini@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=pbonzini@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com 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=lists.gnu.org; Received-SPF: pass client-ip=63.128.21.124; envelope-from=pbonzini@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/08/06 13:48:01 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -30 X-Spam_score: -3.1 X-Spam_bar: --- X-Spam_report: (-3.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, URIBL_BLOCKED=0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Move the create-config logic to meson.build; create a configuration_data object and let meson handle the quoting and output. Signed-off-by: Paolo Bonzini --- Makefile | 2 +- block.c | 4 +- configure | 9 ++- meson.build | 100 ++++++++++++++++++++++--------- scripts/create_config | 131 -------------------------------------= ---- tests/qtest/bios-tables-test.c | 2 +- 6 files changed, 80 insertions(+), 168 deletions(-) delete mode 100755 scripts/create_config diff --git a/Makefile b/Makefile index cc0b053..bab1021 100644 --- a/Makefile +++ b/Makefile @@ -190,7 +190,7 @@ clean: recurse-clean rm -f fsdev/*.pod scsi/*.pod rm -f $(foreach f,$(generated-files-y),$(f) $(f)-timestamp) =20 -VERSION ?=3D $(shell cat VERSION) +VERSION =3D $(shell cat $(SRC_PATH)/VERSION) =20 dist: qemu-$(VERSION).tar.bz2 =20 diff --git a/block.c b/block.c index 67c5028..67ca543 100644 --- a/block.c +++ b/block.c @@ -443,13 +443,13 @@ static int bdrv_format_is_whitelisted(const char *for= mat_name, bool read_only) return 1; /* no whitelist, anything goes */ } =20 - for (p =3D whitelist_rw; *p; p++) { + for (p =3D whitelist_rw; p < &whitelist_rw[ARRAY_SIZE(whitelist_rw)]; = p++) { if (!strcmp(format_name, *p)) { return 1; } } if (read_only) { - for (p =3D whitelist_ro; *p; p++) { + for (p =3D whitelist_ro; p < &whitelist_ro[ARRAY_SIZE(whitelist_ro= )]; p++) { if (!strcmp(format_name, *p)) { return 1; } diff --git a/configure b/configure index 99ed6fa..13b03ac 100755 --- a/configure +++ b/configure @@ -6905,7 +6905,7 @@ if test "$slirp" !=3D "no"; then echo "SLIRP_LIBS=3D$slirp_libs" >> $config_host_mak fi if [ "$slirp" =3D "git" -o "$slirp" =3D "internal" ]; then - echo "config-host.h: slirp/all" >> $config_host_mak + echo "all Makefile: slirp/all" >> $config_host_mak fi if test "$vde" =3D "yes" ; then echo "CONFIG_VDE=3Dy" >> $config_host_mak @@ -6983,7 +6983,6 @@ if test "$xfs" =3D "yes" ; then echo "CONFIG_XFS=3Dy" >> $config_host_mak fi qemu_version=3D$(head $source_path/VERSION) -echo "VERSION=3D$qemu_version" >>$config_host_mak echo "PKGVERSION=3D$pkgversion" >>$config_host_mak echo "SRC_PATH=3D$source_path" >> $config_host_mak echo "TARGET_DIRS=3D$target_list" >> $config_host_mak @@ -7742,7 +7741,7 @@ echo "GENISOIMAGE=3D$genisoimage" >> $config_host_mak echo "MESON=3D$meson" >> $config_host_mak echo "CC=3D$cc" >> $config_host_mak if $iasl -h > /dev/null 2>&1; then - echo "IASL=3D$iasl" >> $config_host_mak + echo "CONFIG_IASL=3D$iasl" >> $config_host_mak fi echo "HOST_CC=3D$host_cc" >> $config_host_mak echo "CXX=3D$cxx" >> $config_host_mak @@ -8271,10 +8270,10 @@ echo "PIXMAN_CFLAGS=3D$pixman_cflags" >> $config_ho= st_mak echo "PIXMAN_LIBS=3D$pixman_libs" >> $config_host_mak =20 if [ "$fdt" =3D "git" ]; then - echo "config-host.h: dtc/all" >> $config_host_mak + echo "all Makefile: dtc/all" >> $config_host_mak fi if [ "$capstone" =3D "git" -o "$capstone" =3D "internal" ]; then - echo "config-host.h: capstone/all" >> $config_host_mak + echo "all Makefile: capstone/all" >> $config_host_mak fi if test -n "$LIBCAPSTONE"; then echo "LIBCAPSTONE=3D$LIBCAPSTONE" >> $config_host_mak diff --git a/meson.build b/meson.build index e2e3348..cb2ffd6 100644 --- a/meson.build +++ b/meson.build @@ -12,6 +12,8 @@ config_host =3D keyval.load(meson.current_build_dir() / '= config-host.mak') config_all_disas =3D keyval.load(meson.current_build_dir() / 'config-all-d= isas.mak') enable_modules =3D 'CONFIG_MODULES' in config_host build_docs =3D 'BUILD_DOCS' in config_host +config_host_data =3D configuration_data() +genh =3D [] =20 add_project_arguments(config_host['QEMU_CFLAGS'].split(), language: ['c', 'objc']) @@ -342,13 +344,47 @@ if 'CONFIG_LIBPMEM' in config_host link_args: config_host['LIBPMEM_LIBS'].spli= t()) endif =20 -create_config =3D find_program('scripts/create_config') +# Create config-host.h + +config_host_data.set('QEMU_VERSION', '"@0@"'.format(meson.project_version(= ))) +config_host_data.set('QEMU_VERSION_MAJOR', meson.project_version().split('= .')[0]) +config_host_data.set('QEMU_VERSION_MINOR', meson.project_version().split('= .')[1]) +config_host_data.set('QEMU_VERSION_MICRO', meson.project_version().split('= .')[2]) + +arrays =3D ['CONFIG_AUDIO_DRIVERS', 'CONFIG_BDRV_RW_WHITELIST', 'CONFIG_BD= RV_RO_WHITELIST'] +ignored =3D ['HOST_USB', 'HOST_CC'] +strings =3D ['HOST_DSOSUF', 'CONFIG_IASL'] +foreach k, v: config_host + if arrays.contains(k) + if v !=3D '' + v =3D '"' + '", "'.join(v.split()) + '", ' + endif + config_host_data.set(k, v) + elif k =3D=3D 'ARCH' + config_host_data.set('HOST_' + v.to_upper(), 1) + elif ignored.contains(k) + # do nothing + elif k.startswith('qemu') and (k.endswith('dir') or k.endswith('path')) + config_host_data.set_quoted('CONFIG_' + k.to_upper(), v) + elif strings.contains(k) + config_host_data.set_quoted(k, v) + elif k.startswith('CONFIG_') or k.startswith('HAVE_') or k.startswith('H= OST_') + if v =3D=3D 'y' or v =3D=3D 'm' + config_host_data.set(k, 1) + else + config_host_data.set(k, v) + endif + endif +endforeach +genh +=3D configure_file(output: 'config-host.h', configuration: config_ho= st_data) + minikconf =3D find_program('scripts/minikconf.py') target_dirs =3D config_host['TARGET_DIRS'].split() have_user =3D false have_system =3D false config_devices_mak_list =3D [] config_devices_h =3D {} +config_target_h =3D {} config_target_mak =3D {} kconfig_external_symbols =3D [ 'CONFIG_KVM', @@ -364,16 +400,36 @@ kconfig_external_symbols =3D [ 'CONFIG_LINUX', 'CONFIG_PVRDMA', ] +ignored =3D ['TARGET_XML_FILES', 'TARGET_ABI_DIR', 'TARGET_DIRS'] foreach target : target_dirs have_user =3D have_user or target.endswith('-user') - config_target =3D keyval.load(meson.current_build_dir() / target / 'conf= ig-target.mak') + config_host + config_target =3D keyval.load(meson.current_build_dir() / target / 'conf= ig-target.mak') + + config_target_data =3D configuration_data() + foreach k, v: config_target + if not k.startswith('TARGET_') and not k.startswith('CONFIG_') + # do nothing + elif ignored.contains(k) + # do nothing + elif k =3D=3D 'TARGET_BASE_ARCH' + config_target_data.set('TARGET_' + v.to_upper(), 1) + elif k =3D=3D 'TARGET_NAME' + config_target_data.set_quoted(k, v) + elif v =3D=3D 'y' + config_target_data.set(k, 1) + else + config_target_data.set(k, v) + endif + endforeach + config_target_h +=3D {target: configure_file(output: target + '-config-t= arget.h', + configuration: config_targe= t_data)} =20 if target.endswith('-softmmu') have_system =3D true =20 base_kconfig =3D [] foreach sym : kconfig_external_symbols - if sym in config_target + if sym in config_target or sym in config_host base_kconfig +=3D '@0@=3Dy'.format(sym) endif endforeach @@ -387,14 +443,16 @@ foreach target : target_dirs command: [minikconf, config_host['CONFIG_MINIKCONF_MODE'], config_devices_mak, '@DEPFILE@', '@INPUT@', base_kconfig]) - config_devices_h +=3D {target: custom_target( - target + '-config-devices.h', - input: config_devices_mak, - output: target + '-config-devices.h', - capture: true, - command: [create_config, '@INPUT@'])} + + config_devices_data =3D configuration_data() + config_devices =3D keyval.load(config_devices_mak) + foreach k, v: config_devices + config_devices_data.set(k, 1) + endforeach config_devices_mak_list +=3D config_devices_mak - config_target +=3D keyval.load(config_devices_mak) + config_devices_h +=3D {target: configure_file(output: target + '-confi= g-devices.h', + configuration: config_devi= ces_data)} + config_target +=3D config_devices endif config_target_mak +=3D {target: config_target} endforeach @@ -434,7 +492,6 @@ config_all +=3D { =20 # Generators =20 -genh =3D [] hxtool =3D find_program('scripts/hxtool') shaderinclude =3D find_program('scripts/shaderinclude.pl') qapi_gen =3D find_program('scripts/qapi-gen.py') @@ -458,7 +515,7 @@ qapi_gen_depends =3D [ meson.source_root() / 'scripts/q= api/__init__.py', =20 qemu_version_cmd =3D [find_program('scripts/qemu-version.sh'), meson.current_source_dir(), - config_host['PKGVERSION'], config_host['VERSION']] + config_host['PKGVERSION'], meson.project_version()] qemu_version =3D custom_target('qemu-version.h', output: 'qemu-version.h', command: qemu_version_cmd, @@ -467,13 +524,6 @@ qemu_version =3D custom_target('qemu-version.h', build_always_stale: true) genh +=3D qemu_version =20 -config_host_h =3D custom_target('config-host.h', - input: meson.current_build_dir() / 'config-h= ost.mak', - output: 'config-host.h', - capture: true, - command: [create_config, '@INPUT@']) -genh +=3D config_host_h - hxdep =3D [] hx_headers =3D [ ['qemu-options.hx', 'qemu-options.def'], @@ -805,13 +855,14 @@ foreach target : target_dirs config_target =3D config_target_mak[target] target_name =3D config_target['TARGET_NAME'] arch =3D config_target['TARGET_BASE_ARCH'] - arch_srcs =3D [] + arch_srcs =3D [config_target_h[target]] arch_deps =3D [] c_args =3D config_target['QEMU_CFLAGS'].split() + ['-DNEED_CPU_H', '-DCONFIG_TARGET=3D"@0@-config-target.h"'.format(target), '-DCONFIG_DEVICES=3D"@0@-config-devices.h"'.format(targe= t)] link_args =3D config_target['QEMU_LDFLAGS'].split() =20 + config_target +=3D config_host target_inc =3D [include_directories('target' / config_target['TARGET_BAS= E_ARCH'])] if host_machine.system() =3D=3D 'linux' target_inc +=3D include_directories('linux-headers', is_system: true) @@ -872,19 +923,12 @@ foreach target : target_dirs objects =3D common_all.extract_objects(target_common.sources()) deps =3D target_common.dependencies() =20 - # TODO: Change to generator once obj-y goes away - config_target_h =3D custom_target(target + '-config-target.h', - input: meson.current_build_dir() / target / = 'config-target.mak', - output: target + '-config-target.h', - capture: true, - command: [create_config, '@INPUT@']) - target_specific =3D specific_ss.apply(config_target, strict: false) arch_srcs +=3D target_specific.sources() arch_deps +=3D target_specific.dependencies() =20 lib =3D static_library('qemu-' + target, - sources: arch_srcs + [config_target_h] + genh, + sources: arch_srcs + genh, objects: objects, include_directories: target_inc, c_args: c_args, diff --git a/scripts/create_config b/scripts/create_config deleted file mode 100755 index ec5c0b4..0000000 --- a/scripts/create_config +++ /dev/null @@ -1,131 +0,0 @@ -#!/bin/sh - -test $# -gt 0 && exec < $1 - -echo "/* Automatically generated by create_config - do not modify */" - -while read line; do - -case $line in - VERSION=3D*) # configuration - version=3D${line#*=3D} - major=3D$(echo "$version" | cut -d. -f1) - minor=3D$(echo "$version" | cut -d. -f2) - micro=3D$(echo "$version" | cut -d. -f3) - echo "#define QEMU_VERSION \"$version\"" - echo "#define QEMU_VERSION_MAJOR $major" - echo "#define QEMU_VERSION_MINOR $minor" - echo "#define QEMU_VERSION_MICRO $micro" - ;; - qemu_*dir=3D* | qemu_*path=3D*) # qemu-specific directory configuration - name=3D${line%=3D*} - value=3D${line#*=3D} - define_name=3D$(echo $name | LC_ALL=3DC tr '[a-z]' '[A-Z]') - eval "define_value=3D\"$value\"" - echo "#define CONFIG_$define_name \"$define_value\"" - # save for the next definitions - eval "$name=3D\$define_value" - ;; - prefix=3D*) - # save for the next definitions - prefix=3D${line#*=3D} - ;; - IASL=3D*) # iasl executable - value=3D${line#*=3D} - echo "#define CONFIG_IASL $value" - ;; - CONFIG_AUDIO_DRIVERS=3D*) - drivers=3D${line#*=3D} - echo "#define CONFIG_AUDIO_DRIVERS \\" - for drv in $drivers; do - echo " \"${drv}\",\\" - done - echo "" - ;; - CONFIG_BDRV_RW_WHITELIST=3D*) - echo "#define CONFIG_BDRV_RW_WHITELIST\\" - for drv in ${line#*=3D}; do - echo " \"${drv}\",\\" - done - echo " NULL" - ;; - CONFIG_BDRV_RO_WHITELIST=3D*) - echo "#define CONFIG_BDRV_RO_WHITELIST\\" - for drv in ${line#*=3D}; do - echo " \"${drv}\",\\" - done - echo " NULL" - ;; - CONFIG_*=3Dy) # configuration - name=3D${line%=3D*} - echo "#define $name 1" - ;; - CONFIG_*=3Dn) # configuration - ;; - CONFIG_*=3D*) # configuration - name=3D${line%=3D*} - value=3D${line#*=3D} - echo "#define $name $value" - ;; - HAVE_*=3Dy) # configuration - name=3D${line%=3D*} - echo "#define $name 1" - ;; - HAVE_*=3D*) # configuration - name=3D${line%=3D*} - value=3D${line#*=3D} - echo "#define $name $value" - ;; - ARCH=3D*) # configuration - arch=3D${line#*=3D} - arch_name=3D$(echo $arch | LC_ALL=3DC tr '[a-z]' '[A-Z]') - echo "#define HOST_$arch_name 1" - ;; - HOST_USB=3D*) - # do nothing - ;; - HOST_CC=3D*) - # do nothing - ;; - HOST_*=3Dy) # configuration - name=3D${line%=3D*} - echo "#define $name 1" - ;; - HOST_DSOSUF=3D*) - echo "#define HOST_DSOSUF \"${line#*=3D}\"" - ;; - HOST_*=3D*) # configuration - name=3D${line%=3D*} - value=3D${line#*=3D} - echo "#define $name $value" - ;; - TARGET_BASE_ARCH=3D*) # configuration - target_base_arch=3D${line#*=3D} - base_arch_name=3D$(echo $target_base_arch | LC_ALL=3DC tr '[a-z]' '[A-= Z]') - echo "#define TARGET_$base_arch_name 1" - ;; - TARGET_XML_FILES=3D*) - # do nothing - ;; - TARGET_ABI_DIR=3D*) - # do nothing - ;; - TARGET_NAME=3D*) - target_name=3D${line#*=3D} - echo "#define TARGET_NAME \"$target_name\"" - ;; - TARGET_DIRS=3D*) - # do nothing - ;; - TARGET_*=3Dy) # configuration - name=3D${line%=3D*} - echo "#define $name 1" - ;; - TARGET_*=3D*) # configuration - name=3D${line%=3D*} - value=3D${line#*=3D} - echo "#define $name $value" - ;; -esac - -done # read diff --git a/tests/qtest/bios-tables-test.c b/tests/qtest/bios-tables-test.c index d49b398..d25ff35 100644 --- a/tests/qtest/bios-tables-test.c +++ b/tests/qtest/bios-tables-test.c @@ -88,7 +88,7 @@ typedef struct { static char disk[] =3D "tests/acpi-test-disk-XXXXXX"; static const char *data_dir =3D "tests/data/acpi"; #ifdef CONFIG_IASL -static const char *iasl =3D stringify(CONFIG_IASL); +static const char *iasl =3D CONFIG_IASL; #else static const char *iasl; #endif --=20 1.8.3.1