From nobody Fri Dec 19 07:41:46 2025 Delivered-To: importer@patchew.org Received-SPF: temperror (zoho.com: Error in retrieving data from DNS) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=temperror (zoho.com: Error in retrieving data from DNS) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1549562775881634.666040848136; Thu, 7 Feb 2019 10:06:15 -0800 (PST) Received: from localhost ([127.0.0.1]:44571 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gro3p-0008Q1-Mb for importer@patchew.org; Thu, 07 Feb 2019 13:06:05 -0500 Received: from eggs.gnu.org ([209.51.188.92]:57319) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1grnvs-0001uX-RQ for qemu-devel@nongnu.org; Thu, 07 Feb 2019 12:57:55 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1grnvr-0002Cq-Is for qemu-devel@nongnu.org; Thu, 07 Feb 2019 12:57:52 -0500 Received: from mail-wr1-x443.google.com ([2a00:1450:4864:20::443]:35345) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1grnvr-00026j-AB for qemu-devel@nongnu.org; Thu, 07 Feb 2019 12:57:51 -0500 Received: by mail-wr1-x443.google.com with SMTP id z18so855410wrh.2 for ; Thu, 07 Feb 2019 09:57:45 -0800 (PST) Received: from 640k.lan ([93.56.166.5]) by smtp.gmail.com with ESMTPSA id q12sm12708982wmf.2.2019.02.07.09.57.43 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 07 Feb 2019 09:57:43 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=nfkgXXx3MWh2uH/8jURh2pzZF1eDUgWEyXWXb9rUCxM=; b=Z5hyHgJ2lYuVGTypDLAYf/3QqqCxz8Kn3xpEmbR+I4zE70EJLnKdWBgGuhMNghj5Eo adY9+Q7jhugvGoVvYv0PZOrb4eYJ7ML/pHGSsQAvrQOCBkQ96R4T0bkW15+BfNPfVd6m +osvOW3QO+Bk22NJ/ALcgDOvSRD9PABO9i80L7aost2i0XzqqGkugZrtW1GopXEwPJNj QtC/GNOkc+GZKrq6OuBpoFa+ATuXBhO4q3lgzPO7jiif5tbqiDXwsge15hbbfJSZpG8O vBUN5XraZUKzokMmpHwAM2iyrG9l0SR09Ttfe1E2PiVS110aTE6mSfU0lmVTXAHVoM4P ZviA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references; bh=nfkgXXx3MWh2uH/8jURh2pzZF1eDUgWEyXWXb9rUCxM=; b=i6PN/dGXcICesvdDL4OoCh4c5S0DMsuGaSpjHAKlqUjDWZqpklkqtKAm3a9IfBdnhf GUHGjfDqRy9Ktwatyq7+tUGd+hGEGn7wJCvcg4LNOyZ6zCnv75ZaRUgdviOj++MKEGf9 CMuindRU7eBWEJJi3vJUxcQEhKtIahUAL1ZhrRiE3eltUnFeGvPhahWsGWvSY6nCFlDS JImKF+vuD4qxqrUsai0CvFwopB988RIlLOPf7K9HMk+p+aBaSipDCmEbsZTZUkbvkrzG slVu9vcGPN222IxmzSiCreKs2zv01gy31R3BnFBv5sKv8UcxoqZhr47HLg1i2FCntnwj l4NQ== X-Gm-Message-State: AHQUAubpRGHtjIestRaGC6dpKPxTdinfSZSAUvb01OPVkcKwOfyrI7tW lFiXCdpmEooSKjZqq/chtLXX+RJy X-Google-Smtp-Source: AHgI3IYRLp/ukk9tX2KgeCsl4jCoO4X1zhNZA3f9B9qkqGj/xFDqQmJBND0TUF6oP4zEaNVXncwsJg== X-Received: by 2002:a5d:6803:: with SMTP id w3mr13612322wru.272.1549562263918; Thu, 07 Feb 2019 09:57:43 -0800 (PST) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Thu, 7 Feb 2019 18:56:50 +0100 Message-Id: <1549562254-41157-8-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1549562254-41157-1-git-send-email-pbonzini@redhat.com> References: <1549562254-41157-1-git-send-email-pbonzini@redhat.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::443 Subject: [Qemu-devel] [PATCH 07/51] minikconfig: implement allnoconfig and defconfig modes X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: thuth@redhat.com, philmd@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Apart from defconfig (which is a no-op), allyesconfig/allnoconfig/randcondfig can be implemented simply by ignoring the RHS of assignments and "default" statements. The RHS is replaced respectively by "true", "false" or a random value. However, allyesconfig and randconfig do not quite work, because all the files for hw/ARCH/Kconfig are sourced and therefore you could end up enabling some ARM boards in x86 or things like that. This is left for future work, but I am leaving it in to help debugging minikconf itself. allnoconfig mode is tied to a new configure option, --without-default-devic= es. Signed-off-by: Paolo Bonzini --- Makefile | 1 + configure | 12 +++++++++++- scripts/minikconf.py | 43 ++++++++++++++++++++++++++++++++++--------- 3 files changed, 46 insertions(+), 10 deletions(-) diff --git a/Makefile b/Makefile index 959ab9e..e444f91 100644 --- a/Makefile +++ b/Makefile @@ -331,6 +331,7 @@ endif =20 # This has to be kept in sync with Kconfig.host. MINIKCONF_ARGS =3D \ + $(CONFIG_MINIKCONF_MODE) \ $@ $*-config.devices.mak.d $< $(MINIKCONF_INPUTS) \ CONFIG_KVM=3D$(CONFIG_KVM) \ CONFIG_SPICE=3D$(CONFIG_SPICE) \ diff --git a/configure b/configure index 64f843f..39e80c7 100755 --- a/configure +++ b/configure @@ -486,7 +486,7 @@ libxml2=3D"" docker=3D"no" debug_mutex=3D"no" libpmem=3D"" -libudev=3D"no" +default_devices=3D"yes" =20 # cross compilers defaults, can be overridden with --cross-cc-ARCH cross_cc_aarch64=3D"aarch64-linux-gnu-gcc" @@ -997,6 +997,10 @@ for opt do ;; --with-trace-file=3D*) trace_file=3D"$optarg" ;; + --with-default-devices) default_devices=3D"yes" + ;; + --without-default-devices) default_devices=3D"no" + ;; --enable-gprof) gprof=3D"yes" ;; --enable-gcov) gcov=3D"yes" @@ -6183,6 +6187,7 @@ echo "capstone $capstone" echo "docker $docker" echo "libpmem support $libpmem" echo "libudev $libudev" +echo "default devices $default_devices" =20 if test "$supported_cpu" =3D "no"; then echo @@ -6244,6 +6249,11 @@ echo "GIT_UPDATE=3D$git_update" >> $config_host_mak =20 echo "ARCH=3D$ARCH" >> $config_host_mak =20 +if test "$default_devices" =3D "yes" ; then + echo "CONFIG_MINIKCONF_MODE=3D--defconfig" >> $config_host_mak +else + echo "CONFIG_MINIKCONF_MODE=3D--allnoconfig" >> $config_host_mak +fi if test "$debug_tcg" =3D "yes" ; then echo "CONFIG_DEBUG_TCG=3Dy" >> $config_host_mak fi diff --git a/scripts/minikconf.py b/scripts/minikconf.py index dd96ab9..dc1b612 100644 --- a/scripts/minikconf.py +++ b/scripts/minikconf.py @@ -14,17 +14,15 @@ from __future__ import print_function import os import sys import re +import random =20 - __all__ =3D [ 'KconfigParserError', 'KconfigData', 'KconfigParser' ] +__all__ =3D [ 'KconfigParserError', 'KconfigData', 'KconfigParser', + 'defconfig', 'allyesconfig', 'allnoconfig', 'randconfig' ] =20 def debug_print(*args): print('#' + (' '.join(str(x) for x in args))) pass =20 -def debug_print(*args): - #print ' '.join(str(x) for x in args) - pass - # ------------------------------------------- # KconfigData implements the Kconfig semantics. For now it can only # detect undefined symbols, i.e. symbols that were referenced in @@ -35,6 +33,11 @@ def debug_print(*args): # just its name). # ------------------------------------------- =20 +allyesconfig =3D lambda x: True +allnoconfig =3D lambda x: False +defconfig =3D lambda x: x +randconfig =3D lambda x: random.randint(0, 1) =3D=3D 1 + class KconfigData: class Expr: def __and__(self, rhs): @@ -188,7 +191,8 @@ class KconfigData: if self.cond.evaluate(): self.dest.set_value(True, self) =20 - def __init__(self): + def __init__(self, value_mangler=3Ddefconfig): + self.value_mangler =3D value_mangler self.previously_included =3D [] self.incl_info =3D None self.defined_vars =3D set() @@ -268,6 +272,7 @@ class KconfigData: self.clauses.append(KconfigData.AssignmentClause(var, val)) =20 def do_default(self, var, val, cond=3DNone): + val =3D self.value_mangler(val) self.clauses.append(KconfigData.DefaultClause(var, val, cond)) =20 def do_depends_on(self, var, expr): @@ -324,9 +329,10 @@ class KconfigParserError(Exception): return "%s: %s" % (self.loc, self.msg) =20 class KconfigParser: + @classmethod - def parse(self, fp): - data =3D KconfigData() + def parse(self, fp, mode=3DNone): + data =3D KconfigData(mode or KconfigParser.defconfig) parser =3D KconfigParser(data) parser.parse_file(fp) return data @@ -649,11 +655,30 @@ class KconfigParser: =20 if __name__ =3D=3D '__main__': argv =3D sys.argv + mode =3D defconfig + if len(sys.argv) > 1: + if argv[1] =3D=3D '--defconfig': + del argv[1] + elif argv[1] =3D=3D '--randconfig': + random.seed() + mode =3D randconfig + del argv[1] + elif argv[1] =3D=3D '--allyesconfig': + mode =3D allyesconfig + del argv[1] + elif argv[1] =3D=3D '--allnoconfig': + mode =3D allnoconfig + del argv[1] + if len(argv) =3D=3D 1: print ("%s: at least one argument is required" % argv[0], file=3Ds= ys.stderr) sys.exit(1) =20 - data =3D KconfigData() + if argv[1].startswith('-'): + print ("%s: invalid option %s" % (argv[0], argv[1]), file=3Dsys.st= derr) + sys.exit(1) + + data =3D KconfigData(mode) parser =3D KconfigParser(data) for arg in argv[3:]: m =3D re.match(r'^(CONFIG_[A-Z0-9_]+)=3D([yn]?)$', arg) --=20 1.8.3.1