From patchwork Mon Nov 11 16:51:47 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christopher Larson X-Patchwork-Id: 3909 Return-Path: Received: from shymkent.ilbers.de ([unix socket]) by shymkent (Cyrus 2.5.10-Debian-2.5.10-3+deb9u2) with LMTPA; Mon, 11 Nov 2024 17:52:07 +0100 X-Sieve: CMU Sieve 2.4 Received: from mail-oo1-f60.google.com (mail-oo1-f60.google.com [209.85.161.60]) by shymkent.ilbers.de (8.15.2/8.15.2/Debian-8+deb9u1) with ESMTPS id 4ABGq5dw013494 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Mon, 11 Nov 2024 17:52:06 +0100 Received: by mail-oo1-f60.google.com with SMTP id 006d021491bc7-5eb6275167dsf3268742eaf.1 for ; Mon, 11 Nov 2024 08:52:06 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1731343920; cv=pass; d=google.com; s=arc-20240605; b=F4ywyboLBSV/5sMFTO00nX6W8jNxsDJ/ri21Og99BkIarvaBlmAMloBl4mtrYbB04u 2bRlu5nwhG+MuUg72ZjeLtYn59j2nZ0vqNgPbXo0qmqkNoyM0Hs6o9kh8gMbNIjcUnNT M97zFCY8itetGhd8n36T5BmoDFrNSv3YDqKPSFQg6vnr/F2Ty/1Q6Pj7GMmNwj7uuJuC E9ir84OgZo0hGDweocWGE2QYcaNqwjtREkRdRgDX7WgZHk/dnA1ZfxaxKB7K8/+pZYg3 UWvsjjwDEhJ+9IaP1NSEd5gMdMbFO0jMaxf6TQBwLEm98Toz52tU5kPo2YoZqc4CWNIC zfHA== 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:to:subject:message-id:date:from :mime-version:sender:dkim-signature:dkim-signature; bh=gpKnnHs8UXf85cto1LUIbK6cmwqRXzyEHRHlDQQ5kf0=; fh=UirCuTYBYeyRvzuGqL0W06/EAd+z/CR1s5tuEmVN1TU=; b=IjVaVU9A4LM0yaYKiXVqAw2U5WnQmKjdFGeexHgbcbjUfgfbe08Ia6zUmZhKt7vgNF KlX+8rIqHchLa0FD896NcGSlr3oUPNDLMOZ6jVsUbU2dk2xtLsJ4c7YZB/1WeGFRt4VY sanMqHc1HDkfBOtjJRyf8lZXahbD7FKw5joWuNi18eT2lB02NKM8jHKWJzUvh4DRImNv sdzZpdhNZZI1kxsqYw08MBFWcU0vpSaunYTLVHlBOFbMffwreTJobHlXJYzGiaoY4jHw wquLrjKbS+ypE/A4J8oR49zL5tVNpvGRzzxYbuR6K8v8BZZBwG04vhJcH6A+PtMihORZ nGZA==; darn=isar-build.org ARC-Authentication-Results: i=2; gmr-mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=LteXe+Ds; spf=pass (google.com: domain of kergoth@gmail.com designates 2607:f8b0:4864:20::c35 as permitted sender) smtp.mailfrom=kergoth@gmail.com; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com; dara=pass header.i=@googlegroups.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlegroups.com; s=20230601; t=1731343920; x=1731948720; darn=isar-build.org; h=list-unsubscribe:list-subscribe:list-archive:list-help:list-post :list-id:mailing-list:precedence:x-original-authentication-results :x-original-sender:to:subject:message-id:date:from:mime-version :sender:from:to:cc:subject:date:message-id:reply-to; bh=gpKnnHs8UXf85cto1LUIbK6cmwqRXzyEHRHlDQQ5kf0=; b=Bn8ud0h3qAspDOJCO/JYjwFiqW0tq9sz2VbL9d9cRZ5EBGIWIfVrLoqoWw6a0tVzyK YNK8BkVmmz1xkPi/Hcd6eN+AFuS9PZPLWeWPv+dobFtQp5PDYlV4z8eMqdYkJNGedUpw RvXt8o6UhVUbnwdQaqoajCdbKYGiGWWsL23QPH8lG5eISXzqsGjF7TNSFpU0Hz1fyM6J vCEWaZMWxRGCCfEBu7Bvp0wJ68rxAeL4BimN0SDgEYu8zCyyYje/Tc2iMMCEhPetFIG/ P43cnnDbeOgJM8LJte63No6q8kpvo50CsbxCgklrFISqRKf7br7oRH9yJXdWlqtMERod za2A== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1731343920; x=1731948720; darn=isar-build.org; h=list-unsubscribe:list-subscribe:list-archive:list-help:list-post :list-id:mailing-list:precedence:x-original-authentication-results :x-original-sender:to:subject:message-id:date:from:mime-version:from :to:cc:subject:date:message-id:reply-to; bh=gpKnnHs8UXf85cto1LUIbK6cmwqRXzyEHRHlDQQ5kf0=; b=fBUhoKMyLme2p5PSDBZmYj2eynuWWKguUvJrFrwIHhMVdpFk8kqMRnXJP1ljsBYxOD 9z+5F9OtYG7Rmx61a4tNHiJoGFYywmkBr9zrjfWdCa+vN4GeeT6YYTC8UbyNbIdEbMHk jW0LhGMcaX3TKgkTj3dM6VooL6ixg8ebMWPb5xEk6KGpwUIFZwu94g3gLzDUWpyGtQpM NZo2OzEKMDFyH3e3p82p5lJusp42PuX1zbe3l+4FGjjRHOplJsJmHgFMtij7DsEOVooS i8XqaAuHQ98spVdOfPF+o+97Zn/gwFueSNF07vVPL0GA7/wwpNBf9XifZ1SrH8p2eubU 6ISw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1731343920; x=1731948720; h=list-unsubscribe:list-subscribe:list-archive:list-help:list-post :x-spam-checked-in-group:list-id:mailing-list:precedence :x-original-authentication-results:x-original-sender:to:subject :message-id:date:from:mime-version:x-beenthere:x-gm-message-state :sender:from:to:cc:subject:date:message-id:reply-to; bh=gpKnnHs8UXf85cto1LUIbK6cmwqRXzyEHRHlDQQ5kf0=; b=QCrJSv9926HmUzYW9EyQg58LeWVUfmLt+pMFA9YFMctKNUaWs4voKFyE8y2KSrrVQA MQxw2WZp6ahtZKvm0hCO1U1uIvayK4Em/A/d06euN708JxEo+ufWdNLJVURQk0wanwoT FYu2RfLEi8ut4fm//53n/9AYHjOVjoF846HQ2udJcnpyyaPgK/96EWFyBMRbmpux+PBF ZpWwYvEbxC2WpkchrH1H0VFABsqmWm998Grtp0Cdd9rEPWUaWPPlSU5L2pUm1Z2s53jO s8u7TBOSjVxcderjtDC3wYF8Vux+1/xYTIjJIJawq30mZIWIcKE3kWEooL7osLVfhsy5 gWZQ== Sender: isar-users@googlegroups.com X-Forwarded-Encrypted: i=2; AJvYcCU9IoClaYJCWN5qp0g04JKK5xTaHNzWlfns0iOmD84D/ZVsDYk0ls1hHZ2OMRBUNa24B9TD2RU=@isar-build.org X-Gm-Message-State: AOJu0YyWHOE2p27TVnWS5F/GIgzXiJXVDmudfiutQFK6L3zLx4rJh0th d8+pX12DRtJKT+bcKdtNvf6xfL8mmUf6HVGaVkdG3NXzwqRgrPBM X-Google-Smtp-Source: AGHT+IFMNzqKQufwSPUbpd9IPVjMmHaSW+ItlQglpn0xNu/uQd7vkvFzALz8C+rPeRpiFqxQFaW7vA== X-Received: by 2002:a05:6820:1a0e:b0:5ed:fe6a:26f0 with SMTP id 006d021491bc7-5ee57c862fbmr9395759eaf.8.1731343920198; Mon, 11 Nov 2024 08:52:00 -0800 (PST) X-BeenThere: isar-users@googlegroups.com Received: by 2002:a05:6820:2002:b0:5eb:4cf9:9ee1 with SMTP id 006d021491bc7-5ee45bdde07ls2842600eaf.1.-pod-prod-04-us; Mon, 11 Nov 2024 08:51:59 -0800 (PST) X-Received: by 2002:a05:6820:1f08:b0:5eb:85ee:2cbd with SMTP id 006d021491bc7-5ee57c60694mr8889382eaf.6.1731343919312; Mon, 11 Nov 2024 08:51:59 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1731343919; cv=none; d=google.com; s=arc-20240605; b=YTwBVqpNDrvtABBIXEZN/6kafY9XfE3FYnK/kx6eDHfpHGUl8V/jVm8Pj0Y0S3trb3 c0dC6hHihtmfrTwPRmU6L4X4DzsiZOKxF8lPsbM6sEnnCYIDKSTJiJPlFKJSBNBuO3cu NG73DnRLptcNYfaS3bVZu8r5sPWzqlOUf+vl7m8Cgl20RHsGtYNE4OLteq/4BcWLPQCt v3r1hVeAVDlyACbudbhHQBvJzsa1hqQM1PxP1w54U3eQabejnSig0wJFZ2T04DkCKBji iLuPBd+22i+4mUsHDJ5H1fQvHkboX1zFiX1jA6A7VRFLD6NUMP27Dooq/NiYhabi7h+5 pXsw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=to:subject:message-id:date:from:mime-version:dkim-signature; bh=sMvdHfjlKrFUIzjCgZRJJIWCJj+h5G5bu0QKD/p9iP4=; fh=7tclEdh7YbwSQowgJ6LNq720O7H5HTEaqj22NJWRE2E=; b=lNWJZB3Y92aP9DkRuFW3mFq75YUFeWNxJ6KhJtHxhLg5YVHzTDUm0ntrffkwlEYoxN MUWuCqPhC+jPfTLvSx05yl9SzX3i1TN8czbEdJNNhXLzOj9rnUWvyQOwbpPJ8W9HmQki rnVXV3xg0CZM/zO1ZneUk/bgQcQI8qTBI26+Cif3NjJRu+wV+PYCWYZhT5kstObrYpGz +Vk4HBdx/R9rkC3/yUigT9mh8SXgi7KTguyD26dPudLjcHn5Jth2tNstdworc+Qzw8Zq KlzlfO+9Yd3V4tFrwSYuwFWV/JowcrO0t3la5k8R0+0m41qG5D9asGjRFQv4yH4SzOYa M3jA==; dara=google.com ARC-Authentication-Results: i=1; gmr-mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=LteXe+Ds; spf=pass (google.com: domain of kergoth@gmail.com designates 2607:f8b0:4864:20::c35 as permitted sender) smtp.mailfrom=kergoth@gmail.com; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com; dara=pass header.i=@googlegroups.com Received: from mail-oo1-xc35.google.com (mail-oo1-xc35.google.com. [2607:f8b0:4864:20::c35]) by gmr-mx.google.com with ESMTPS id 006d021491bc7-5ee493844f5si478093eaf.0.2024.11.11.08.51.59 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 11 Nov 2024 08:51:59 -0800 (PST) Received-SPF: pass (google.com: domain of kergoth@gmail.com designates 2607:f8b0:4864:20::c35 as permitted sender) client-ip=2607:f8b0:4864:20::c35; Received: by mail-oo1-xc35.google.com with SMTP id 006d021491bc7-5ebc4e89240so2135652eaf.1 for ; Mon, 11 Nov 2024 08:51:59 -0800 (PST) X-Received: by 2002:a05:6820:2184:b0:5eb:6a67:6255 with SMTP id 006d021491bc7-5ee57ba7b74mr9890831eaf.1.1731343918868; Mon, 11 Nov 2024 08:51:58 -0800 (PST) MIME-Version: 1.0 From: Christopher Larson Date: Mon, 11 Nov 2024 16:51:47 +0000 Message-ID: Subject: [PATCH] RFC: features.bbclass,bitbake.conf: use features lists To: isar-users@googlegroups.com X-Original-Sender: kergoth@gmail.com X-Original-Authentication-Results: gmr-mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=LteXe+Ds; spf=pass (google.com: domain of kergoth@gmail.com designates 2607:f8b0:4864:20::c35 as permitted sender) smtp.mailfrom=kergoth@gmail.com; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com; dara=pass header.i=@googlegroups.com 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.7 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,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-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= Any thoughts on something like this? Too much? The intention is that downstreams would use standard bitbake functions to check features, the same way they do in the Yocto Project, which ensures that signatures and variable checksums never include the entirety of the features variable, only the presence or absence of the feature being checked. This also adds bits to allow one to disable a feature without having to use the problematic :remove mechanism, which can't be undone by downstream layers easily. In this case, MY_FEATURES += "feature-a" and then MY_FEATURES += "-feature-a" would result in removing it. Order matters, so it can be re-added again later on without complication. It also adds a minimal mechanism to let one feature pull in others implicitly, which helps to avoid duplication when a feature is a superset of another. --- '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." +ROOTFS_FEATURES:remove = "${@remove_prefixed_features('ROOTFS_FEATURES', d)}" +ROOTFS_FEATURES:prepend = "${@add_implied_features('ROOTFS_FEATURES', 'IMPLIED_ROOTFS_FEATURES', d)} " + # 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.45.2 diff --git a/meta/classes/features.bbclass b/meta/classes/features.bbclass new file mode 100644 index 00000000..32964c91 --- /dev/null +++ b/meta/classes/features.bbclass @@ -0,0 +1,91 @@ +# Functions to manipulate feature lists +# +# This class provides functions to manipulate feature lists. The functions +# are intended to be used in :remove and :append handlers to remove or append +# items to a variable. The remove will interpret items prefixed with a '-' +# as items to be removed. The append function will rely on a mapping of +# implied features to append the corresponding items. The intention is to +# provide the ability for a feature to imply enabling of other features, +# much like a dependency, but without the implication of order. +# +# Usage example: +# +# IMAGE_FEATURES ??= "" +# IMAGE_FEATURES:remove = "${@remove_prefixed_features('IMAGE_FEATURES', d)}" +# IMAGE_FEATURES:prepend = "${@add_implied_features('IMAGE_FEATURES', 'IMPLIED_IMAGE_FEATURES', d)} " +# IMAGE_FEATURES_DISABLED = "${@' '.join(f for f in remove_prefixed_features('IMAGE_FEATURES', d).split() if not f.startswith('-'))}" +# +# IMPLIED_IMAGE_FEATURES[alpha] = "beta" +# +# IMAGE_FEATURES += "alpha theta -theta" +# +# # SOME_VARIBLE="yes" if 'beta' is in IMAGE_FEATURES, "no" otherwise +# SOME_VARIABLE = "${@bb.utils.contains('IMAGE_FEATURES', 'beta', 'yes', 'no', d)}" +# # SOME_VARIBLE_TWO="yes" if 'beta' and 'alpha' are in IMAGE_FEATURES, "no" otherwise +# SOME_VARIABLE_TWO = "${@bb.utils.contains('IMAGE_FEATURES', ['beta', 'alpha'], 'yes', 'no', d)}" +# # SOME_VARIBLE_THREE="yes" if 'beta' or 'theta' are in IMAGE_FEATURES, "no" otherwise +# SOME_VARIABLE_THREE = "${@bb.utils.contains_any('IMAGE_FEATURES', ['beta', 'theta'], 'yes', 'no', d)}" + + +def remove_prefixed_features(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 '-' as + items to be removed. + + As an internal note, the 'remove_prefixed_features_internal' flag is used to + avoid infinite recursion. + """ + if d.getVarFlag(var, 'remove_prefixed_features_internal') == '1': + return '' + + from collections import Counter + + d.setVarFlag(var, 'remove_prefixed_features_internal', '1') + try: + value = d.getVar(var) + counter = Counter() + for v in value.split(): + if 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_features_internal') + +def add_implied_features(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 mapping of implied features + to append the corresponding items. + + As an internal note, the 'add_implied_features_internal' flag is used to + avoid infinite recursion. + """ + if d.getVarFlag(var, 'add_implied_features_internal') == '1': + return '' + + def implied_features(feature, implied_mapping, d, seen=None): + """Return the implied features for a given feature.""" + if seen is None: + seen = set() + if feature in seen: + return '' + seen.add(feature) + implied = implied_mapping.get(feature, '').split() + return ' '.join(implied + [implied_features(f, implied_mapping, d, seen) for f in implied]) + + d.setVarFlag(var, 'add_implied_features_internal', '1') + try: + value = d.getVar(var) + implied_mapping = d.getVarFlags(implied_var) + if implied_mapping is None: + return '' + + return ' '.join(implied_features(f, implied_mapping, d) for f in value.split()) + finally: + d.delVarFlag(var, 'add_implied_features_internal') diff --git a/meta/conf/bitbake.conf b/meta/conf/bitbake.conf index cda98035..4dedb081 100644 --- a/meta/conf/bitbake.conf +++ b/meta/conf/bitbake.conf @@ -172,6 +172,31 @@ BBINCLUDELOGS ??= "yes" # Add event handlers for bitbake INHERIT += "isar-events sstate" +# Make features variables available +INHERIT += "features" + +BASE_REPO_FEATURES ??= "" +BASE_REPO_FEATURES[doc] = "Specifies the list of features for the base-apt repository." +BASE_REPO_FEATURES:remove = "${@remove_prefixed_features('BASE_REPO_FEATURES', d)}" +BASE_REPO_FEATURES:prepend = "${@add_implied_features('BASE_REPO_FEATURES', 'IMPLIED_BASE_REPO_FEATURES', d)} " + +MACHINE_FEATURES ??= "" +MACHINE_FEATURES[doc] = "Specifies the list of hardware features the MACHINE is capable of supporting." +MACHINE_FEATURES:remove = "${@remove_prefixed_features('MACHINE_FEATURES', d)}" +MACHINE_FEATURES:prepend = "${@add_implied_features('MACHINE_FEATURES', 'IMPLIED_MACHINE_FEATURES', d)} " + +DISTRO_FEATURES ??= "" +DISTRO_FEATURES[doc] = "The software support you want in your distribution for various features." +DISTRO_FEATURES:remove = "${@remove_prefixed_features('DISTRO_FEATURES', d)}" +DISTRO_FEATURES:prepend = "${@add_implied_features('DISTRO_FEATURES', 'IMPLIED_DISTRO_FEATURES', d)} " + +COMBINED_FEATURES = "${@oe.utils.set_intersect('DISTRO_FEATURES',