From patchwork Fri Jan 10 19:08:41 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yoann Congal X-Patchwork-Id: 55354 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 C5044E7719C for ; Fri, 10 Jan 2025 19:09:20 +0000 (UTC) Received: from mail-wr1-f68.google.com (mail-wr1-f68.google.com [209.85.221.68]) by mx.groups.io with SMTP id smtpd.web10.401.1736536150184654806 for ; Fri, 10 Jan 2025 11:09:10 -0800 Authentication-Results: mx.groups.io; dkim=pass header.i=@smile.fr header.s=google header.b=wxP5czbE; spf=pass (domain: smile.fr, ip: 209.85.221.68, mailfrom: yoann.congal@smile.fr) Received: by mail-wr1-f68.google.com with SMTP id ffacd0b85a97d-385deda28b3so1466235f8f.0 for ; Fri, 10 Jan 2025 11:09:09 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=smile.fr; s=google; t=1736536148; x=1737140948; 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=zzfLq1OwDcWoNZX/DVu+nqKPp3FCVH+hwIFUFd6c74s=; b=wxP5czbESFqVniacu/OI7rZjQsSKD4bEe1UClzNnj1vu6RVpi7vYZtRAiv9K/h6tO0 luw6WP0fogp9T7SfjUbks6YDfL4j0/8oe+HsMrZIWMmPgIsOG6ZsM5/3if/6QtLR76OH ueoURKn3/Lwat065nhW2FCGEfYElzLwbV52GY= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1736536148; x=1737140948; 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=zzfLq1OwDcWoNZX/DVu+nqKPp3FCVH+hwIFUFd6c74s=; b=S9TbXFFb5Fgo8JaEPU/VXgtpeR3liRXiqVo/j6Apst5Us8WcPB2gM5Yt+/8hBFQq+d ph6WViUTlcHN+HM8KNiGYJfCBKpuN1LpZfcqHtqWuKqbNiSITC8VoKPP5+wEP/+DbMch LWBBrp7EIo44Rhemsy8nIjroeJfzSwWaLAqFd20THXPXNDOL+SoQeNmhi1RUuLjIzIIr cn5PpTJuoKYxx/OSC3YUCu4mUsdMVgvuFeVeLSQrqU9J/MTR2AA30uOh071mJxzL/iFW THQJlNWwyfNvlXwje70SmyZmZGRqBdhrPeXfQcUT0sOtFKa3GZvvLBqazmKmk0d2ntjB F0tQ== X-Gm-Message-State: AOJu0YyiUNHBAweRBwePljhvsRKlMH/ntG1LOgRHeBHEGgm+Cy4p5phM 3n/VB4Vkdtk4pyZd1lpE79GlGPF1RVlnDJir7ZMks2W6EeON3SW99N8fhYZVlWPzqvXwD4iBa8z QPdtkAQ== X-Gm-Gg: ASbGncvtYH6XSeBjdA4hL0Dx7wvT3VlEthsxjM2sKOMwqskYDNDEdGcmr2ggngZZ/dX WeFhhAz0QOqrphBu8ml3k1dP2tdX33KH2G/EjWJvBUQvR7ExvMtY6T1n2idY/BkRNaVAqfqwFnf KDxEC86ZBiM925jwKYSeoMceavKllk9W/Hsahf+biy2qXvrV3qSE9UeJWJiAO/yTopaHRhWlMOO ifuwp/J1B3+dJRcjgdhEOyRjQipAcwCmqoQUIrkKQZXNAz+wHpZBl7q50rQYr0qFdbaaE3gfzck nBe7vWiB82KQ2wg+IyNdax8dTXue/C5uHIsZ8j6SpJx91dDHbfyhHlBbAgggydY= X-Google-Smtp-Source: AGHT+IE1zqAmmvr/BtAzK4oMV0YZXqa/tfrSu5fBpSnQeQ3A21oydoDLqiPqp0KTSyJ8YNgXpzC3ZQ== X-Received: by 2002:a05:6000:1f81:b0:386:7fe:af8e with SMTP id ffacd0b85a97d-38a872fb17fmr9751272f8f.12.1736536147694; Fri, 10 Jan 2025 11:09:07 -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 ffacd0b85a97d-38a8e4c1cf2sm5275443f8f.99.2025.01.10.11.09.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 10 Jan 2025 11:09:07 -0800 (PST) From: Yoann Congal To: bitbake-devel@lists.openembedded.org Cc: Yoann Congal Subject: [PATCH 1/2] tests/parse: add test for ?= and ??= operators for variable flags Date: Fri, 10 Jan 2025 20:08:41 +0100 Message-Id: <20250110190842.3861684-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 19:09:20 -0000 X-Groupsio-URL: https://lists.openembedded.org/g/bitbake-devel/message/17008 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 --- lib/bb/tests/parse.py | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/lib/bb/tests/parse.py b/lib/bb/tests/parse.py index 56eb66be9..8e04458a0 100644 --- a/lib/bb/tests/parse.py +++ b/lib/bb/tests/parse.py @@ -75,6 +75,29 @@ 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" +""" + 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") + exporttest = """ A = "a" export B = "b" From patchwork Fri Jan 10 19:08:42 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yoann Congal X-Patchwork-Id: 55355 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 C3F06E77188 for ; Fri, 10 Jan 2025 19:09:20 +0000 (UTC) Received: from mail-wm1-f43.google.com (mail-wm1-f43.google.com [209.85.128.43]) by mx.groups.io with SMTP id smtpd.web11.408.1736536150599962652 for ; Fri, 10 Jan 2025 11:09:11 -0800 Authentication-Results: mx.groups.io; dkim=pass header.i=@smile.fr header.s=google header.b=Cy90bemL; spf=pass (domain: smile.fr, ip: 209.85.128.43, mailfrom: yoann.congal@smile.fr) Received: by mail-wm1-f43.google.com with SMTP id 5b1f17b1804b1-43626213fffso22174445e9.1 for ; Fri, 10 Jan 2025 11:09:10 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=smile.fr; s=google; t=1736536148; x=1737140948; 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=29mlo2Bz4XHbhFgoshgxOs+0MPjSIMUQ2Q+NNdgK94g=; b=Cy90bemLNAExSVTudJvZUUq8O4MJtc9NQ7VQhT3JW0grgZo6R+ZQ5DtquvFa8PUfm3 proGmB1F9JuOeR18RrRetTDU0t8uNjDhYrstoM0woQ2WEaOjhH3t0j83S2dWFY/H7r0K RjNR+GN00Vfxi88is1IcnGApa2ofyzyBhA54A= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1736536148; x=1737140948; 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=29mlo2Bz4XHbhFgoshgxOs+0MPjSIMUQ2Q+NNdgK94g=; b=ZLn+iKO/yvyWVrsPKdnEcMrWX5hx7rly6OgTT45UB+PJ05FbWsdWbsaXbNeXsNUxDF pQCU39wwdLWUhZ/2bLYjaqe2IlYhWcVHyLJyxbc5WWjlHGQw0NnBskMMlIzI7y72g499 f4fR0/VCZO2I7QwYvUwpK1a47NeaSxIw6tMpI4uxD0NJy+vObeTmC+/Mg4gP4HrdO/8P 25gBtWJwvG7CMNbKuhrMLKPGamZKsO63A1bVoDtWrHbD6oFBkdIFa0zSQdeZyyoGAc2Q H7Gf3GgIOIwHa3wrIwDsCLo8ZceUfL/NT0gJaYnnME4gxKWWdZayTCubLP1mUwypHVng 3ygA== X-Gm-Message-State: AOJu0YyT3nms7UJrzSfHs10NNUqMyAy7pagHhHPNLnYrTjAEtjwpZy15 a0bYOGwj9ByHBXZFMQKQWpuOGLawifyRD+zBljXv8uRWVedUQ0MsrnKLAdy0+4rCiLEYWb1WZk7 hYqs= X-Gm-Gg: ASbGncvQRlsFVgz9bhN0WN+NroIwcN4Wgo40gq8/xvbiU5zxqrBKQjotpGFapBhHC8C uSLjEXohTuaxbwqjZvswIF9h9K4aRGt8scxS/INtyD6/ahyZDntjGdcv+fPQYwao9yIrtaxisz3 7ZDe8jBV2RP8TD1HfTGKVc3fGk77VbVgzoJi+eFd4xnW4vaYzfIEXQFwDcBnSXs8sJlfsWMRZbl 6klytyHdG2SmbVmz97fykUYm6nPYU+BwA7BLk3qdHno00j3CCur9hRNy1qndpENekoz8Z5EgnnA io5N/Rya/PhOVGLxUmz33o+/cGpIp3aZMUuF/A3uTCaOG3xvrsMi5usMkpBw7CA= X-Google-Smtp-Source: AGHT+IGeBXjLtYe8PWWQSUZqRmLbHz3PmTF4hK7EEVQJuRpMboeRmEY1Ir+Xkobl6gCuXcgO2eaMNQ== X-Received: by 2002:a5d:5f87:0:b0:386:37f8:450b with SMTP id ffacd0b85a97d-38a8b0b7fc5mr7397782f8f.5.1736536148126; Fri, 10 Jan 2025 11:09:08 -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 ffacd0b85a97d-38a8e4c1cf2sm5275443f8f.99.2025.01.10.11.09.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 10 Jan 2025 11:09:07 -0800 (PST) From: Yoann Congal To: bitbake-devel@lists.openembedded.org Cc: Yoann Congal Subject: [PATCH 2/2] data_smart: fix ??= operator for variable flags Date: Fri, 10 Jan 2025 20:08:42 +0100 Message-Id: <20250110190842.3861684-2-yoann.congal@smile.fr> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20250110190842.3861684-1-yoann.congal@smile.fr> References: <20250110190842.3861684-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 19:09:20 -0000 X-Groupsio-URL: https://lists.openembedded.org/g/bitbake-devel/message/17009 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 --- lib/bb/data_smart.py | 2 ++ lib/bb/parse/ast.py | 4 +++- 2 files changed, 5 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..dcc845dcd 100644 --- a/lib/bb/parse/ast.py +++ b/lib/bb/parse/ast.py @@ -151,8 +151,10 @@ class DataNode(AstNode): bb.warn(key + " " + groupd[op] + " is not a recommended operator combination, please replace it.") flag = None - if 'flag' in groupd and groupd['flag'] is not None: + if 'flag' in groupd and groupd['flag'] is not None and not groupd["lazyques"]: flag = groupd['flag'] + elif 'flag' in groupd and groupd['flag'] is not None and groupd["lazyques"]: + flag = "_defaultval_flag_"+groupd['flag'] elif groupd["lazyques"]: flag = "_defaultval"