From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from shymkent.ilbers.de ([unix socket]) by shymkent (Cyrus 2.5.10-Debian-2.5.10-3+deb9u2) with LMTPA; Tue, 24 Dec 2024 00:17:23 +0100 X-Sieve: CMU Sieve 2.4 Received: from mail-pj1-f58.google.com (mail-pj1-f58.google.com [209.85.216.58]) by shymkent.ilbers.de (8.15.2/8.15.2/Debian-8+deb9u1) with ESMTPS id 4BNNHLku001787 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Tue, 24 Dec 2024 00:17:22 +0100 Received: by mail-pj1-f58.google.com with SMTP id 98e67ed59e1d1-2efa74481fdsf4318085a91.1 for ; Mon, 23 Dec 2024 15:17:22 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1734995835; cv=pass; d=google.com; s=arc-20240605; b=k6lIpNSD6voC055A4OxCSXHo8AvUYsypZIJIGuqUjzQB5q3+WcRSKlucrhEMto85+V j1MDm+SaHSnG/N1ciaz7z+r4OjyhmkINbsYAMT1fcLuihHKyGOpaub+t5E5gYODq8Pgf 8pJw+5JJcTSIpFjuR8ns0OTIYLyD16wva9gesTyKf8OFP/r3sBybF4ACEA4Btf/qR58z qG2FJqIcNcYJYMbfckoOS/UBZmwNwH7binjrlOemHY5tqr1yRjT7Qo/yrOSqOkPKsxz0 Aq+HO/EE1h3vOhVU9EVCHLOvK+/z2WoEg4nnHAYLMJDxVkXIRlfigKEj3+2dJ1LaN6U8 hWjQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=list-unsubscribe:list-subscribe:list-archive:list-help:list-post :list-id:mailing-list:precedence:reply-to:feedback-id:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=yASF1ERrphqXq/fdzilmbBLDaStlu/Q0BIrjDwGEP8w=; fh=5pOvcKgbiMUDNxGDiY2tcplvZp/4aq3pd8NqQc///M4=; b=T42pJYc/N6fK+AzI7rLPbF4ABbcyEWGJB4Nghy8VBXL8T9zSiHnYq0lz7eYVyeEfg2 6wldAlbggiViyXMO5vtj+AojVClF6ScXuyvMOi3i5cR8H99XcliYlDbZ/buVNkynyd+8 pFg+JIgtCiuS9H2BmZQjhZoaLC2wjrdJVWHASrGhTdwaeMNx9sH0nOyNfMJtVGD1HW0d IrVwJJ1NTYr/D7ij8boqsAVLyo1/HAzf1kFoxncO7rJFfIvc1rpKAZE7gsrItUIHbNYF 1Ng9/OMBuLcYv/U98TZlnUy+GcVuscM5X9a8d8TcrJxPUZftIi6E2ixSVV0UAOm3aDsH f27A==; darn=ilbers.de ARC-Authentication-Results: i=2; gmr-mx.google.com; dkim=pass header.i=@siemens.com header.s=fm1 header.b="q/Xn6XtO"; spf=pass (google.com: domain of fm-1325773-20241223231711a21eeb4636c832dcf1-3fwfe7@rts-flowmailer.siemens.com designates 185.136.64.226 as permitted sender) smtp.mailfrom=fm-1325773-20241223231711a21eeb4636c832dcf1-3FwFe7@rts-flowmailer.siemens.com; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=siemens.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlegroups.com; s=20230601; t=1734995835; x=1735600635; darn=ilbers.de; h=list-unsubscribe:list-subscribe:list-archive:list-help:list-post :list-id:mailing-list:precedence:reply-to :x-original-authentication-results:x-original-sender:feedback-id :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:from:to:cc:subject:date:message-id:reply-to; bh=yASF1ERrphqXq/fdzilmbBLDaStlu/Q0BIrjDwGEP8w=; b=rB0cPLhkW2E9XKXLJ8tL069xK5AiEhjcIe3OHRNTzb2qTCE9wC+mDv82fcvdauA1C5 LGhhqb+vEvuNezuSG3IJTFoRiwUDEdvQE3QRxavjKURkICrB39sZtIWxG4I+WaYMwduV HKN5hptpv4GAJVTd718HoSPOOvzsXU5mbYyGUjP+akJzs2562wICfhXB5xLCzwnUFNrj g1j/ZDmysFE+CVxJz4zwc6qX2nWNjpKFtciowDwrNKKvS4Q1o6eI9vLFiOwGk9o7qwDq miD+pKufm2jCZBFoYO5+miTD5XuFSo14QhsUOAVA5lPTJqHyW30Yef+D+D9Pn3Z04x6s UJTQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1734995835; x=1735600635; h=list-unsubscribe:list-subscribe:list-archive:list-help:list-post :x-spam-checked-in-group:list-id:mailing-list:precedence:reply-to :x-original-authentication-results:x-original-sender:feedback-id :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:x-beenthere:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=yASF1ERrphqXq/fdzilmbBLDaStlu/Q0BIrjDwGEP8w=; b=XWW0668E/Ddhw/2/g9ziM6ZPvhmcE5v1tjV9GpM7ETHVOezV1yLMOKuElM/rHdWeJZ ha+oFwWyYpiubVYtE+YxOn5vv7C7KRjE6TzyyclPbOOkF8SpdFvHkTFssguO4OLTSFUo IGk0/MAX7eDYRGA0n9lXgWSpbnF5FoAQ/wk34VdYDbz+6aAIswio3tUhgIRNtjGeDtm9 +ESm9UC36LJQiI8JOSWXw9ziIv2slMrGIDd299dKk0356AMC2iZLaNEwr3sVlQiAMxWg QKqSbn9VVBttGmyB0jO3QGTKdszrAB3zYJfhW5y1GTOpkNEdiji8UrdCwhPtblRQ8m0S bvtQ== X-Forwarded-Encrypted: i=2; AJvYcCUT/sz8QHsIMcG6I2wqBo5/gU86Wbs5LYsfGcRa/SZqyY3yCDLaEAQKxPj2hgj0WfCuQLis@ilbers.de X-Gm-Message-State: AOJu0YxWsQnUc1cl8IeNmoSEH7SPzPzp97xNAboPssgo28AdJxlVOodo KIhxGTxZLCn26gTq+ZKdT5yv2wkc0D6HtJBsUd1++1KVtCEKrHnn X-Google-Smtp-Source: AGHT+IGFJNiziCsuyXFIJWct4uF6h08OspR9hBEu6XY0vjGseFzdVoVat+eJLB2a9B9sItn39KCzdw== X-Received: by 2002:a17:90b:53c8:b0:2ee:c2df:5d30 with SMTP id 98e67ed59e1d1-2f452eb11e1mr19238393a91.26.1734995835108; Mon, 23 Dec 2024 15:17:15 -0800 (PST) X-BeenThere: isar-users@googlegroups.com Received: by 2002:a17:90a:609:b0:2ee:126e:2f50 with SMTP id 98e67ed59e1d1-2f4430d6ea7ls978026a91.2.-pod-prod-05-us; Mon, 23 Dec 2024 15:17:14 -0800 (PST) X-Received: by 2002:a17:90a:d00b:b0:2ee:9a82:5a93 with SMTP id 98e67ed59e1d1-2f452e1d13amr22413294a91.14.1734995833719; Mon, 23 Dec 2024 15:17:13 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1734995833; cv=none; d=google.com; s=arc-20240605; b=e/fKGcu0zQ1Uu8UdKiUZEXN5NCrf0DTlwJVQbRmcvyxfRv6uTDtmlK5JmqimTCdYk/ jGl0tJEgaJDb/yhzZLO1qK7R6xfYglX2EcGn7XQwmhYAwhXiianbAJjQnGWaQ4uCpq67 LQ7Lq2kb6YD7ajGt2u009YWQExEv86huuCgyh/RhJo+hjxbskIeCdoB2MLLZqcRtvtBC UUQeNYXoYb3djbm+MuI15N9uBAW4hYrvur33Tz0fNq15iCynPGg62/3cBTopIb9O43s5 Alfa7jg36I12i9bRcn9TVi4OyS+gJFlqHfsY/nDOG75ZJOqNNGz6h14k/hH11vYelsQH TuLQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=feedback-id:content-transfer-encoding:mime-version:references :in-reply-to:message-id:date:subject:cc:to:from:dkim-signature; bh=CaeVB2ad7KtNgoPCfKhhfZzns20SUPcTQapgCCpVbpw=; fh=3bh9z2BWAzGAc1byRhMi0K+arMZmX5BQHE0sOxINdyU=; b=B0bzZt7h4n1Foy5gu9Nx3K49R6589BFqoaTdoMQ6wLO5U/EaZDAOli8fzow4IYdQq1 OlqdRc3ZbgaGzUrZxI9q+EOXrE58C3wp3glkbDgcX1L7hrueuoDhZc2ltAVTAUkdaoSU SZkh6kIhZg4dDM5OA14CjG9j4pEqytrYu1UMhaixIMC92wnn1NGdQNNurX10Enns/9oW 6Y7o/WMsQOueQIm3HLkMWvkE2wJV9xM5uko+22LSJH8ENwuLua3i6K6C4ZRsU4tYnOiq 365CHafLWZJxDePbMCS5iNoQ2LgiSk0MUMLvhwVC4Sw0QkoJMb/9SWgy6KZ3N01oAVb8 YIRQ==; dara=google.com ARC-Authentication-Results: i=1; gmr-mx.google.com; dkim=pass header.i=@siemens.com header.s=fm1 header.b="q/Xn6XtO"; spf=pass (google.com: domain of fm-1325773-20241223231711a21eeb4636c832dcf1-3fwfe7@rts-flowmailer.siemens.com designates 185.136.64.226 as permitted sender) smtp.mailfrom=fm-1325773-20241223231711a21eeb4636c832dcf1-3FwFe7@rts-flowmailer.siemens.com; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=siemens.com Received: from mta-64-226.siemens.flowmailer.net (mta-64-226.siemens.flowmailer.net. [185.136.64.226]) by gmr-mx.google.com with ESMTPS id 98e67ed59e1d1-2f2db992ae5si1324818a91.1.2024.12.23.15.17.13 for (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 23 Dec 2024 15:17:13 -0800 (PST) Received-SPF: pass (google.com: domain of fm-1325773-20241223231711a21eeb4636c832dcf1-3fwfe7@rts-flowmailer.siemens.com designates 185.136.64.226 as permitted sender) client-ip=185.136.64.226; Received: by mta-64-226.siemens.flowmailer.net with ESMTPSA id 20241223231711a21eeb4636c832dcf1 for ; Tue, 24 Dec 2024 00:17:11 +0100 From: "chris.larson via isar-users" To: isar-users@googlegroups.com Cc: Christopher Larson Subject: [PATCHv2] lists.bbclass,bitbake.conf: use features lists Date: Mon, 23 Dec 2024 16:16:56 -0700 Message-ID: <20241223231656.120820-1-chris.larson@siemens.com> In-Reply-To: <20241216201602.619-1-chris.larson@siemens.com> References: <20241216201602.619-1-chris.larson@siemens.com> MIME-Version: 1.0 X-Flowmailer-Platform: Siemens Feedback-ID: 519:519-1325773:519-21489:flowmailer X-Original-Sender: chris.larson@siemens.com X-Original-Authentication-Results: gmr-mx.google.com; dkim=pass header.i=@siemens.com header.s=fm1 header.b="q/Xn6XtO"; spf=pass (google.com: domain of fm-1325773-20241223231711a21eeb4636c832dcf1-3fwfe7@rts-flowmailer.siemens.com designates 185.136.64.226 as permitted sender) smtp.mailfrom=fm-1325773-20241223231711a21eeb4636c832dcf1-3FwFe7@rts-flowmailer.siemens.com; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=siemens.com X-Original-From: chris.larson@siemens.com Reply-To: chris.larson@siemens.com Content-Type: text/plain; charset="UTF-8" Precedence: list Mailing-list: list isar-users@googlegroups.com; contact isar-users+owners@googlegroups.com List-ID: X-Spam-Checked-In-Group: isar-users@googlegroups.com X-Google-Group-Id: 914930254986 List-Post: , List-Help: , List-Archive: , List-Unsubscribe: , X-Spam-Status: No, score=-4.9 required=5.0 tests=DKIMWL_WL_MED,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,MAILING_LIST_MULTI, RCVD_IN_DNSWL_BLOCKED,RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL, RCVD_IN_RP_CERTIFIED,RCVD_IN_RP_RNBL,RCVD_IN_RP_SAFE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on shymkent.ilbers.de X-TUID: qrNp0U3dPTYx From: Christopher Larson The intention behind this commit is to ease and encourage the use of Yocto-style features variables, beyond our current usage: - Add a bbclass to ease the handling of list variables in general - Add default values for the features variables - Add the features variables to the list variables - Add a combined features variable The intention is that a downstream layer will use `bb.utils.contains` or `bb.utils.contains_any` to enable or disable functionality based on the presence of defined features, rather than adding new variables in each case. Signed-off-by: Christopher Larson --- meta/classes/lists.bbclass | 105 +++++++++++++++++++++++++++++++++++++ meta/conf/bitbake.conf | 19 +++++++ 2 files changed, 124 insertions(+) create mode 100644 meta/classes/lists.bbclass v2 changes: - Corrected email address. - Added missing LIST_VARIABLES event handler - Changed the examples to the more appropriate ROOTFS_FEATURES diff --git a/meta/classes/lists.bbclass b/meta/classes/lists.bbclass new file mode 100644 index 00000000..db8f5837 --- /dev/null +++ b/meta/classes/lists.bbclass @@ -0,0 +1,105 @@ +# Functions to improve the functionality of bitbake list variables. +# +# - Add the ability to remove items from a list variable without using :remove. +# - Add the ability for a list item to imply the addition of other list items. +# + +# Usage requires either adding the variable name to LIST_VARIABLES, or manually +# adding a :remove and a :prepend to each fully supported list variable. +# +# To remove items from a configured list, simply append the item to be removed +# to the variable with a '-' or '~' prefix. For example, to remove 'alpha' from +# ROOTFS_FEATURES, add '-alpha' to ROOTFS_FEATURES. +# +# To support implied list items, create a mapping of items to be appended to +# the variable when a specific item is present. For example, to append 'beta' +# to ROOTFS_FEATURES when 'alpha' is present, configure ROOTFS_FEATURES as such, +# then set IMPLIED_ROOTFS_FEATURES[alpha] = "beta". +# +# Boilerplate example: +# +# # Either this: +# LIST_VARIABLES += "ROOTFS_FEATURES" +# +# # Or this: +# ROOTFS_FEATURES:remove = "${@remove_prefixed_items('ROOTFS_FEATURES', d)}" +# ROOTFS_FEATURES:prepend = "${@add_implied_items('ROOTFS_FEATURES', 'IMPLIED_ROOTFS_FEATURES', d)} " +# +# Usage example: +# +# # ROOTFS_FEATURES will be "beta alpha" if the following configuration is used: +# IMPLIED_ROOTFS_FEATURES[alpha] = "beta" +# ROOTFS_FEATURES += "alpha" +# +# # ROOTFS_FEATURES will be "first" if the following configuration is used: +# ROOTFS_FEATURES = "first second" +# ROOTFS_FEATURES += "-second" + +python enable_list_variables() { + """Enable list variable functionality.""" + for variable in d.getVar("LIST_VARIABLES").split(): + d.setVar(variable + ':remove', ' ${@remove_prefixed_items("%s", d)}' % variable) + d.setVar(variable + ':prepend', '${@add_implied_items("%s", "IMPLIED_%s", d)} ' % (variable, variable)) +} +enable_list_variables[eventmask] = "bb.event.ConfigParsed" +addhandler enable_list_variables + +def remove_prefixed_items(var, d): + """Return the items to be removed from var with :remove. + + This function is intended to be used in a :remove handler to remove + items from a variable. It will interpret items prefixed with a '-' + or '~' as items to be removed. + """ + # Use a flag to avoid infinite recursion. + if d.getVarFlag(var, 'remove_prefixed_items_internal') == '1': + return '' + + from collections import Counter + + d.setVarFlag(var, 'remove_prefixed_items_internal', '1') + try: + value = d.getVar(var) + counter = Counter() + for v in value.split(): + if v.startswith('-') or v.startswith('~'): + counter[v[1:]] -= 1 + counter[v] -= 1 + else: + counter[v] += 1 + return ' '.join(v for v, c in counter.items() if c < 1) + finally: + d.delVarFlag(var, 'remove_prefixed_items_internal') + + +def add_implied_items(var, implied_var, d): + """Return the items to be appended due to the presence of other items in var. + + This function is intended to be used in a :append handler to append + items from a variable. It will rely on the supplied mapping of implied items + to append the corresponding items. + """ + # Use a flag to avoid infinite recursion. + if d.getVarFlag(var, 'add_implied_items_internal') == '1': + return '' + + def implied_items(item, implied_mapping, d, seen=None): + """Return the implied items for a given item.""" + if seen is None: + seen = set() + if item in seen: + return '' + seen.add(item) + implied = implied_mapping.get(item, '').split() + return ' '.join(implied + [implied_items(f, implied_mapping, d, seen) for f in implied]) + + d.setVarFlag(var, 'add_implied_items_internal', '1') + try: + value = d.getVar(var) + implied_mapping = d.getVarFlags(implied_var) + if implied_mapping is None: + return '' + + return ' '.join(implied_items(f, implied_mapping, d) for f in value.split()) + finally: + d.delVarFlag(var, 'add_implied_items_internal') diff --git a/meta/conf/bitbake.conf b/meta/conf/bitbake.conf index cda98035..9f3b8a4e 100644 --- a/meta/conf/bitbake.conf +++ b/meta/conf/bitbake.conf @@ -172,6 +172,25 @@ BBINCLUDELOGS ??= "yes" # Add event handlers for bitbake INHERIT += "isar-events sstate" +# Make features variables available +INHERIT += "lists" + +LIST_VARIABLES += "BASE_REPO_FEATURES MACHINE_FEATURES DISTRO_FEATURES ROOTFS_FEATURES" + +BASE_REPO_FEATURES ??= "" +BASE_REPO_FEATURES[doc] = "Specifies the list of features for the base-apt repository." + +MACHINE_FEATURES ??= "" +MACHINE_FEATURES[doc] = "Specifies the list of hardware features the MACHINE is capable of supporting." + +DISTRO_FEATURES ??= "" +DISTRO_FEATURES[doc] = "The software support you want in your distribution for various features." + +COMBINED_FEATURES = "${@oe.utils.set_intersect('DISTRO_FEATURES', 'MACHINE_FEATURES', d)}" + +ROOTFS_FEATURES ??= "" +ROOTFS_FEATURES[doc] = "The list of features to be included in a root filesystem. Typically, you configure this variable in an image recipe or class." + # Buildstats requires IMAGE_ROOTFS to be always defined IMAGE_ROOTFS ??= "${WORKDIR}/rootfs" INHERIT += "${@'buildstats' if bb.utils.to_boolean(d.getVar('USE_BUILDSTATS')) else ''}" -- 2.47.1 -- You received this message because you are subscribed to the Google Groups "isar-users" group. To unsubscribe from this group and stop receiving emails from it, send an email to isar-users+unsubscribe@googlegroups.com. To view this discussion visit https://groups.google.com/d/msgid/isar-users/20241223231656.120820-1-chris.larson%40siemens.com.