From patchwork Fri Jan 10 22:56:51 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Yoann Congal X-Patchwork-Id: 55384 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id C2CCAE7719D for ; Fri, 10 Jan 2025 22:57:12 +0000 (UTC) Received: from mail-wm1-f67.google.com (mail-wm1-f67.google.com [209.85.128.67]) by mx.groups.io with SMTP id smtpd.web11.4542.1736549823491231268 for ; Fri, 10 Jan 2025 14:57:04 -0800 Authentication-Results: mx.groups.io; dkim=pass header.i=@smile.fr header.s=google header.b=drSvB+iH; spf=pass (domain: smile.fr, ip: 209.85.128.67, mailfrom: yoann.congal@smile.fr) Received: by mail-wm1-f67.google.com with SMTP id 5b1f17b1804b1-436345cc17bso19156305e9.0 for ; Fri, 10 Jan 2025 14:57:03 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=smile.fr; s=google; t=1736549821; x=1737154621; darn=lists.openembedded.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=GPoFJwRTCPd0zFAjmtwhgmcJbD9PcocBdIXv9GmAyd0=; b=drSvB+iHof/VlIRy9B7vke0MsLKEtBQEgSa/aVIbiVWxEBuwvZajx4iDAuag80av1K LqkVBeWbel2YKZhA7R5MuQzIWV7csnugB0JsNDdKHQPFul1HnH6NkGhh5XGNKXr4tZUt ZroWwmTW0pKMvejA9MkN9SFHeJklsFGrcMl1k= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1736549821; x=1737154621; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=GPoFJwRTCPd0zFAjmtwhgmcJbD9PcocBdIXv9GmAyd0=; b=miRN9KV/BS0TdGzjeVKIYsy1TGuFG60TzQ7sc5J8v/r9ueqf46wlFyHP9fQVJlGB5d 9rdE9YeWZaokI9Ydl3h+/zJGy12f45+J8PJGPE32oZGBr42n1L4RUIp0gcrj+nkcNWf5 jj0HlcsTUtRoWrKdPITpjliRd/7fXZOxKr5axzEpIOJ8THqkKBvpovICvsTAXZqHAnSY UwvXfK7kdRMa1p2FXMaZQUyMJmOkPmZSsSHW+ykIaKfXSMLJ5HErzPsH4enxRKNdSR4P oW33+kM5ldUHob0rKbd2tLmIuGYxDv+GnO8+T5zr0vUkI5tYukg7/LxxZxQq4B3RjNUu Vigg== X-Gm-Message-State: AOJu0Yx2NNgMH3OSAC03OqD1tTd3UfvPGMpzJOgea1T+CrYd48L5TPVO sQjV6o6yLM6e4/EPeTXzbtMEQjsVnXEBQ0mw9bNcLiHXyJH26F4L52uVFQd40R/nMJL/XzgEmGk GvVn+gQ== X-Gm-Gg: ASbGnctFEaOaHx5+iopIvoYROwXPElWBLSvjEXP5aXCgs1TBmdwgNf4w4Ll2CawpWIh GYRP5bsSkb9lCXDUe16xkU8aIDV1vUhr5lAVHjTFrIWXpatfCXGTh9v7rcmTzaTsDfLTS7aYfOK YY88dBttVQ9d0Obpv81366SBTHcVZ883gkAd4h9zf65MbS0+qwqxUbAMNi7zkAvKuVch88DKpN/ A01mJKaXKQrXoZhNTl5/Wtw7yo4UedWmxDU4oinW/83fL1MKhEnIwqBsqN0JLFTeVIFy4YeuEqr 3hP+SOQEANr//aXxPCi1uUEEoWJeVMHdMI74oBClLuIEDAAN681aSdgxsnqcNiY= X-Google-Smtp-Source: AGHT+IElXGVdHeVgCRw9FsvWb4KqlYVyVhSOlDhZexyK+DzONG1OzEspX7O9/pO+e8XPyMfjGqypBw== X-Received: by 2002:a05:600c:1987:b0:436:1aa6:b8ee with SMTP id 5b1f17b1804b1-436e2677378mr109333545e9.2.1736549821142; Fri, 10 Jan 2025 14:57:01 -0800 (PST) Received: from P-ASN-ECS-830T8C3.home (2a01cb000deef000bdfc82d7e16362a9.ipv6.abo.wanadoo.fr. [2a01:cb00:dee:f000:bdfc:82d7:e163:62a9]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-436e2dc0f69sm98727805e9.13.2025.01.10.14.57.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 10 Jan 2025 14:57:00 -0800 (PST) From: Yoann Congal To: bitbake-devel@lists.openembedded.org Cc: Yoann Congal , =?utf-8?q?Ghislain_Mang=C3=A9?= Subject: [PATCH v2 1/2] tests/parse: add test for ?= and ??= operators for variable flags Date: Fri, 10 Jan 2025 23:56:51 +0100 Message-Id: <20250110225652.3892828-1-yoann.congal@smile.fr> X-Mailer: git-send-email 2.39.5 MIME-Version: 1.0 List-Id: X-Webhook-Received: from li982-79.members.linode.com [45.33.32.79] by aws-us-west-2-korg-lkml-1.web.codeaurora.org with HTTPS for ; Fri, 10 Jan 2025 22:57:12 -0000 X-Groupsio-URL: https://lists.openembedded.org/g/bitbake-devel/message/17011 From: Yoann Congal Run the test with: $ bitbake-selftest bb.tests.parse.ParseTest.test_parse_defaulttest . ---------------------------------------------------------------------- Ran 1 test in 0.001s OK This is a test case for [YOCTO #15685] Signed-off-by: Yoann Congal Reviewed-by: Ghislain Mangé --- v1->v2: * More comprehensive test cases with =, ?= and ??= combinations --- lib/bb/tests/parse.py | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) diff --git a/lib/bb/tests/parse.py b/lib/bb/tests/parse.py index 56eb66be9..38c3e3253 100644 --- a/lib/bb/tests/parse.py +++ b/lib/bb/tests/parse.py @@ -75,6 +75,47 @@ unset B[flag] self.assertEqual(d.getVarFlag("A","flag"), None) self.assertEqual(d.getVar("B"), "2") + defaulttest = """ +A = "set value" +A ??= "default value" + +A[flag_set_vs_question] = "set flag" +A[flag_set_vs_question] ?= "question flag" + +A[flag_set_vs_default] = "set flag" +A[flag_set_vs_default] ??= "default flag" + +A[flag_question] ?= "question flag" + +A[flag_default] ??= "default flag" + +A[flag_question_vs_default] ?= "question flag" +A[flag_question_vs_default] ??= "default flag" + +A[flag_default_vs_question] ??= "default flag" +A[flag_default_vs_question] ?= "question flag" + +A[flag_set_question_default] = "set flag" +A[flag_set_question_default] ?= "question flag" +A[flag_set_question_default] ??= "default flag" + +A[flag_set_default_question] = "set flag" +A[flag_set_default_question] ??= "default flag" +A[flag_set_default_question] ?= "question flag" +""" + def test_parse_defaulttest(self): + f = self.parsehelper(self.defaulttest) + d = bb.parse.handle(f.name, self.d)[''] + self.assertEqual(d.getVar("A"), "set value") + self.assertEqual(d.getVarFlag("A","flag_set_vs_question"), "set flag") + self.assertEqual(d.getVarFlag("A","flag_set_vs_default"), "set flag") + self.assertEqual(d.getVarFlag("A","flag_question"), "question flag") + self.assertEqual(d.getVarFlag("A","flag_default"), "default flag") + self.assertEqual(d.getVarFlag("A","flag_question_vs_default"), "question flag") + self.assertEqual(d.getVarFlag("A","flag_default_vs_question"), "question flag") + self.assertEqual(d.getVarFlag("A","flag_set_question_default"), "set flag") + self.assertEqual(d.getVarFlag("A","flag_set_default_question"), "set flag") + exporttest = """ A = "a" export B = "b" From patchwork Fri Jan 10 22:56:52 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Yoann Congal X-Patchwork-Id: 55383 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id C1D6FE77188 for ; Fri, 10 Jan 2025 22:57:12 +0000 (UTC) Received: from mail-wm1-f48.google.com (mail-wm1-f48.google.com [209.85.128.48]) by mx.groups.io with SMTP id smtpd.web11.4543.1736549823997040818 for ; Fri, 10 Jan 2025 14:57:04 -0800 Authentication-Results: mx.groups.io; dkim=pass header.i=@smile.fr header.s=google header.b=3qxW9NeP; spf=pass (domain: smile.fr, ip: 209.85.128.48, mailfrom: yoann.congal@smile.fr) Received: by mail-wm1-f48.google.com with SMTP id 5b1f17b1804b1-436326dcb1cso18784055e9.0 for ; Fri, 10 Jan 2025 14:57:03 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=smile.fr; s=google; t=1736549822; x=1737154622; darn=lists.openembedded.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=n67qZIS3cIasDCrU9J9goz+tOJkkw66szrsBiA7Bxso=; b=3qxW9NePC1L+xvEOSeHnduniq/OWrXFYo7ouExCY1WhtzGzAtpDFKIjs8LKXiXPbHI tgu7zW/j8l9f8tIUSHpTpsWP9WX0qxPL92UP3fSj927fs6LX9dMnhAvc6qs9YVV/0wsw tqY1RBhUACE3XyCOL1IOdzHjgFUrjiCGiKYng= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1736549822; x=1737154622; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=n67qZIS3cIasDCrU9J9goz+tOJkkw66szrsBiA7Bxso=; b=wa2cm92CaaQt4Ne7gPWFuf0uI1U+MXIPmJRq+RO3qH2O4QLHqc6KjLvEQ8YMuxQWPO 0DG57bNCpYexk/sSrGLvktvNUggtnaL/zfQV7OZJamKQcpSPGZGT5qzq8t0+UTGq2cfD Q88D+1iFgxs5bnMXqe6gt7Eg/86EEkXiCgw1SO6oJg3+Q7rzOz9+wBBy64uZZVVtN3Gg DMXEYvPTKgDUIfbT97Jofoi58eOxn8VKWC1RNXczLWmrFn4NK1b6spQGsZ5wp/BnKBMM odhERVdDWI4vXZxlfBE8/1WNgFMw230H03OYkdyMFSbOJByr/4pl6xub6TYPBdLkpm75 2DMg== X-Gm-Message-State: AOJu0YzSZ1KnA8PofFRrLLdHr4sb9peDbDyZ4epjfNKv7MdPHV5kRtAp 2XPjFNASnuOYDc2qe698UiBUM+fTaRaH9TDBNVt8etWYRsNCqA2aXaacZJbGIKKovZ+tgppTNEF ydG8= X-Gm-Gg: ASbGncsX7fBFJhKpNxmRm7UtoM+LrzA7lGg3vGIreWj54DKXLnOCGUOq+elTYhD551Y ZCklOmoZAWqw1tkCTmqh61NgPUh97JBttEjjcFSD4M7pRx36kcFRWLYorZQ8Ufhx3Hnxm4+IFOv HFKOBYfyHeN6x8fmKtsS9r+NRH2fHxZMzN9kfEw6rbfk7pI2IJcRYQGdrjy6BN+R8yrlK4knkdv 5eLPGf9op8JYkycytsskDjb/P8J3OPh2VEHuLHlLLU0/kZTPCWFpwy29vQ1mzvI4yga6N2GGtox yuvvnMYCQ62AHFyZ841HqVZyNGxI0hi6eiF7ZnRy9pvMn7TmseKVtHx2+LxilDk= X-Google-Smtp-Source: AGHT+IG1puTkL8tSBDFtqS1IgJ5MkYfBzIFvtT4SCNmu/wG374YtKqx7qQPxtaZHBzQzhyJpzo0TPw== X-Received: by 2002:a05:600c:4e46:b0:436:488f:50a with SMTP id 5b1f17b1804b1-436e26be5aemr124662055e9.17.1736549821699; Fri, 10 Jan 2025 14:57:01 -0800 (PST) Received: from P-ASN-ECS-830T8C3.home (2a01cb000deef000bdfc82d7e16362a9.ipv6.abo.wanadoo.fr. [2a01:cb00:dee:f000:bdfc:82d7:e163:62a9]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-436e2dc0f69sm98727805e9.13.2025.01.10.14.57.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 10 Jan 2025 14:57:01 -0800 (PST) From: Yoann Congal To: bitbake-devel@lists.openembedded.org Cc: Yoann Congal , =?utf-8?q?Ghislain_Mang=C3=A9?= , Ola Nilsson Subject: [PATCH v2 2/2] data_smart: fix ??= operator for variable flags Date: Fri, 10 Jan 2025 23:56:52 +0100 Message-Id: <20250110225652.3892828-2-yoann.congal@smile.fr> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20250110225652.3892828-1-yoann.congal@smile.fr> References: <20250110225652.3892828-1-yoann.congal@smile.fr> MIME-Version: 1.0 List-Id: X-Webhook-Received: from li982-79.members.linode.com [45.33.32.79] by aws-us-west-2-korg-lkml-1.web.codeaurora.org with HTTPS for ; Fri, 10 Jan 2025 22:57:12 -0000 X-Groupsio-URL: https://lists.openembedded.org/g/bitbake-devel/message/17012 From: Yoann Congal ??= operator works for variable value by defining a "_defaultval" flag. Use something similar for flags: For the default value of the flag "flag_name", define a flag "_defaultval_flag_flagname" that is used when reading flag_name but no other value has been set. Fixes [YOCTO #15685] Signed-off-by: Yoann Congal Reviewed-by: Ghislain Mangé Suggested-by: Ola Nilsson --- v1->v2: * Refactor condition from Ghislain's suggestion * Added Suggested-by: Ola Nilsson since they correctly pointed out the fix location. --- lib/bb/data_smart.py | 2 ++ lib/bb/parse/ast.py | 5 ++++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/lib/bb/data_smart.py b/lib/bb/data_smart.py index c6049d578..897ceeb32 100644 --- a/lib/bb/data_smart.py +++ b/lib/bb/data_smart.py @@ -827,6 +827,8 @@ class DataSmart(MutableMapping): value = copy.copy(local_var[flag]) elif flag == "_content" and "_defaultval" in local_var and not noweakdefault: value = copy.copy(local_var["_defaultval"]) + elif "_defaultval_flag_"+flag in local_var and not noweakdefault: + value = copy.copy(local_var["_defaultval_flag_"+flag]) if flag == "_content" and local_var is not None and ":append" in local_var and not parsing: diff --git a/lib/bb/parse/ast.py b/lib/bb/parse/ast.py index 2f6c6a005..30ede008d 100644 --- a/lib/bb/parse/ast.py +++ b/lib/bb/parse/ast.py @@ -152,7 +152,10 @@ class DataNode(AstNode): flag = None if 'flag' in groupd and groupd['flag'] is not None: - flag = groupd['flag'] + if groupd["lazyques"]: + flag = "_defaultval_flag_"+groupd['flag'] + else: + flag = groupd['flag'] elif groupd["lazyques"]: flag = "_defaultval"